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.
  • 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
                                • N Offline
                                  N Offline
                                  nicesw123
                                  wrote on last edited by
                                  #31

                                  Maby the way to do this for now...
                                  (i.e. until the qt developers realize the value of extending QCameraImageProcessing or QCameraViewfinder to allow mirroring (flipping) the image)

                                  ...is to "derive from QAbstractVideoSurface" as shown here: http://doc.qt.io/qt-5/cameraoverview.html#viewfinder (find some example code there, showing rotation)

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

                                    DSEngine -> DirectShow. The plugin it self has the control but it seems it's not accessible yet.

                                    If you are wiling to re-build the plugin, that can be modified.

                                    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

                                      DSEngine -> DirectShow. The plugin it self has the control but it seems it's not accessible yet.

                                      If you are wiling to re-build the plugin, that can be modified.

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

                                      @SGaist, it depends on how difficult it is to build Qt 5 nowadays (I remember it being a pain because of WebKit that I didn't even need, hopefully that's fixed now). Let me check nicesw123's suggestion first.

                                      1 Reply Last reply
                                      0
                                      • D Offline
                                        D Offline
                                        Devopia53
                                        wrote on last edited by
                                        #34

                                        Qt/C++ already provides that functionality. You can easily implement flipping feature if you use the following classes.

                                        QGraphicsView, QGraphicsScene, QCamera, QVideoWidget, QTramsform

                                        V 1 Reply Last reply
                                        1
                                        • D Devopia53

                                          Qt/C++ already provides that functionality. You can easily implement flipping feature if you use the following classes.

                                          QGraphicsView, QGraphicsScene, QCamera, QVideoWidget, QTramsform

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

                                          @Devopia53, how can I connect those to QCamera if the only thing camera accepts is QCameraViewfinder?
                                          P. S. Nvm, it accepts QVideoWidget. Still not quite sure how to connect the parts you've listed. A little help, please? :)

                                          D 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