KDE Frameworks Barcode Scanner
KDE Framework’s Prison library for displaying one-dimensional barcodes and two-dimensional matrix codes will also provide a component to scan those codes from a camera feed in its upcoming 5.94 release.
Features
There are a few copies of code for scanning barcodes from a Qt Multimedia video feed using ZXing in apps like Kaidan or Qrca, as well in projects outside of KDE’s repositories. That’s usually a good indicator that this functionality belongs into a shared component or library.
For 5.94 KDE Frameworks now provides this, taking the best bits of the existing implementations and expanding on them:
- Barcode detection happens in a separate thread to not impact displaying the video feed or application UI.
- By using newer ZXing API we can avoid expensive color conversions for many video formats, in the best case detection is now done without a single video frame copy.
- For planar or semi-planar video formats (that is formats which have a luminance channel that isn’t interleaved with color channels), barcode detection is performed solely on the luminance data, avoiding not only the color conversion but also effectively reducing the amount of data to process by half.
- Forward-compatibility with Qt6, which changed the API of Qt Multimedia significantly.
Overall this is fast enough for running barcode detection on every frame of a live video feed, on a phone.
This is available both from a C++ and a QML API which can consume a Qt Multimedia video stream and outputs the detected barcodes, including their textual or binary content, the barcode format and the barcode position in the source video frame.
App Integration
There is no UI included, applications have full control on how to integrate and display this. This isn’t difficult at all though, and just takes three elements to get started:
import QtQuick 2.15
import QtMultimedia 5.15
import org.kde.prison.scanner 1.0 as Prison
ApplicationWindow {
Camera {
id: camera
}
VideoOutput {
id: viewFinder
anchors.fill: parent
source: camera
filters: [scanner]
}
Prison.VideoScanner {
id: scanner
onResultChanged: console.log(result.text)
}
}
Slightly more comprehensive QML examples for both Qt5 and Qt6 are included in the Prison source code, demonstrating more ways to use the scan results for example.
There’s also two merge requests for use in applications already:

Contribute
There are more applications that would benefit from direct barcode scanning integration, such as Vakzination or Keysmith. Another place might the Wi-Fi setup UI of Plasma Mobile, Qrca even already has the necessary Wi-Fi QR code parsing code which might come in handy here.