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 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
                              • V Violet Giraffe

                                @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 Offline
                                D Offline
                                Devopia53
                                wrote on last edited by
                                #36

                                @Violet-Giraffe
                                QCameraViewfinder is not a solution for flipping. Instead, use the QAbstractVideoSurface. But it is poor display performance.

                                Samples on how to use the QGraphicsView are as follows: I wish you a note.

                                auto camera = new QCamera;
                                auto widget = new QVideoWidget;
                                QTransform matrix(-1,0,0,0,1,0,0,0,1); // m11=-1 : flipping horizontal

                                graphicsView->setScene(new QGraphicsScene);
                                graphicsView->show();

                                auto proxyWidget = graphicsView->scene()->addWidget(widget);

                                proxyWidget->setTransform(matrix);
                                camera->setViewfinder(widget);
                                camera->start();

                                V 1 Reply Last reply
                                1
                                • D Devopia53

                                  @Violet-Giraffe
                                  QCameraViewfinder is not a solution for flipping. Instead, use the QAbstractVideoSurface. But it is poor display performance.

                                  Samples on how to use the QGraphicsView are as follows: I wish you a note.

                                  auto camera = new QCamera;
                                  auto widget = new QVideoWidget;
                                  QTransform matrix(-1,0,0,0,1,0,0,0,1); // m11=-1 : flipping horizontal

                                  graphicsView->setScene(new QGraphicsScene);
                                  graphicsView->show();

                                  auto proxyWidget = graphicsView->scene()->addWidget(widget);

                                  proxyWidget->setTransform(matrix);
                                  camera->setViewfinder(widget);
                                  camera->start();

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

                                  @Devopia53, thanks, but I think you're missing something. proxyWidget is not used here. AndQTransform has no effect on the widget, although I do see the image just as I did with QCameraViewfinder.

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

                                    Any further ideas? I'm stuck here.

                                    kshegunovK 1 Reply Last reply
                                    0
                                    • V Violet Giraffe

                                      Any further ideas? I'm stuck here.

                                      kshegunovK Offline
                                      kshegunovK Offline
                                      kshegunov
                                      Moderators
                                      wrote on last edited by
                                      #39

                                      @Violet-Giraffe

                                      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

                                      Have you tried installing the DX11 SDK?

                                      Read and abide by the Qt Code of Conduct

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

                                        I have not. Frankly, I doubt this message is related to my task/problem.

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

                                          You don't have to rebuild all of Qt just to modify one module. But the solution I have in mind might not be an optimal use of the API.

                                          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

                                          • Login

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