Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt 6.4.2 Android Qml loader issue #229

Open
julienchevet opened this issue Feb 6, 2023 · 0 comments
Open

Qt 6.4.2 Android Qml loader issue #229

julienchevet opened this issue Feb 6, 2023 · 0 comments

Comments

@julienchevet
Copy link

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);
                }
            }
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant