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

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

Closed
implor opened this issue Jul 12, 2018 · 15 comments
Closed

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

implor opened this issue Jul 12, 2018 · 15 comments

Comments

@implor
Copy link

implor commented Jul 12, 2018

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);
            }
        }
    }
@ftylitak
Copy link
Owner

Hello @implor

which platform are you targeting? Android? Linux? other?

@swex
Copy link

swex commented Jul 19, 2018

same here. decoding not working on 5.11 for somereason

@swex
Copy link

swex commented Jul 19, 2018

its not about target platform, but Qt version.

@ftylitak
Copy link
Owner

@swex
I have just built QZXingLive on Qt 5.11 for Android and it works. So may be i need more information to see that is the problem with your case.

@implor
Could you send me a sample image (QR code) that you try to decode and do not have success?
If you want to try our different QR codes that are already used in QZXing tests you can check out the qrcode related folder in the test resources: https://github.com/ftylitak/qzxing/tree/master/tests/resources

@seraphzxz87
Copy link

I have the same problem, QML decoding not work, the target platform is Linux.

@simonschmeisser
Copy link

I also tried QZXingLive with Qt5.11 on both Amd64 and Arm64 on linux and cannot decode any Qr code

@swex
Copy link

swex commented Nov 28, 2018

@simonschmeisser @seraphzxz87 check for my simple Qt/QML wrapper I've made around zxing-cpp works good for me for any Qt version.

@xuin-net
Copy link

xuin-net commented Apr 9, 2019

I also tried QZXingLive with Qt5.11.3 on Macx and cannot decode any Qr code

@Thaodan
Copy link
Contributor

Thaodan commented Apr 12, 2019

I've updated the QZXing live example and I can verify i works indeed with Android.

@Thaodan
Copy link
Contributor

Thaodan commented Apr 12, 2019

see my pr #102

@Thaodan
Copy link
Contributor

Thaodan commented Apr 12, 2019

Doesn't work for me on Linux either (Arch Linux Qt5.12).
Using a regular captured image works thou.

@ftylitak
Copy link
Owner

Hello all,

today I had an available linux pc to test and i confirm that for some reason the decoding fails.
I will try to find some time to debug it.

Meanwhile, when deployed on Android it continues to work properly.

ftylitak added a commit that referenced this issue Apr 17, 2019
…ead of the image is not correct (it is missaligned). #86
ftylitak added a commit that referenced this issue Apr 17, 2019
…n QZXingFilter. Now it seems that Decoding is working for Linux. #86
@ftylitak
Copy link
Owner

Hello all,

i have fixed the support of YUYV image decoding so now the decoding of images in Linux works.

Could you please give it a try and give me your feedback? I have added the solution to branch 86-fix-QZXingFilter-Linux . As soon as you confirm that it is ok, i will merge it to master.

@implor
Copy link
Author

implor commented Apr 17, 2019 via email

@ftylitak
Copy link
Owner

Closing due to inactivity since the issue has been resolved during our testing.

If any issue comes up freely open a new issue or reopen this one.

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

7 participants