How to get video preview from QProcess to fill a rectangle in qml
-
Hi!
I have a c++ class, where I am initiating QProcess in detached mode. This process launches a python script to get raspberry pi camera preview.
How can I get that preview and show it in a rectangle element?
The c++ function is a void type. Should it be some other type? You can make a QString function to return a QString, but there is no QProcess type.
I would appreciate any help. Thanks -
@Kachoraza you should provide more details about your runtime environment, i.e.
is the python script running on the RPi device, or is just connecting remotely? -
@Kachoraza and what about the Qt application using QProcess?
-
@Kachoraza so what about driving the Pi camera directly from your QML app? just for instance this guide
-
I tried to access the camera through Camera element and VideoOutput element. Camera status is 2, which I cannot understand.
Camera {
id: mycameraComponent.onCompleted: { console.log(cameraStatus); mycamera.start() console.log(cameraStatus); } }
I tried it on pi and on ubuntu as well
-
@Pablo-J-Rogina I am trying to get camera preview with the following code, but all I have is a white window. Can you please see what am I doing wrong here. I have tried it on pi and ubuntu with no errors, but similar result. Thanks in advance
import QtQuick 2.9
import QtQuick.Window 2.3
import QtMultimedia 5.9
import QtQuick.Controls 2.2Window {
id: window
width: 640
height: 480
property alias window: window
property alias videooutput: videooutput
visible: true
property Camera camera: Camera {
id: camera
captureMode: Camera.CaptureViewfinder
cameraState: Camera.ActiveState
Component.onCompleted: {
camera.start()
if(cameraState === Camera.ActiveState){
console.log("Camera ready")
}
}
}
VideoOutput {
id: videooutput
anchors.fill: parent
source: camera
focus: visible
enabled: true
Component.onCompleted: {
console.log(camera.cameraState)
}
}
}