Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QCamera + QCameraViewfinder: how to mirror the the image displayed in the viewfinder?
Forum Updated to NodeBB v4.3 + New Features

QCamera + QCameraViewfinder: how to mirror the the image displayed in the viewfinder?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qcamera
43 Posts 8 Posters 26.3k Views 4 Watching
  • 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.
  • V Offline
    V Offline
    Violet Giraffe
    wrote on last edited by
    #11

    Sorry, but I can't find anything related to video surface format in the QCameraViewFinder class. What's videoSurfaceProperty in your answer?
    I can get QCameraViewFinderSettings from QCamera, but that doesn't appear to be what you're referring to. I've looked at the QCameraViewFinderSettings source file and there's no mention of the "mirrored" property.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #12

      No, it's the QVideoRendererControl that you must first retrieve first.

      The mirrored property I stumbled upon while checking something unrelated in QtMultimedia's sources.

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

      Andy314A V 2 Replies Last reply
      1
      • SGaistS SGaist

        No, it's the QVideoRendererControl that you must first retrieve first.

        The mirrored property I stumbled upon while checking something unrelated in QtMultimedia's sources.

        Andy314A Offline
        Andy314A Offline
        Andy314
        wrote on last edited by
        #13

        Hello @SGaist ,

        how can I get the QVideoRenderControl?
        From the QViewFinder, which function, I find no.

        1 Reply Last reply
        0
        • SGaistS SGaist

          No, it's the QVideoRendererControl that you must first retrieve first.

          The mirrored property I stumbled upon while checking something unrelated in QtMultimedia's sources.

          V Offline
          V Offline
          Violet Giraffe
          wrote on last edited by
          #14

          @SGaist, thanks. I, too, can't find a way to get it from QViewFinder (which is a QVideoWidget). Looks like I need QMediaService to get QVideoRenderControl from it.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by SGaist
            #15
            QMediaService *mediaService = viewFinder->mediaObject()->service();
            QVideoRendererControl *rendererControl = mediaService->requestControl<QVideoRendererControl *>();
            rendererControl->setSurface(myVideoSurface);
            

            Don't forget to add the necessary checks.

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

            V 1 Reply Last reply
            0
            • SGaistS SGaist
              QMediaService *mediaService = viewFinder->mediaObject()->service();
              QVideoRendererControl *rendererControl = mediaService->requestControl<QVideoRendererControl *>();
              rendererControl->setSurface(myVideoSurface);
              

              Don't forget to add the necessary checks.

              V Offline
              V Offline
              Violet Giraffe
              wrote on last edited by
              #16

              @SGaist
              No such luck :( viewFinder->mediaObject() is nullptr.
              IS there a restriction on when I should call mediaObject() relative to, say, show() or any other lifecycle-related method of the view finder?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #17

                Did you set the viewFinder on the camera before calling mediaObject ?

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

                V 1 Reply Last reply
                0
                • SGaistS SGaist

                  Did you set the viewFinder on the camera before calling mediaObject ?

                  V Offline
                  V Offline
                  Violet Giraffe
                  wrote on last edited by
                  #18

                  @SGaist
                  Nope, i was doing it just before that. So, now I put this code right after setViewfinder, and mediaService is not null, but mediaService->requestControl<QVideoRendererControl *>() returns nullptr.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #19

                    What OS are you running ? It might be that the backend doesn't provide that control.

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

                    1 Reply Last reply
                    0
                    • V Offline
                      V Offline
                      Violet Giraffe
                      wrote on last edited by
                      #20

                      Windows 10.

                      1 Reply Last reply
                      0
                      • V Violet Giraffe

                        I need the live view image from the camera being displayed in the QCameraViewfinder to be mirrored (flipped horizontally). What are my options for doing this?

                        N Offline
                        N Offline
                        nicesw123
                        wrote on last edited by nicesw123
                        #21

                        how to mirror the the image displayed in the viewfinder?

                        +1

                        Actually
                        +1000

                        This is a very good question!
                        I also want to mirror the image (flip it left to right)!

                        PS:
                        I'm using Debian Testing, which requires these packages, to get QCamera working: qt5-default, libqt5multimedia5, libqt5multimedia5-plugins, libqt5multimediaquick-p5, libqt5multimediawidgets5, qml-module-qtmultimedia, qtmultimedia5-dbg, qtmultimedia5-dev

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #22

                          Just a quick update:

                              QVideoRendererControl *rendererControl = camera.service()->requestControl<QVideoRendererControl *>();
                              if (rendererControl) {
                                  QAbstractVideoSurface *surface = rendererControl->surface();
                                  QVideoSurfaceFormat format = surface->surfaceFormat();
                                  format.setProperty("mirrored", true);
                          
                                  surface->stop();
                                  surface->start(format);
                              } else {
                                  qDebug() << "Backend doesn't provide a video renderer control";
                              }
                          

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

                          1 Reply Last reply
                          1
                          • V Offline
                            V Offline
                            Violet Giraffe
                            wrote on last edited by
                            #23

                            Thanks, but still no. rendererControl is null, and I tried executing your snippet both before and after camera.start() call.

                            N 1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #24

                              Can you check what plugin is loaded ? It should be either the WMF or DirectX plugin. IIRC the DX plugin has the control.

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

                              1 Reply Last reply
                              0
                              • V Offline
                                V Offline
                                Violet Giraffe
                                wrote on last edited by Violet Giraffe
                                #25

                                I can't see either. Here's the complete list of all the .dlls loaded.
                                I can, however, see an odd warning. I don't have a slightest idea if it's related, but probably not:

                                D3D11CreateDevice: Flags (0x2) were specified which require the D3D11 SDK Layers for Windows 10, but they are not present on the system.
                                These flags must be removed, or the Windows 10 SDK must be installed.
                                Flags include: D3D11_CREATE_DEVICE_DEBUG

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #26

                                  Sorry, I meant start your application with QT_DEBUG_PLUGINS set to 1.

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

                                  1 Reply Last reply
                                  0
                                  • V Offline
                                    V Offline
                                    Violet Giraffe
                                    wrote on last edited by
                                    #27

                                    Is it an environment variable or a project define?

                                    1 Reply Last reply
                                    0
                                    • SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #28

                                      Environment variable that you can set in the Run part of the Project panel.

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

                                      1 Reply Last reply
                                      0
                                      • V Offline
                                        V Offline
                                        Violet Giraffe
                                        wrote on last edited by
                                        #29

                                        Here's the list. Can't see anything named WMF, but I guess I need to know the exact name to look for.

                                        1 Reply Last reply
                                        0
                                        • V Violet Giraffe

                                          Thanks, but still no. rendererControl is null, and I tried executing your snippet both before and after camera.start() call.

                                          N Offline
                                          N Offline
                                          nicesw123
                                          wrote on last edited by
                                          #30

                                          @Violet-Giraffe said:

                                          Thanks, but still no. rendererControl is null

                                          Same for Debian (and it's variants [Ubuntu, etc.])

                                          1 Reply Last reply
                                          0

                                          • Login

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