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 Violet Giraffe
    #1

    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 HymerB534H 2 Replies Last reply
    1
    • V Offline
      V Offline
      Violet Giraffe
      wrote on last edited by
      #2

      Please don't tell me it's not possible...

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

        Hi,

        I don't remember that option but that doesn't mean it doesn't exists. What is your use case ?

        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 Violet Giraffe
          #4

          I have a car PC, and I've written a program to display the image from the rear view camera (connected through a USB video capture card). But the image from the camera has to be mirrored, hence my question.

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

            Ok good.

            Did you consider QML ?

            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
            • V Offline
              V Offline
              Violet Giraffe
              wrote on last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • SGaistS SGaist

                Ok good.

                Did you consider QML ?

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

                @SGaist, no, I never used QML and don't intend to ever use it. How would that help?

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

                  You can do some post-processing more easily with QML.

                  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
                    #9

                    Okay then, would it be possible to write my own viewfinder widget that mirrors the image without actually implementing the whole viewfinder by hand myself?

                    I suppose it's hypothetically possible to make the viewfinder invisible, grab()it on timer (or render it to QPixmap, or whatever), manipulate the image and then draw that image in another, visible widget. But I have serious doubts about performance of this solution. It must work on an Intel Atom PC, and should produce minimal CPU load, too.

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

                      One thing you can try:

                      1. Get the video surface format of your QCameraViewFinder
                      2. Call videoSurfaceProperty.setProperty("mirrored", true)
                      3. Then set it on again.

                      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
                        #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

                                          • Login

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