Qr Decoder in Qt
This article demonstrates how to create a Barcode Decoder program, using the C++ part of ZXing project to process the image and decode it.
Article Metadata
Code Example
Tested with
Compatibility
Platform Security
Article
QQrDecoder project is developed entirely in Qt SDK + using the CPP part of the ZXing library. It supports the latest version of Qt in Symbian (4.7.x) and the camera is controlled using the Camera APIs from Qt Mobility project. Thus we reasure the compatibility with future releases of Qt and the compatibility with newer device with Symbian^3, Belle and Anna (and S60 5th).
The project's folder contains the code as well as the an installation file in case you want try it out without compiling the project.
It currently supports decoding:
- Qr Code
- DataMatrix (QZXing V1.1)
- Aztec (QZXing V1.2)
- UPC_E
- UPC_A
- EAN_8
- EAN_13
- CODE_128
- CODE_39
- ITF
Contents |
The three parts of the project
- CameraImageWrapper:
- The porting layer between the ZXing and Qt. Inherits from LuminanceSource (zxing/LuminanceSource.h) which is an abstract class representing a grey-scale image. This class holds the image information in a QImage and 3 methods were needed to be implemented: getWidth(), getHeight() and getPixel(int,int). The first 2 are trivial, the 3rd needed to return an unsigned char representing the grey-scale value of the pixel given as argument so since QImage will contain RGB image in this project, the return value was given by qGray(QImage::pixel(x,y)). New functions added to comply with the latest version of ZXing libary getRow(int, unsigned char*) and getMatrix().
- QCameraControllerWidget:
- This widget is responsible for the camera. All the camera operations are taken from QCamera Example. This is the widget where the image from the camera is shown. When the user presses the button to take a picture, that picture is decoded. If and barcode is found, it is reported with a QMessageBox else nothing happens.
- QQrDecoder:
- the main window class which contains a QCameraControllerWidget instance. QCameraControllerWidget::imageCaptured(QImage) signal is connected to QQrDecoder::decodeImage(QImage) slot, so each captured image is processed to find the "hidden" message inside the Qr Code.
Prerequisites to compile
- Have Qt SDK installed. This will give you all the tools needed such as the Qt SDK, Qt Mobility APIs and the Qt Creator IDE.
http://qt.nokia.com/downloads/
Prerequisites to install and run to device
- Have Qt 4.7.3 (and newer) binaries installed to the device.
- Have Qt Mobility 1.1.0 (and newer) binaries installed to the device.
NOTE: those binaries, if Qt SDK is installed, can be found under the path \QtSDK\Symbian\sis\Symbian^X\
Importing the project
For this step, Qt Creator IDE will be used (contained in Qt SDK). The project can be imported/opened with 2 ways.
NOTE: The project folder must be placed under the same drive letter as the installed Qt SDK. For example "C:\QtSDK" and "C:\QtProject\QQrDecoder"
- Go the the project's folder and double-click the QQrDecoder.pro file. This will result the Qt Creator to open. (This requires that Qt Creator is selected as the predefined program to open such files which is automatically set when installing Qt SDK.)
- Alternatively, open Qt Creator manually, and go under: "File" -> "Open File or Project...", go to the project's folder and select once again the QQrDecoder.pro.
Whichever step from the above you have followed, now you are led to screen named "Project Setup". Here you select the Target Platform. You can select "Symbian Device" to target directly for a physical device, or "Qt Simulator" to first test it to the build-in simulator.
Building the project
At this point you have imported the project and you are ready to compile it. At the left toolbar in Qt Creator, above the green arrow you can see the current target platform selected. Press to select which you want.
Now by pressing Ctrl+B or the "hammer icon" on the left at the bottom. Normally this should be completed without errors (might be lots of wrning though which we selectively reject them from our mind :P )
This step compiles the project BUT doesn't produces the .sis file (the installation file). To create the installation file you have to press the "Run button". It that "Green arrow" on your left, or by simply pressing Ctrl+R. Regardless if you have a device or not, the .sis file will be created.
Now you can install it to your device.
Version changes
- 1.3 Support of Aztec barcodes. Speed improvement in 1D decoding.
- 1.2.1 Removed automatic detection (unsupported operations from Qt Mobility). Detection happens by pressing a button.
- 1.2 Added zoom functionality. Added automatic detection (no need to press any button).
- 1.1 Camera Plug-in replaced by Camera API from Qt Mobility. New UI. Now the project is completely written on Qt.
- 1.0 Initial release. Was using Camera Plug-in for S60 3rd.
Download
- File:ZXingBarcodeReader.zip
This is the same implementation but without Qt. The GUI is implemented with Symbian C++ and again Open C++ is required (for the ZXing library to work).
Licence
- For the QCamera Example see Nokia_Licence.txt
- For the ZXing code see ZXing_Licence.txt
Useful Links
Qr Decoder for Windows phone 7
Following open source libraries are available for Windows Phone 7 :
NOTE : please look for any copyright/commercial use policy (if any) in the above links.
favoritas37 18:28, 14 May 2012 (EEST)



