Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Qt 6.2, QML Camera, change resolution on image capture
Forum Updated to NodeBB v4.3 + New Features

Qt 6.2, QML Camera, change resolution on image capture

Scheduled Pinned Locked Moved Unsolved Qt 6
3 Posts 2 Posters 1.5k 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.
  • R Offline
    R Offline
    russkij
    wrote on last edited by
    #1

    Hi,

    I can't change the resolution of the camera.
    In Qt 5 I do it like this: camera.imageCapture.resolution = "640x480" and it works.
    In Qt 6 I found camera.cameraFormat.resolution but changing the resolution doesn't work for me.

    Qt declarative-camera example, declarative-camera.qml:

    State {
       name: "PhotoCapture"
       StateChangeScript {
           script: {
               camera.captureMode = Camera.CaptureStillImage
               
               // works in Qt 5
               camera.imageCapture.resolution = "640x480"
               
               // doesn't work in Qt 6:
               camera.cameraFormat.resolution = Qt.size(320, 240)
               camera.cameraFormat.resolution = "320x240"
                          
               camera.start()
           }
       }
    },
    

    please support :-)

    S 1 Reply Last reply
    0
    • R russkij

      Hi,

      I can't change the resolution of the camera.
      In Qt 5 I do it like this: camera.imageCapture.resolution = "640x480" and it works.
      In Qt 6 I found camera.cameraFormat.resolution but changing the resolution doesn't work for me.

      Qt declarative-camera example, declarative-camera.qml:

      State {
         name: "PhotoCapture"
         StateChangeScript {
             script: {
                 camera.captureMode = Camera.CaptureStillImage
                 
                 // works in Qt 5
                 camera.imageCapture.resolution = "640x480"
                 
                 // doesn't work in Qt 6:
                 camera.cameraFormat.resolution = Qt.size(320, 240)
                 camera.cameraFormat.resolution = "320x240"
                            
                 camera.start()
             }
         }
      },
      

      please support :-)

      S Offline
      S Offline
      svar
      wrote on last edited by
      #2

      Hi @russkij,

      Found what QT6 camera still very buggy...

      I got the impression that no one uses this camera all over the globe (except me). I tried to do something and stumbled upon the inability to implement anything. Yes, you will have an application that shows frames from the camera. But this is ridiculous, the android already has a built-in camera :) At the same time, it will not work to process frames. The camera is catastrophically slow. I have posted bug reports - https://bugreports.qt.io/browse/QTBUG-99969 (Please vote it), https://bugreports.qt.io/browse/QTBUG-99650(fixed now in future releases :) ). If you try to extract frames, app turns into a slideshow. They didn't even test it to work with very popular virtual cameras like snap camera(Windows),XSplit vcam(Windows) etc. they just crash your app, qcamera can't handle their format!

      1 Reply Last reply
      0
      • R Offline
        R Offline
        russkij
        wrote on last edited by
        #3

        I have the following solution:

        QML:

        CaptureSession {
                id: captureSession
                videoOutput: videoOutput
        
                Component.onCompleted: {
                    camera.cameraFormat = classPhoto.getCameraFormat();
                    camera.start()
                }
        ...
        

        C++

        Q_INVOKABLE QCameraFormat getCameraFormat() const
        {
            auto formats = QMediaDevices::defaultVideoInput().videoFormats();
            for (const auto &format : formats)
            {
                if (format.resolution() == ***)
                {
                    return format;
                 }
             }
            return QCameraFormat();
        }
        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