Change Camera pixel format from qml

981 Views Asked by At

Looking at the documentation of Qt5 it seems possible to change the pixel format of the camera. I need to create a QCameraViewfinderSettings set the new pixel format and set the new settings to the camera... like in this example

QCameraViewfinderSettings viewfinderSettings;
viewfinderSettings.setPixelFormat(QVideoFrame::Format_RGB32);
camera->setViewfinderSettings(viewfinderSettings);

But I cannot find anything similar in QML... Is there any way to do the something in QML? I'd like something like:

Camera {
    id: camera
    viewfinder.pixelFormat = VideoFrame.Format_RGB32
}

If QML doesn't allow me to set the pixel format what alternatives have I?

1

There are 1 best solutions below

0
On

No, you can't change the pixel format in QML per the maintainer of that component, but you can pass the QML object to C++ and do it from there per bug report 42909.

As Yoann Lopes wrote in that bug's comments, you can access the QCamera of the QML object with:

QCamera *cam = qvariant_cast<QCamera*>(obj->property("mediaObject"))