Contents
Hamishwillee - Hamishwillee - Thanks for the update
Hi Favoritas
Thanks very much for the update. Its great that you wrote the article in the first place, but keeping it up to date adds even more value! I've updated the documentation to add ArticleMetaData. Can you please have a look at the template and confirm its correct? Also add signing information and anything else I might have missed.
Regards
Hamish
Mch0lic - Problems with C7, Symbian Belle
I spend a lot of time trying to figure out whats wrong with the code. It does not seem to be working with C7 (Symbian Belle), qt 4.7.4.
I tried both purely qt versions (with the button to send image for processing and latest one which processes images automatically). Both of them would return me "General camera error", while application output would also tell me: [Qt Message] Camera error: "Starting viewfinder failed."
Is this related to Qt 4.7.4? I don't have opportunities to check the code on other devices / qt versions.mch0lic 14:55, 13 November 2011 (EET)
Favoritas37 - Regarding the problems on Symbian^3 and on
Have you tried the latest version of the project from this place? https://projects.developer.nokia.com/QQrDecoder/browser Today i made a last update which i hope will help.
Unfortunately i only have an S60 5th edition device, so this is my only test target where it does work. So i am waiting for your feedback on it.
The above project is compiled under Symbian^1 Qt 4.7.3 and Qt Mobility 1.1.3 so i would expect it to work on your device as well.
Once again, waiting for your feedback.favoritas37 15:17, 13 November 2011 (EET)
Ahandler - QQR Decoder on Symbian S60 3th Device
Is it possible to get it working on Devices like Nokia C05-00?
QT SDK 4.6.3 file works - but i can't add the SDK to QT
Any ideas?ahandler 12:40, 29 January 2012 (EET)
Favoritas37 - Re: QQR Decoder on Symbian S60 3th Device
Ahandler, the QQrDecoder example now uses Qt Mobility 1,1,3. Theoretically it is supported for S60 FP2 (the C05-00) but i am not sure if Qt Mobility 1.1.3 depends on Qt 4.7. If it does then you might need to check the old version of the QQrDecoder which uses Symbian C++ to manipulate Camera: http://www.developer.nokia.com/Community/Wiki/File:QQrDecoder.zip
Also i have a question, what do you mean by saying: "but i can't add the SDK to Qt"? You can't add the Symbian SDK version to the Qt Creator?
Ahandler - QQR Decoder on Symbian S60 3th Device
I allready tried the version, so sent me.
I i need du install SDK 4.6.3 on QT 1.1.2
http://file.kapo.co.at/qt.JPG
But i don't know, where from i get the SDK. And if i take the 4.7.3 i get these error:
"Unsupported platform ARMV6 specified"ahandler 14:31, 29 January 2012 (EET)