Interestingly this pyzbar seems to be the best way to go for now:
Vikas Gupta at learnopencv.com writes:
Speed
The ZBar library is almost twice as fast as the OpenCV QR code detector.
Robustness
The ZBar library produces more robust results as compared to OpenCV on the following factors as shown in the above video :
ZBar is better or comparable at various rotation
ZBar is better at different image sizes as seen from the different zoom levels in the video
ZBar is better at handling perspective distortions ( when the image is not upright w.r.t the camera.
Features
The ZBar library provides support for Bar codes as well, which is not yet there in OpenCV.
Overall, we can say that QR Code is launched recently in OpenCV and it might get better in future releases. Till then, if you want to use Bar code or QR Code in your application, stick with ZBar.
Even using a smartphone that is particularly and specifically designed to read QR codes, and with a pretty darn nice camera, thank you very much, I still have to be within a foot to get a reading.
My cases are both with a high-contrast monitor, back-lit to about 5,000-or-so °Kelvin, and a piece of white paper on a red table lit with a LED lamp somewhere around 3,000 °K
The best I can hope to achieve is about 12" max. Â Thinking that my palsy might be affecting things, (no kidding!), I asked both my granddaughters - who have hands that are steady as rocks - to try it. Â Even with very steady hands, they didnât get much more.
It should be noted that, in order for the QR code to read properly, it must take up a very large portion of the visible image. Â QR codes Iâve seen on the sides of trucks, or on billboards, are HUGE - several feet on a side.
If youâre going to want Carl to read a QR code at any distance further away than a foot-ruler, youâre going to have to make it BIG, as in gigantic. Â Maybe as large as the width of Carlâs sign? Â Maybe even larger.
Been testing more at various camera modes and it seems like the farthest I can get recognitions is 5 feet - if I keep checking more frames, and some QR codes appear to be easier to reco than others.
I need to see if there is something like âlow resolution QR Codesâ that might have longer reco distances. Since the encoding allows for so much information, the codes are perhaps more complex and detailed than needed for recognizing âcode 0 ⌠code 9â.
This is from 54 inches at 1920x1080 with Carl âthinking about itâ for 10 seconds, and finding 2 of the 13 codes in the image:
Â
The issue here is not the resolution of the QR code itself, per. se., itâs the size of the printed image. Â Obviously, QR codes with more detail need to be larger to get the element sizes to something readable.
It has been my experience that, to get any kind of accuracy, you need better than 5 mpx to get the image clarity you need. Â But the real limiting factor is the size of the image itself. Â At risk of dredging up an old saw, (that is badly in need of sharpening), size DOES matter.
The bigger the better.
Suggested experiment:
Print out several copies of the exact same QR code, in various sizes, all the way up to full-page-width for one QR code.
Print one QR code per page - (or however you see fit). Â Me? Â Iâd do one page with the size in inches, (size"), marked in huge letters, since a QR code is always square, AFAIK.
Iâd then try Carl at various distances from each sized QR code. Â This way you can rapidly determine the variation. Â If you want to spring for the new âhigh-resâ Pi-Cam, try it with that too.
Yes I saw a size vs distance application chart for private 1-2 feet distance and 2-4 inches, commercial farther and bigger, and public (billboards) Huge and still not that far away. It also mentioned the 5 mp assumption.
So my version 1 cam running at 1mp is actually excelling!
I donât need QR codes. It was just my latest scheme to try for guiding Carl.
I already started working on another technique, but I donât regret learning this. Doubt Hanna will like me sticking codes on all the baseboards to id the walls/rooms for Carl, but it was an interesting thought.
Didnât you read about the new âFrameQRâ codes where you can put pictures, logos, and all kinds of fun stuff in them. Make them shaped like valentineâs hearts, with her picture, and comments about how wonderful she is - and youâve got it in the bag!
Wow! Â And I thought MY wife was tough! Â All she did was handle multi-million dollar contracts for the Soviet government when they were around - then she became the country manager for Lloydâs Register of Shipping. (a worldwide maritime vessel inspectorate and certification business)