Skip to content

My QML app don't decode the QR code #86

@implor

Description

@implor

Hi, here i am again previously i had asked for help but that was a lib issue that finally i can solve, so, here's the new problem:
My App runs correctly, it keeps running searching for QR code but it never found 1 the code stay in bucle here:

onDecodingFinished:
{
    timePerFrameDecode = (decodeTime + framesDecoded * timePerFrameDecode) / (framesDecoded + 1);
    framesDecoded++;
    console.log("frame finished: " + succeeded, decodeTime, timePerFrameDecode, framesDecoded);
}

i know that the camera works fine with the same QR i'm trying to decode, i've tested it with another program. So i wonder if u can help ASAP. NOTE: the camera is started and closed when open or close qr_image_scan rectangle. (Neither your example works fine with me, but using third-party software linux QtQr app works, any idea if the configuration is not correct, ask for my mail if needed to send the project to you)

Here the code:

import QtQuick 2.11
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
import QtQml.Models 2.3
import QtQuick.Controls.Material 2.4
import QtQuick.Window 2.3
import QtMultimedia 5.9
import QZXing 2.3
import QZXingFilter 2.3

ApplicationWindow {
    id: window
    visible: true
    width: 640
    height: 480

    Rectangle {
        id:qr_image_scan
        anchors.fill:parent
        visible: false
        color:"black"
        property bool isCameraAvailable: QtMultimedia.availableCameras.length > 0
        Image{
            id:imageToDecode
        }
        Camera{
            id:camerax
            position: Camera.BackFace
            captureMode: Camera.CaptureStillImage
            deviceId: QtMultimedia.availableCameras[0].deviceId
            opticalZoom: 0.0
            imageCapture {
                onImageCaptured: {
                    imageToDecode.source = preview
                    decoder.decodeImageQML(imageToDecode);
                }
            }
        }
        VideoOutput{
            id:videoOutput
            source:camerax
            //focus: visible
            anchors.fill:parent
            fillMode: VideoOutput.Stretch
            filters: [ zxingFilter ]
            MouseArea {
                anchors.fill: parent
                onClicked: {
                    camerax.focus.customFocusPoint = Qt.point(mouse.x / width,  mouse.y / height);
                    camerax.focus.focusMode = CameraFocus.FocusMacro;
                    camerax.focus.focusPointMode = CameraFocus.FocusPointCustom;
                }
            }
            Rectangle {
                id: captureZone
                color: "red"
                opacity: 0.2
                width: parent.width / 2
                height: parent.height / 2
                anchors.centerIn: parent
            }
        }
        QZXingFilter{
            id: zxingFilter
            captureRect: {
                // setup bindings
                videoOutput.contentRect;
                videoOutput.sourceRect;
                return videoOutput.mapRectToSource(videoOutput.mapNormalizedRectToItem(Qt.rect(
                                                                                           0.25, 0.25, 0.5, 0.5
                                                                                           )));
            }

            decoder {
                enabledDecoders: QZXing.DecoderFormat_QR_CODE

                onTagFound: {
                    console.log(tag + " | " + decoder.foundedFormat() + " | " + decoder.charSet());

                    window.detectedTags++;
                    window.lastTag = tag;
                }

                tryHarder: false
            }

            onDecodingStarted:
            {
                //            console.log("started");
            }

            property int framesDecoded: 0
            property real timePerFrameDecode: 0

            onDecodingFinished:
            {
                timePerFrameDecode = (decodeTime + framesDecoded * timePerFrameDecode) / (framesDecoded + 1);
                framesDecoded++;
                console.log("frame finished: " + succeeded, decodeTime, timePerFrameDecode, framesDecoded);
            }
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions