QML Camera does not work on android!
-
Hello everyone,
I am testing a qr decoder using android
the custom qml type-file isimport QtQuick 2.0 import QtMultimedia import QtQrDec import MyDesigns Item { id:root signal gotdata(string data); function stop() { timer.stop(); camera.stop(); startcamera.visible=true; } VideoOutput { id: videoOutput anchors.fill: root } MediaDevices { id: devices } Camera { id: camera active: false cameraDevice: devices.defaultVideoInput onErrorOccurred: (error,errorString)=> { console.log( devices.videoInputs); console.log(errorString) console.log(error) } } Connections { target: QRImageDecoder function onText_changed(boo) { root.gotdata(QRImageDecoder.text) } } Connections { target: QRImageDecoder function onPermissionRequested(boo) { if(boo) { console.log( devices.videoInputs); console.log(camera.cameraFormat) devices.videoInputs.forEach((Cdev) => { if(Cdev.position===Cdev.BackFace) { camera.cameraDevice=Cdev; } }); camera.start(); timer.start(); startcamera.visible=false; } } } CaptureSession { id: capturesession camera: camera videoOutput: videoOutput imageCapture: ImageCapture { id: imageCapture onErrorOccurred:(requestId, error, message)=> { console.log("capture error:",message) } onImageCaptured: { console.log("onImageCaptured"); QRImageDecoder.source = imageCapture.preview } } } Timer { id: timer interval: 500; running: false; repeat: true onTriggered: { console.log("camera:",camera.cameraFormat.pixelFormat) if( imageCapture.readyForCapture ) { imageCapture.capture(); } } } MyButton { id:startcamera anchors.centerIn: root text:qsTr("ScanQr") onClicked: { QRImageDecoder.requestPermision(); } width:100 height:width*0.5 } }
The thing is that when pressing the 'ScanQr' button, the app ask for permission to use the camera. If the permission is granted The video is shown on the app but the video is lagging.
And theimageCapture.readyForCapture
is always false.On the debugger, I get:
W Gralloc4: allocator 3.x is not supported W Gralloc3: allocator 3.x is not supported W ample.nftminte: [SurfaceTexture-4-9500-0] bindTextureImage: clearing GL error: 0x500 W ample.nftminte: [SurfaceTexture-4-9500-0] bindTextureImage: clearing GL error: 0x500
Any help will be much appreciated.
Thank you for your time. -
Hello everyone,
I am testing a qr decoder using android
the custom qml type-file isimport QtQuick 2.0 import QtMultimedia import QtQrDec import MyDesigns Item { id:root signal gotdata(string data); function stop() { timer.stop(); camera.stop(); startcamera.visible=true; } VideoOutput { id: videoOutput anchors.fill: root } MediaDevices { id: devices } Camera { id: camera active: false cameraDevice: devices.defaultVideoInput onErrorOccurred: (error,errorString)=> { console.log( devices.videoInputs); console.log(errorString) console.log(error) } } Connections { target: QRImageDecoder function onText_changed(boo) { root.gotdata(QRImageDecoder.text) } } Connections { target: QRImageDecoder function onPermissionRequested(boo) { if(boo) { console.log( devices.videoInputs); console.log(camera.cameraFormat) devices.videoInputs.forEach((Cdev) => { if(Cdev.position===Cdev.BackFace) { camera.cameraDevice=Cdev; } }); camera.start(); timer.start(); startcamera.visible=false; } } } CaptureSession { id: capturesession camera: camera videoOutput: videoOutput imageCapture: ImageCapture { id: imageCapture onErrorOccurred:(requestId, error, message)=> { console.log("capture error:",message) } onImageCaptured: { console.log("onImageCaptured"); QRImageDecoder.source = imageCapture.preview } } } Timer { id: timer interval: 500; running: false; repeat: true onTriggered: { console.log("camera:",camera.cameraFormat.pixelFormat) if( imageCapture.readyForCapture ) { imageCapture.capture(); } } } MyButton { id:startcamera anchors.centerIn: root text:qsTr("ScanQr") onClicked: { QRImageDecoder.requestPermision(); } width:100 height:width*0.5 } }
The thing is that when pressing the 'ScanQr' button, the app ask for permission to use the camera. If the permission is granted The video is shown on the app but the video is lagging.
And theimageCapture.readyForCapture
is always false.On the debugger, I get:
W Gralloc4: allocator 3.x is not supported W Gralloc3: allocator 3.x is not supported W ample.nftminte: [SurfaceTexture-4-9500-0] bindTextureImage: clearing GL error: 0x500 W ample.nftminte: [SurfaceTexture-4-9500-0] bindTextureImage: clearing GL error: 0x500
Any help will be much appreciated.
Thank you for your time.I have tried the declarative camera example on Android and it works ok. It also returns the same warnings
W Gralloc4: allocator 3.x is not supported W Gralloc3: allocator 3.x is not supported W ample.nftminte: [SurfaceTexture-4-9500-0] bindTextureImage: clearing GL error: 0x500 W ample.nftminte: [SurfaceTexture-4-9500-0] bindTextureImage: clearing GL error: 0x500
The video is lagging on my app because calling
imageCapture.capture()
freezes the VideoOutput. This freeze does not happen on the Desktop.
Do you think it freezes because of memory issues or is it a feature? -
Hello everyone,
I am testing a qr decoder using android
the custom qml type-file isimport QtQuick 2.0 import QtMultimedia import QtQrDec import MyDesigns Item { id:root signal gotdata(string data); function stop() { timer.stop(); camera.stop(); startcamera.visible=true; } VideoOutput { id: videoOutput anchors.fill: root } MediaDevices { id: devices } Camera { id: camera active: false cameraDevice: devices.defaultVideoInput onErrorOccurred: (error,errorString)=> { console.log( devices.videoInputs); console.log(errorString) console.log(error) } } Connections { target: QRImageDecoder function onText_changed(boo) { root.gotdata(QRImageDecoder.text) } } Connections { target: QRImageDecoder function onPermissionRequested(boo) { if(boo) { console.log( devices.videoInputs); console.log(camera.cameraFormat) devices.videoInputs.forEach((Cdev) => { if(Cdev.position===Cdev.BackFace) { camera.cameraDevice=Cdev; } }); camera.start(); timer.start(); startcamera.visible=false; } } } CaptureSession { id: capturesession camera: camera videoOutput: videoOutput imageCapture: ImageCapture { id: imageCapture onErrorOccurred:(requestId, error, message)=> { console.log("capture error:",message) } onImageCaptured: { console.log("onImageCaptured"); QRImageDecoder.source = imageCapture.preview } } } Timer { id: timer interval: 500; running: false; repeat: true onTriggered: { console.log("camera:",camera.cameraFormat.pixelFormat) if( imageCapture.readyForCapture ) { imageCapture.capture(); } } } MyButton { id:startcamera anchors.centerIn: root text:qsTr("ScanQr") onClicked: { QRImageDecoder.requestPermision(); } width:100 height:width*0.5 } }
The thing is that when pressing the 'ScanQr' button, the app ask for permission to use the camera. If the permission is granted The video is shown on the app but the video is lagging.
And theimageCapture.readyForCapture
is always false.On the debugger, I get:
W Gralloc4: allocator 3.x is not supported W Gralloc3: allocator 3.x is not supported W ample.nftminte: [SurfaceTexture-4-9500-0] bindTextureImage: clearing GL error: 0x500 W ample.nftminte: [SurfaceTexture-4-9500-0] bindTextureImage: clearing GL error: 0x500
Any help will be much appreciated.
Thank you for your time.@Mesrine said in QML Camera does not work on android!:
lagging
don't know if this is the reason of your problems, but your QML Camera classes structure isn't valid from my POV: Camera should be inside CaptureSession
see here my blog about Port QML Camera 5.15 to 6.6
-
@Mesrine said in QML Camera does not work on android!:
lagging
don't know if this is the reason of your problems, but your QML Camera classes structure isn't valid from my POV: Camera should be inside CaptureSession
see here my blog about Port QML Camera 5.15 to 6.6
@ekkescorner
Thanks, I am no longer usingimageCapture.capture()
. I do not understand the difference between declaring the camera outside the CaptureSession and inside the CaptureSession. There is no warning or a mandatory statement about this in the documentation, or there is? -
@ekkescorner
Thanks, I am no longer usingimageCapture.capture()
. I do not understand the difference between declaring the camera outside the CaptureSession and inside the CaptureSession. There is no warning or a mandatory statement about this in the documentation, or there is?@Mesrine you're right. have overlooked that inside CaptureSession you set camera: camera