Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Change QML Camera viewfinder and capture pixel format
QtWS25 Last Chance

Change QML Camera viewfinder and capture pixel format

Scheduled Pinned Locked Moved Solved QML and Qt Quick
19 Posts 2 Posters 1.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NoodlesDev
    wrote on 29 Mar 2020, 11:18 last edited by
    #1

    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.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 29 Mar 2020, 12:15 last edited by
      #2

      Hi,

      You can try QCameraViewFinderSettings::setPixelFormat in C++.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      N 1 Reply Last reply 29 Mar 2020, 14:22
      1
      • S SGaist
        29 Mar 2020, 12:15

        Hi,

        You can try QCameraViewFinderSettings::setPixelFormat in C++.

        Hope it helps

        N Offline
        N Offline
        NoodlesDev
        wrote on 29 Mar 2020, 14:22 last edited by
        #3

        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?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 29 Mar 2020, 15:53 last edited by
          #4

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          N 1 Reply Last reply 29 Mar 2020, 15:57
          1
          • S SGaist
            29 Mar 2020, 15:53

            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.

            N Offline
            N Offline
            NoodlesDev
            wrote on 29 Mar 2020, 15:57 last edited by
            #5

            @SGaist Could you please point me to the relevant classes you are thinking about?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 29 Mar 2020, 17:28 last edited by
              #6

              I was thinking about checking that directly on the command line.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              N 1 Reply Last reply 29 Mar 2020, 17:58
              0
              • S SGaist
                29 Mar 2020, 17:28

                I was thinking about checking that directly on the command line.

                N Offline
                N Offline
                NoodlesDev
                wrote on 29 Mar 2020, 17:58 last edited by
                #7

                @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.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 29 Mar 2020, 19:26 last edited by
                  #8

                  You may have to resort to low-level handling for the stream type switching.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  N 1 Reply Last reply 29 Mar 2020, 19:30
                  0
                  • S SGaist
                    29 Mar 2020, 19:26

                    You may have to resort to low-level handling for the stream type switching.

                    N Offline
                    N Offline
                    NoodlesDev
                    wrote on 29 Mar 2020, 19:30 last edited by
                    #9

                    @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.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 29 Mar 2020, 19:41 last edited by
                      #10

                      I just had a doubt, what if you use the xvimagesink ?
                      Are you seeing the live image of your camera ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      N 1 Reply Last reply 29 Mar 2020, 21:02
                      0
                      • S SGaist
                        29 Mar 2020, 19:41

                        I just had a doubt, what if you use the xvimagesink ?
                        Are you seeing the live image of your camera ?

                        N Offline
                        N Offline
                        NoodlesDev
                        wrote on 29 Mar 2020, 21:02 last edited by
                        #11

                        @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
                        
                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 29 Mar 2020, 21:05 last edited by
                          #12

                          Can you open the camera with VLC ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          N 1 Reply Last reply 30 Mar 2020, 10:34
                          1
                          • S SGaist
                            29 Mar 2020, 21:05

                            Can you open the camera with VLC ?

                            N Offline
                            N Offline
                            NoodlesDev
                            wrote on 30 Mar 2020, 10:34 last edited by
                            #13

                            @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?

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on 30 Mar 2020, 20:02 last edited by
                              #14

                              I meant just testing with the VLC application.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              N 1 Reply Last reply 30 Mar 2020, 20:45
                              0
                              • S SGaist
                                30 Mar 2020, 20:02

                                I meant just testing with the VLC application.

                                N Offline
                                N Offline
                                NoodlesDev
                                wrote on 30 Mar 2020, 20:45 last edited by
                                #15

                                @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.

                                1 Reply Last reply
                                0
                                • S Offline
                                  S Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on 30 Mar 2020, 21:03 last edited by
                                  #16

                                  Then I fear you are going to have to go lower level to set the stream type...

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  N 1 Reply Last reply 30 Mar 2020, 21:11
                                  0
                                  • S SGaist
                                    30 Mar 2020, 21:03

                                    Then I fear you are going to have to go lower level to set the stream type...

                                    N Offline
                                    N Offline
                                    NoodlesDev
                                    wrote on 30 Mar 2020, 21:11 last edited by
                                    #17

                                    @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.

                                    1 Reply Last reply
                                    0
                                    • S Offline
                                      S Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on 30 Mar 2020, 21:26 last edited by
                                      #18

                                      Did you check with the GStreamer folks whether there was something possible with directly from their v4l2 plugin ?

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      N 1 Reply Last reply 30 Mar 2020, 21:28
                                      0
                                      • S SGaist
                                        30 Mar 2020, 21:26

                                        Did you check with the GStreamer folks whether there was something possible with directly from their v4l2 plugin ?

                                        N Offline
                                        N Offline
                                        NoodlesDev
                                        wrote on 30 Mar 2020, 21:28 last edited by
                                        #19

                                        @SGaist Well, no, but I might as well try at this point.

                                        1 Reply Last reply
                                        0

                                        1/19

                                        29 Mar 2020, 11:18

                                        • Login

                                        • Login or register to search.
                                        1 out of 19
                                        • First post
                                          1/19
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • Users
                                        • Groups
                                        • Search
                                        • Get Qt Extensions
                                        • Unsolved