qzxing
qzxing copied to clipboard
Qt 6.4.2 Android Qml loader issue
Qt 6.4.2 QZXing 3.3 Android 11
I placed the Camera and the QZXingFilter in a Component, loaded by a Loader. If I pass it to the Loader directly in the sourceComponent property, the camera is loaded when the application starts and the QZXingFilter decodes the QRCodes, it works fine.
But if I load it after a button click, for example, I get a black screen and these errors:
I ViewRootImpl@4d42ac6[QtActivity]: ViewPostIme pointer 0 D InputMethodManager: HSIFW - flag : 0 I InputMethodManager: hideSoftInputFromWindow ignore mServedView == null or mServedView.getWindowToken() != windowToken, mServedView :DecorView@68adeb5[QtActivity] I ViewRootImpl@4d42ac6[QtActivity]: ViewPostIme pointer 1 D SensorManager: registerListener :: 11, lsm6dsm Accelerometer Non-wakeup, 200000, 0, android.view.OrientationEventListener$SensorEventListenerImpl@d52e84d W Gralloc4: allocator 3.x is not supported W Gralloc3: allocator 3.x is not supported W [SurfaceTexture-4-28300-0] bindTextureImage: clearing GL error: 0x500 D QZXingFilter error: Cant create image file to process. D QZXingFilter error: Cant create image file to process. D QZXingFilter error: Cant create image file to process. D QZXingFilter error: Cant create image file to process. D QZXingFilter error: Cant create image file to process. D QZXingFilter error: Cant create image file to process. D QZXingFilter error: Cant create image file to process. D QZXingFilter error: Cant create image file to process. D QZXingFilter error: Cant create image file to process.
Here is a simple code to reproduce:
import QtQuick.Window
import QtQuick.Controls
import QtMultimedia
import QZXing
Window {
id: window
width: 640
height: 480
visible: true
Button {
anchors.centerIn: parent
text: "Load"
onClicked: cameraLoader.sourceComponent = cameraComponent
}
Loader {
id: cameraLoader
anchors.fill: parent
// sourceComponent: cameraComponent
}
Component {
id: cameraComponent
Item {
Camera {
id:camera
active: true
focusMode: Camera.FocusModeAutoNear
}
CaptureSession {
camera: camera
videoOutput: videoOutput
}
VideoOutput
{
id: videoOutput
anchors.fill: parent
fillMode: VideoOutput.Stretch
property double captureRectStartFactorX: 0.25
property double captureRectStartFactorY: 0.25
property double captureRectFactorWidth: 0.5
property double captureRectFactorHeight: 0.5
Rectangle {
id: captureZone
color: "red"
opacity: 0.2
width: parent.width * parent.captureRectFactorWidth
height: parent.height * parent.captureRectFactorHeight
x: parent.width * parent.captureRectStartFactorX
y: parent.height * parent.captureRectStartFactorY
}
}
QZXingFilter
{
id: zxingFilter
videoSink: videoOutput.videoSink
captureRect: {
videoOutput.sourceRect;
return Qt.rect(videoOutput.sourceRect.width * videoOutput.captureRectStartFactorX,
videoOutput.sourceRect.height * videoOutput.captureRectStartFactorY,
videoOutput.sourceRect.width * videoOutput.captureRectFactorWidth,
videoOutput.sourceRect.height * videoOutput.captureRectFactorHeight)
}
decoder {
enabledDecoders: QZXing.DecoderFormat_EAN_13 | QZXing.DecoderFormat_CODE_39 | QZXing.DecoderFormat_QR_CODE
onTagFound: {
console.log(tag + " | " + decoder.foundedFormat() + " | " + decoder.charSet());
window.detectedTags++;
window.lastTag = tag;
}
tryHarder: false
}
property int framesDecoded: 0
property real timePerFrameDecode: 0
onDecodingFinished: function (succeeded, decodeTime)
{
timePerFrameDecode = (decodeTime + framesDecoded * timePerFrameDecode) / (framesDecoded + 1);
framesDecoded++;
if(succeeded)
console.log("frame finished: " + succeeded, decodeTime, timePerFrameDecode, framesDecoded);
}
}
}
}
}