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. Image orientation with qml Camera
Qt 6.11 is out! See what's new in the release blog

Image orientation with qml Camera

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qml cameraios
6 Posts 4 Posters 2.4k Views 1 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
    vudangkhoa2906
    wrote on last edited by
    #1

    I'm using Qml Camera to capture an image and send it to the server. The code look something like this

    Camera {
    id: camera

        imageCapture {
            onImageSaved: {
                // upload the image. context is the c++ class handling the logic
                context.uploadImage(path)
            }
        }
    }
    

    the context class use the path to read the content of the file
    QFile file(path);
    QByteArray fileContent(file.readAll());

    and the fileContent is attached to a http request and sent to the server.

    the problem is, with iOS, when the screen is locked to portrait mode, and i take a photo, the image specified in path did NOT auto rotate. (for example, when i take a photo in horizontal direction, the image should auto rotate 90)

    is there anyway to make the image auto rotate before it is sent to the server?

    1 Reply Last reply
    0
    • GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #2

      Does it also happen when loading the image with QImageReader?

      V 1 Reply Last reply
      1
      • GrecKoG GrecKo

        Does it also happen when loading the image with QImageReader?

        V Offline
        V Offline
        vudangkhoa2906
        wrote on last edited by
        #3

        Hi @GrecKo,
        Even though I have not tried your solution, but as you suggested, i create an image from the path, and it works fine now.
        Thank you very much

        Pablo J. RoginaP 1 Reply Last reply
        0
        • V vudangkhoa2906

          Hi @GrecKo,
          Even though I have not tried your solution, but as you suggested, i create an image from the path, and it works fine now.
          Thank you very much

          Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @vudangkhoa2906 said in Image orientation with qml Camera:

          it works fine now

          Is your issue solved? If so please don't forget to mark your post as such.

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          V 1 Reply Last reply
          0
          • Pablo J. RoginaP Pablo J. Rogina

            @vudangkhoa2906 said in Image orientation with qml Camera:

            it works fine now

            Is your issue solved? If so please don't forget to mark your post as such.

            V Offline
            V Offline
            vudangkhoa2906
            wrote on last edited by
            #5

            @Pablo-J-Rogina @GrecKo
            I'm really sorry, after a more thorough test, turns out it did not work as i expected. However, I have found a way to rotate the image with code, the only problem is to detect the screen orientation.
            Do you guys have any idea how to use it?
            As specified in here (https://doc.qt.io/qt-5/qml-qtquick-window-screen.html#orientationUpdateMask-attached-prop), in the main.qml file, I have add this line

            ApplicationWindow {
                    ...
                    Screen.orientationUpdateMask: Qt.PortraitOrientation | Qt.LandscapeOrientation | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation
                    ...
            }
            

            however, the Screen.onOrientationChanged signal is not emitted?
            fyi: my iPhone is currently in locked portrait mode. but if i disable screen lock, the signal is emitted.

            J.HilkJ 1 Reply Last reply
            0
            • V vudangkhoa2906

              @Pablo-J-Rogina @GrecKo
              I'm really sorry, after a more thorough test, turns out it did not work as i expected. However, I have found a way to rotate the image with code, the only problem is to detect the screen orientation.
              Do you guys have any idea how to use it?
              As specified in here (https://doc.qt.io/qt-5/qml-qtquick-window-screen.html#orientationUpdateMask-attached-prop), in the main.qml file, I have add this line

              ApplicationWindow {
                      ...
                      Screen.orientationUpdateMask: Qt.PortraitOrientation | Qt.LandscapeOrientation | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation
                      ...
              }
              

              however, the Screen.onOrientationChanged signal is not emitted?
              fyi: my iPhone is currently in locked portrait mode. but if i disable screen lock, the signal is emitted.

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @vudangkhoa2906 said in Image orientation with qml Camera:

              Screen.orientationUpdateMask

              I never specified an orientation update mask, and this

              readonly property bool isPortrait: (Screen.primaryOrientation === Qt.PortraitOrientation ||
                                                      Screen.primaryOrientation === Qt.InvertedPortraitOrientation)
              

              works fine for me, maybe you don't need it ? 🤷‍♂️


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              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