QWidget Flickering for frame by frame streaming of video
-
Make the QImage the correct format and size.
-
Make the QImage the correct format and size.
wrote on 13 Mar 2018, 12:45 last edited by@SGaist
Tried using
QImage::QImage(uchar * data, int width, int height, Format format, QImageCleanupFunction cleanupFunction = 0, void * cleanupInfo = 0)data = pixel data , updated by fetchBitmap(..) function above.
format = RGB888
where as per documentation it does not do a deep copy. So this helps.But my image has R and B planes swapped.
Can't seem to find the appropriate format .P.S: I am on a Windows machine.
Thanks,
Kshitij Mayekar -
-
wrote on 24 May 2018, 12:53 last edited by
@SGaist
QImage::rgbSwapped results in creating new QImage with is equivalent to deep copy. So It does not help. Is there any other way to dislaying the RGB planes correctly ?Note: Whenever I write the contents of the buffer to a file with appropriate headers I could see the Image correctly when I open the Image through windows photo viewer.
Original Problem Statement : Display Byte Buffer(uchar*) to a QWidget without the need to deep Copy .
-
Where are these frames coming from ?
-
wrote on 25 May 2018, 15:35 last edited by
These frames are received from a server.
//Api that talks to server fetchBitmap(&vector[0]);
I do not have access to server code.
P.S: Server Machine is Linux and Client is Windows . Could this be the reason for RGB /BGR mismatch ?
-
wrote on 25 May 2018, 16:27 last edited by
Is there any chance of the paint event being triggered by the system at a moment when the pixmap isn't fully populated? If that is possible, you would get flickering regardless of whether the load function is faster or slower than real time.
-
These frames are received from a server.
//Api that talks to server fetchBitmap(&vector[0]);
I do not have access to server code.
P.S: Server Machine is Linux and Client is Windows . Could this be the reason for RGB /BGR mismatch ?
@SilverSurfer said in QWidget Flickering for frame by frame streaming of video:
Could this be the reason for RGB /BGR mismatch ?
Well there is always Endianness but if using same sort of CPU in both ends, its likely not related to that.
-
@SilverSurfer said in QWidget Flickering for frame by frame streaming of video:
Could this be the reason for RGB /BGR mismatch ?
Well there is always Endianness but if using same sort of CPU in both ends, its likely not related to that.
wrote on 28 May 2018, 07:46 last edited by@mrjj
Both machines are little endian. -
@mrjj
Both machines are little endian.@SilverSurfer
Ok. so most likely they
are just using openCV and send as BGR888So i dont see any way to convert to supported format without copy.
-
@SilverSurfer
Ok. so most likely they
are just using openCV and send as BGR888So i dont see any way to convert to supported format without copy.
wrote on 29 May 2018, 01:31 last edited by@mrjj If you use a shader in a QOpenGLWidget, you can swizzle the r/g/b around arbitrarily when you do the drawing into the frame buffer, which would avoid an extra copy step to normalize the channel order.
-
@mrjj If you use a shader in a QOpenGLWidget, you can swizzle the r/g/b around arbitrarily when you do the drawing into the frame buffer, which would avoid an extra copy step to normalize the channel order.
wrote on 29 May 2018, 10:09 last edited by SilverSurfer@wrosecrans said in QWidget Flickering for frame by frame streaming of video:
you can swizzle the r/g/b around arbitrarily when you do the drawing into the frame buffer
Could you provide sample code for the same ?
-
@wrosecrans said in QWidget Flickering for frame by frame streaming of video:
you can swizzle the r/g/b around arbitrarily when you do the drawing into the frame buffer
Could you provide sample code for the same ?
wrote on 29 May 2018, 18:03 last edited by@SilverSurfer I don't have the time handy to do a full working example, but this is the technique in glsl:
https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Swizzling(The vec4 can hold "rgba" values if that's what you put in it - the example there just calls it "xyzw" because the data type generically handles any 4 floats.)
Basically, start from an example that draws an image with a simple glsl shader as a texture. Then hack on the shader until it flips around the colors like you want when it draws the texture. Then use your code that gets the image over the network to upload the image as the OpenGL texture every frame.