QCamera capture 8bit gray scale and convert to rgb
I am just starting on Qt. I am trying to capture an image from a sensor that generates grey/raw byte image.
Would like to capture 2592x1944 grey image scale it to 640x360 and convert it to rgb and display it.
All this with as little CPU involvement as possible.
I have tried the following:
The only codec supported is jpeg and this in not useful to me.
Any ideas will be very helpful.
Hi and welcome to devnet,
How is that sensor seen by the system ?
What version of Qt are you using ?
What platform are you running on ?
The sensor is seen as /dev/video0.
I am using Qt for device creation v 5.8.
I am building on linux platform for IMX.6 Q SabreSD.
Just some thoughts:
- If you wish to minimise CPU usage, why do the capture at such high resolution? For supported resolutions, check QCameraImageCapture::supportedResolutions()
- There might not be no need to convert the image to RGB for display -- Qt should handle grayscale just well
- Scaling using any scaling functions may be more innefient than creating an empty target image and picking every Nth pixel for it from the source (JPEG buffer converted into QImage -- see QImage::loadFromData()) and calculating for the pixel either grayscale RGB value or indexed grayscale value from the source buffer
Thanks for your prompt reply.
I can't change the resolution at which the sensor is capturing. It is a special sensor and I can't configure for lower resolution.
I have a test app that does the scaling by doing just that copy/scale (copying only the needed pixels to destination image buffer). The problem is that this is very slow process. It takes 0.6 seconds per frame. This doesn't work for my application this is the reason I was wondering if the scale and image conversion could be done by gpu. I can copy the frame from the camera to a buffer in memory but then I need to somehow hand over the buffer to the gpu and do the scaling/conversion there.
So something like creating a texture from the image and then process it ?
Something like QOpenGLTexture ?
How can I use a that texture class. The camera app seems to handle everything under covers.
Before going further, what will you be using to display the image ? QtWidgets ? QtQuick ?
QtQuick 2.4 is imported by the qml. I must be using QtQuick. I am new to Qt.