QR Code Scanner App for Android and iOS

not work

import QtQuick 2.5

import QtQuick.Controls 2.0
import QtQuick.Layouts 1.1
import QtMultimedia 5.5
import QZXing 1.0

Item
{
id: window

property bool debug: contentUi.getValueByKey("debug") == "on" || contentUi.getValueByKey("debug") == "true"
property bool verbose: contentUi.getValueByKey("verbose") == "on" || contentUi.getValueByKey("verbose") == "true"
property bool autofocus: contentUi.getValueByKey("autofocus") == "on" || contentUi.getValueByKey("autofocus") == "true"
property bool zone: contentUi.getValueByKey("zone") == "on" || contentUi.getValueByKey("zone") == "true"

Component.onCompleted: {
    widget.content.statusMsg = ""
    widget.content.status = 0
}

property int detectedTags: 0
property string lastTag: ""

Camera
{
    id:camera
    focus {
        focusMode: CameraFocus.FocusContinuous
        focusPointMode: autofocus ? CameraFocus.FocusPointAuto : CameraFocus.FocusPointCustom
        customFocusPoint: Qt.point(0.5,  0.5)
    }
}

VideoOutput
{
    id: videoOutput
    source: camera
    anchors.fill: parent
    autoOrientation: true
    fillMode: VideoOutput.PreserveAspectCrop 
    filters: [ zxingFilter ]
    MouseArea {
        anchors.fill: parent
        onClicked: {
            camera.focus.customFocusPoint = Qt.point(mouse.x / width,  mouse.y / height);
            camera.focus.focusMode = CameraFocus.FocusMacro;
            camera.focus.focusPointMode = CameraFocus.FocusPointCustom;
        }
    }
    Rectangle {
        id: captureZone
        visible: zone
        color: "transparent"
        opacity: 0.2
        width: Math.min(parent.width,parent.height)*0.8
        height: width
        anchors.centerIn: parent
        border.color: "yellow"
        border.width: 20
    }
}

QZXingFilter
{
    id: zxingFilter
    captureRect: {
        videoOutput.contentRect;
        videoOutput.sourceRect;
        return videoOutput.mapRectToSource(videoOutput.mapNormalizedRectToItem(Qt.rect(
            zone ? 0.1 : 0, zone ? 0.1 : 0, zone ? 0.8 : 1, zone ? 0.8 : 1
        )));
    }

    decoder {
        enabledDecoders: QZXing.DecoderFormat_EAN_13 | QZXing.DecoderFormat_CODE_39 | QZXing.DecoderFormat_QR_CODE

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

            window.detectedTags++;
            window.lastTag = tag;
            
            widget.content.statusMsg = tag
            widget.content.status = 1
            widget.content.script.actionStart()
        }

        tryHarder: false
    }

    property int framesDecoded: 0
    property real timePerFrameDecode: 0

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

Connections {
    target: widget.scriptAdaptor
    onEventChanged: {
        changeTimer.restart()
   }
}

Timer {
    id: changeTimer
    interval: 25
    onTriggered: {
        debug = contentUi.getValueByKey("debug") == "on" || contentUi.getValueByKey("debug") == "true"
        verbose = contentUi.getValueByKey("verbose") == "on" || contentUi.getValueByKey("verbose") == "true"
        autofocus = contentUi.getValueByKey("autofocus") == "on" || contentUi.getValueByKey("autofocus") == "true"
        zone = contentUi.getValueByKey("zone") == "on" || contentUi.getValueByKey("zone") == "true"            
    }
}

Rectangle {
    id: debugInfo
    visible: debug
    anchors.fill: parent
    anchors.topMargin: 75
    anchors.bottomMargin: parent.height - 75 - text1.contentHeight*2
    color: "#88ffffff"

    Text
    {
        id: text1
        visible: debug
        wrapMode: Text.Wrap
        font.pixelSize: 40
        anchors.top: parent.top
        anchors.left: parent.left
        text: "Tags detected: <b>" + detectedTags + "</b>"
    }
    
    Text
    {
        id: text2
        visible: debug
        wrapMode: Text.Wrap
        font.pixelSize: 40
        anchors.top: text1.bottom
        anchors.left: parent.left
        text: "Last tag: <b>" + lastTag + "</b>"
    }
    
    Text
    {
        id: fps
        visible: debug
        font.pixelSize: 40
        anchors.top: parent.top
        anchors.right: parent.right
        text: (1000 / zxingFilter.timePerFrameDecode).toFixed(0) + "fps"
    }
}

}
import QZXing 1.0

Yes, it does not work in Android. Thank you, we’ll fix it for next version!

It’s fixed in the new version 2.1: https://flipab.it/download/


Back to Flipabit >
Copyright © 2018. Flipabit Team. All rights reserved.