Introduction of QR Code Reader Library
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.
28 Comments
[...] QR Code Reader Library by Kenichi Ueno Introduction of QR Code Reader Library Kenichi UENO: For people who want to use QR Codes within the Flash environment, LOGOSWARE (the [...]
This doesn’t work for me. I’m using a Mac with a built-in iSight camera. Would that be a problem?
Stuart: Some webcam would be a problem for following reasons. 1.It can’t focus in closeup, 2.It has a large distortion, 3.It has many moire stripes.
Although, improvement of the recognition Class would get rid of some of these. If you sent me the screenshot, it would be a help.
Thank you.
Sorry, should’ve been more clear. Even after clicking “allow”, the camera doesn’t activate, the box is just grey.
Oh OK, please confirm that other application is not using the camera at the same time.
No, nothing else at all I’m afraid. If you need me to test any updated builds, please just email!
Kenichi, thanks, that’s really cool.
I test and work good,
I just notice the recognition take some time or maybe was the focus for my camera -distortion-
By the way, I noticed too that the return string when I encoded Latin characters like á ó or German umlaut like Ü ö ä ß are not property represent.
that ’s can be the encoding UTF8 … I will check more deep your sample and code.
again thanks for share it
Best,
guillermo
[...] JActionScripters » Blog Archive » Introduction of QR Code Reader Library 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. [...]
Guillermo, thank you for trying this library.
The original QR code does not support UTF8. It has only 4 modes of encoding – numbers, alphabets and numbers, a 8-bit byte and Kanji characters(shift-JIS encoding).
I have no idea if the QR code encoder customized to use UTF8 encoding instead of shift-JIS encoding even exists. But if you already have such encoder, it is not so difficult to make a customized version of decoder. The encoding of Kanji characters is written in lines.351-363 of QRdecode.as.
[...] QRCodeReader by LOGOSWARE – A library to recognize and decode QRCode in specified image. [...]
The idea of having 2d barcode recognition available to a flash app is awesome, but the detection seems a bit sub par. It seems that if there is any skew to the code at all, or not filling up all of the are within the guide lines, it’s almost useless. If the recognition time can be bumped up and it’s less finicky, I’d love to implement it in a project.
[...] ちなみにJActionScripterに書いた英語版の紹介記事はこちら。英文のネイティブチェックはSimon氏にやってもらいました。thx! [...]
[...] Developer for Logosware Software, Kenichi Ueno has released a library into the Spark Project (an open source community to develop Flash/ActionScripts) that recognizes [...]
Hello, i am looking forward to use your qrlicense, but have been unable to find one example that reads the code from a local file like a png image, i have been trying, but it yields about invalid bitmap this is the code i am using:
public function qrReader(): void {
qrCodeLoader= new Loader();
qrCodeImage = new URLRequest(”licenses/qr.png”);
qrCodeLoader.load(qrCodeImage);
var qrSprite:Sprite = new Sprite();
qrSprite.addChild(qrCodeLoader)
getQRimage = new GetQRimage(qrSprite); // imageSrc:DisplayObject(Sprite, Video, …)
getQRimage.addEventListener(QRreaderEvent.QR_IMAGE_READ_COMPLETE, onQrImageReadComplete);
getQRimage.process();
function onQrImageReadComplete(e:QRreaderEvent):void{
qrDecode.setQR(e.data);
qrDecode.addEventListener(QRdecoderEvent.QR_DECODE_COMPLETE, onQrDecodeComplete);
qrDecode.startDecode();
}
function onQrDecodeComplete(e:QRdecoderEvent):void{
trace(e.data)
// e.data is the string decoded from QR Code
}
}
Hi,
I am working on a school project. I know it is not a right place to post my problem as it is related to .net application, but i need it urgently and i know atleast you can give me some direction to solve this problem.
The project is to develope a .net(c#) application to read QRCode. I am able to deoce it from a QRCode image. But when i use a Webcam image, same code does not work. Can you help me in this.
Thanks
Hi Kenichi,
I just found this amazing qr reader, and i was trying to do so changes but i think i am not that smart. I was trying to add adaptive thresholding.
Could you help me out and give me some pointers.
Thanks
Hi.İts so successful project but it’s not working on my computer.I’m using your shared class ‘ReadQrCodeSample.as’ but no =( it’s working on this site very successfuly but not working my computer.Why is that? Thank you….
I’m sorry that I have not approved recent comments because I didn’t notice to have to do that ; )
carlos >
I believe your problem was solved by initializing the class correctly. Thanks for sending me an email.
raj >
I guess the thresholding is not working well.
But to narrow what is the problem, you should try passing an image captured by webcam to the decoder directly.
I’m sorry for being late to answer for an urgent question.
Jaime >
You can add your thresholding method at com.logosware.utils.QRcode.QRCodeDetector class’s detect() method.
Thresholding techniques themselves are almost same as ones for AR marker detection.
It must worth to research them too.
Özgün >
I am note sure what is the problem though, please make sure your webcam is working only in one application simultaneously.
Thank you for sending me an email and noticing me about comments here : )
Kenichi
Thanks for the introduction to the QR Code Reader Library. I’m wondering if theres a version that can be hosted (that runs within a browser)?
Thanks
Sometimes Flash traces this error. Any idea what that could be ? :
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.logosware.utils.QRcode::G8Num/multiply()
at com.logosware.utils.QRcode::QRdecode/_RS8bit()
at com.logosware.utils.QRcode::QRdecode/_ReedSolomon()
at com.logosware.utils.QRcode::QRdecode/startDecode()
at ReadQrSimple/onQrImageReadComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.logosware.utils.QRcode::GetQRimage/process()
at ReadQrSimple/refresh()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
Hi,
I’ve made an example with Automated Threshold (by Quasimondo:
http://www.quasimondo.com/archives/000690.php
)
Thank you for the excellent library.
See:
http://www.kasperkamperman.com/blog/flash-qrcode-reader-as3/
thanks for sharing such interesting code. Pls I need to know how can I scan directly from the webcam.
it ’s simple to put the image path in the “imageSrc” . but how can I get the result directly without cliking ou button to take a picture.
Thank you in advance
Kenichi Ueno,
Do you mind to show me the way to build them step by step…
I have a limited knowledge on flash
thanks in advance for your help.
The application is perfect, just a shame it’s not quicker at reading from the webcam.
Hello, Is great your app, but once the app recognices the code I would like to open the website in a new window.
How can I do it?
thank you
[...] QR Code Reader – A library that recognizes and decodes any QR Code from any image source http://blog.jactionscripters.com/2009/05/23/introduction-of-qr-code-reader-library/ [...]
Hi, kindly tell me how to speed up the process of scanning as its very slow and I wanted to convert it to an android app by minor tweekings.
Please help as I am stuck.
thanks,
HIma
[...] QR Code Reader – A library that recognizes and decodes any QR Code from any image source http://blog.jactionscripters.com/2009/05/23/introduction-of-qr-code-reader-library/ [...]