For people who want to use QR Codes within the Flash environment, LOGOSWARE (the company I work for) has released a QR Code Reader into the Spark Project.

It is essentially a library that recognizes and decodes any QR Code from any image source.


The QR Code Reader is made from 2 main Classes.
1. GetQRImage Class: recognize QR Code from any image
2. QRdecode Class: decode a QR Code to get string

Here is an introduction on how to get started.

1. GetQRImage:

// set DisplayObject contains a QR Code
getQRimage = new GetQRimage(imageSrc); // imageSrc:DisplayObject(Sprite, Video, ...)
// run onQrImageReadComplete when the QR Code is found
getQRimage.addEventListener(QRreaderEvent.QR_IMAGE_READ_COMPLETE, onQrImageReadComplete);
// begin recognition. you may run this every frame when the image source is viewed by a webcam.
getQRimage.process();

// invoked when QR Code is found
function onQrImageReadComplete(e:QRreaderEvent):void{
// e.data is a 2D bit array of QR Code
}

 
The bit array of QR Code obtained by GetQRimage can be decode by QRdecode Class.

2.QRdecode Class

// set 2D bit array of QR Code
qrDecode.setQR(e.data); // e:QRreaderEvent
// run onQrDecodeComplete when decoding is complete
qrDecode.addEventListener(QRdecoderEvent.QR_DECODE_COMPLETE, onQrDecodeComplete);
// begin decoding
qrDecode.startDecode();

// invoked when decoding is complete
function onQrDecodeComplete(e: QRdecoderEvent):void{
// e.data is the string decoded from QR Code
}

Below is a sample of the flash application and a QR Code. If it doesn’t work, please check the following.

  • Is the webcam connected to your computer?
  • focus the webcam
  • set the webcam center, directly viewing the QR Code, and move it back and forth

 


 
Both Classes support QR Code of Model Two, Version 1-10 and all levels of Error correction.
If you have any comments or questions, please post them here or e-mail me directly.
keno42 [at] gmail [dot] com

I think the GetQRimage Class has many points to be improved upon (e.g. It is currently using a global thresholding, but an adaptive thresholding may increase recognition rate).
I will keep updating these points and then submit them to the Spark Project.


QR code (R) is a registered trademark of Denso Wave Incorporated.

Follow me on Twitter