From 0e10d8aecad00b23bd5113b50f93a08e3358bd6c Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Mon, 19 Dec 2016 11:32:20 +0100 Subject: [PATCH] Add simple FPS counter to QZXingLive example --- examples/QZXingLive/main.qml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/examples/QZXingLive/main.qml b/examples/QZXingLive/main.qml index b6d7769..7268934 100644 --- a/examples/QZXingLive/main.qml +++ b/examples/QZXingLive/main.qml @@ -34,6 +34,15 @@ ApplicationWindow z: 50 text: "Tags detected: " + detectedTags } + Text + { + id: fps + font.pixelSize: 20 + anchors.top: parent.top + anchors.right: parent.right + z: 50 + text: (1000 / zxingFilter.timePerFrameDecode).toFixed(0) + "fps" + } Camera { @@ -103,9 +112,14 @@ ApplicationWindow // console.log("started"); } + property int framesDecoded: 0 + property real timePerFrameDecode: 0 + onDecodingFinished: { - console.log("frame finished: " + succeeded, decodeTime); + timePerFrameDecode = (decodeTime + framesDecoded * timePerFrameDecode) / (framesDecoded + 1); + framesDecoded++; + console.log("frame finished: " + succeeded, decodeTime, timePerFrameDecode, framesDecoded); } }