Qr Decoder in Qt
This is a Qr Code Decoder program using the C++ part of ZXing project to process the image and decode it.
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)).
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)
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 reimplement QCameraControllerWidget with target platform specific code on how to use the camera and capture images.