Qt 6.2, QML Camera, change resolution on image capture
-
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 :-)
-
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!
-
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(); }