Investigating QR Codes

I decided to check out how my GoPiGo3 with RPi 3B can do with reading QR codes.

To Generate QR Codes: http:/

QR Code graphics are able to store over 3000 characters. The information is encoded according to ISO/IEC 18004:2006

My result is less than impressive. I had this hope of reading 2x2 inch QR codes from 8-10 feet away, but the best I can get is 24 - 29 inches.


  • Processing:

    • fixTiltOCV only
    • Blurs, Thresholding, Dilations (that I tried) decreased performance
  • Camera

    • CAMERA_RESOLUTION = (320,240) or (640, 480) or (1280, 960) or (2560, 1920)
    • CAMERA_BRIGHTNESS = 60 # 50 default
    • CAMERA_CONTRAST = 60 # 0 default
    • CAMERA_SHARPNESS = 25 # 0 default
    • CAMERA_AWB_MODE = ‘incandescent’
  • 320x240 gets 12 inches reliably

  • 640x480 gets 18-20 inches reliably

  • 1280x960 gets 24-29 inches reliably

  • 2560x1920 no recognitions at any distance

  • Best QR set reading was 11 out of 12 on the page, sometimes 6, sometimes 9…

  • Frame rate as high as 4 fps if none found

  • Framerate for single QR 320x240 2 fps

  • Frame rate around 0.3 fps or 3 seconds per frame

Ignore that it did it twice - fixed off by one error:

Interestingly this pyzbar seems to be the best way to go for now:
Vikas Gupta at writes:


The ZBar library is almost twice as fast as the OpenCV QR code detector.


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.


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.


1 Like

This does not surprise me.

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:


Perhaps better, showing the actual full res frame also:

1 Like

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:

  1. 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.
  2. 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.
  3. 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.

1 Like

Of course you can!

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! :wink:

1 Like

I got that one down, (but ex-Israeli military commanders aren’t much interested in cute little hearts).

1 Like

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)

Sounds like they both have AAAA+++ personalities.

1 Like