Change QML Camera viewfinder and capture pixel format
-
wrote on 29 Mar 2020, 11:18 last edited by
Hi everyone,
I'm working on a simple application, written with PySide2 and QML, that controls a UVC webcam. Its purpose its simply show a preview of what the camera sees and allow the user to take a picture on the press of a button.
The webcam I'm using supports two different image formats: YUYV and MJPEG. The two different formats, based on the chosen resolution, allow different framerates. When using 1920x1080, YUYV supports only 5fps, while MPJEG supports 30fps.
My problem is that the QML Camera defaults to YUYV, and I have been trying for the last few days to change it to MJPEG, without any success.
I'm sure that the problem is the image format as I've conducted lots of test by changing the Camera.viewfinder resolution property, and the obtained framerates always matched the supported ones for different resolutions on YUYV.
Does anyone have any idea on how to fix this?
I do not expect a QML solution, as it is quite clear that the QML Camera APIs do not support this. However, I would expect the underlying Qt code to support this, even though I haven't been able to find the proper way to do it.
-
-
wrote on 29 Mar 2020, 14:22 last edited by
Hi @SGaist, thanks for your reply.
I've tried, but something's wrong. I am 100% sure that my camera supports MJPEG, as I've already tested it with QV4L2.
However, when I query the QCamera instance capabilites by calling supportedViewFinderSettings(), only YUYV format settings are listed.What could be the cause?
-
Good question. I am currently not sure whether GStreamer is also used for camera handling but I would check if it's possible to set the stream type with it too.
-
Good question. I am currently not sure whether GStreamer is also used for camera handling but I would check if it's possible to set the stream type with it too.
wrote on 29 Mar 2020, 15:57 last edited by@SGaist Could you please point me to the relevant classes you are thinking about?
-
I was thinking about checking that directly on the command line.
-
wrote on 29 Mar 2020, 17:58 last edited by
@SGaist By checking with gst-inspect it seems like the v4l2src element supports image/jpeg and not video/mjpeg.
However, with this pipeline:gst-launch v4l2src device=/dev/video2 ! image/jpeg, framerate=30/1 ! filesink location=test.mjpeg
the generated file is too big to be a single jpeg image, thus I assume a MJPEG video is created.
Nonetheless, when I try and open it with VLC, only the first frame is shown... I'm quite confused. -
You may have to resort to low-level handling for the stream type switching.
-
wrote on 29 Mar 2020, 19:30 last edited by
@SGaist That's what I feared... Is there any Qt class you have in mind? I could handle this via V4L2 but I was hoping for a portable solution.
-
I just had a doubt, what if you use the xvimagesink ?
Are you seeing the live image of your camera ? -
I just had a doubt, what if you use the xvimagesink ?
Are you seeing the live image of your camera ?wrote on 29 Mar 2020, 21:02 last edited by@SGaist xvimagesink does not support image/jpeg, I just get:
WARNING: erroneous pipeline: could not link v4l2src0 to xvimagesink0, xvimagesink0 can't handle caps image/jpeg
-
Can you open the camera with VLC ?
-
wrote on 30 Mar 2020, 10:34 last edited by
@SGaist I've never used VLC on the command line, and I'm having trouble figuring out how to stream directly from my local camera. Could you please provide me with some indications on how to do?
-
I meant just testing with the VLC application.
-
wrote on 30 Mar 2020, 20:45 last edited by
@SGaist Yeah sorry, I've just noticed the "Open capture device" option in the GUI program... My bad.
Anyway, I get the same problem, VLC defaults to YUYV and I get extremely low FPS. As far as I could see there were no option to set the capture format at all. -
Then I fear you are going to have to go lower level to set the stream type...
-
wrote on 30 Mar 2020, 21:11 last edited by
@SGaist Yes, that's what I feared too.
Since there seems to be no suitable Qt-based solution at all, I'm closing the topic as solved. -
Did you check with the GStreamer folks whether there was something possible with directly from their v4l2 plugin ?
-
Did you check with the GStreamer folks whether there was something possible with directly from their v4l2 plugin ?
wrote on 30 Mar 2020, 21:28 last edited by@SGaist Well, no, but I might as well try at this point.
1/19