×
Namespaces

Variants
Actions
Revision as of 10:46, 18 May 2011 by hamishwillee (Talk | contribs)

Qr Decoder in Qt

From Nokia Developer Wiki
Jump to: navigation, search

This is a Barcode Decoder program using the C++ part of ZXing project to process the image and decode it.

It currently supports decoding:

  • Qr codes
  • EAN
  • Code 128
  • UPC-A
Qr Code containing the text "Qr Decoder in Qt"

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)).


  • QCameraControllerWidget:
    This widget is responsible for the camera. All the camera operations are taken from S60 Platform: Camera Example, so sense that this part is Symbian specific. On construction, the camera is reserved and powered on which are asynchronous operations. When ready, a backbuffer is created to hold the live camera feedback images which are reported through MceoViewFinderFrameReady( CFbsBitmap&). When each frame is reported, it is saved to the backbuffer and then update is called to print it. CaptureImage() method can be called to initiate capturing image operation. When image is captured successfully, imageCaptured(QImage) signal is emitted.


  • 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.


Preconditions to use it for Symbian

Inside the project folder, there is a folder named camerawrapper. Inside this, the epoc32 folder must be copied to the epoc32 folder of the Symbian SDK to be used!
(in my case: C:\S60\devices\S60_5th_Edition_SDK_v1.0)

NOTE: Tested on Nokia 5230 (S60 5th Edition SDK v1.0) and Nokia E52 (S60 3rd FP2 SDK v1.1). On E52 the detection rate was not that great considering the fact that its camera is not as good as 5230's.

How to use it on other platforms than Symbian

Since only QCameraControllerWidget is Symbian specific you can just change the source of the image to be decoded. For example, the image can be read from the local file system, or re-implement QCameraControllerWidget with target platform specific code on how to use the camera and capture images.

Download

  • File:ZXingBarcodeReader.zip
    This is the same implementation but without Qt. The GUI is implemented with Symbian C++ and again OpenC++ is required (for the ZXing library to work).

Licence


Useful Links

373 page views in the last 30 days.
×