Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

New QR Code Reader Library

DZone's Guide to

New QR Code Reader Library

Learn about a new, free QR code reader and associated library that improve performance and let you take advantage of QR for more innovative purposes.

· Mobile Zone ·
Free Resource

This article discusses a new free QR Code detector that has been released as part of an existing open source computer vision library. Its features are highlighted and a performance study is shown, comparing it to several other open source libraries. It's shown to have the best overall performance and be one of the faster libraries.Image title

For the few of you who don't know, those weird markers you have been seeing printed on buisness cards, food, and shipping boxes, with three squares on them are QR Codes. They are used to encode data such as websites, e-mail addresses, and product information. Just take a photo of it with the correct application and you will get access to all that information or automatically taken to a website. In theory.

For years now, there have been several open source QR Code detectors or reader libraries to choose from. A software developer can add one of these libraries to their application then read the QR Codes using a camera. Probably the most popular library is ZXing, but there plenty of others to choose from. These libraries are typically designed to for the most common use case, which is detecting a single QR Code in nominal lighting conditions.

Recently a new QR Code detector was added to BoofCV, which leverages past development on markers for camera calibration and augmented reality. The main motivation behind the development of this new QR Code detector was to read numerous QR Codes in a single high-resolution image, in less than ideal lighting conditions, with high-accuracy corners, as fast as possible. In that, it was almost completely successful.

Features of BoofCV's QR Code Detector:

  • Fast detection

  • Works in poor lighting conditions

  • Barely slows with numerous markers in view at the same time

  • High Precision Corner

  • Access to internal data structures and likely false negatives

  • True rotation invariance

The main disadvantage of BoofCV's detector, relative to other libraries, is that it doesn't handle damaged locator patterns very well. Locator patterns are the squares within a square. Most detectors use some variant of the baseline algorithm described in the QR Code specification. BoofCV uses a technique designed for AR markers. This makes it invariant to rotation, but doesn't like it when the squares are scratched. Scratches/damage inside the data region are just fine and easily recovered from. 

To test this new detector's capabilities, a performance benchmark has been created from 230  images (and counting). These images are carefully selected to stress test it in many different environments and situations. A sample of the types of images included is shown below.

Sample Images From Different Categories

This same benchmark has been applied to ZXing, Quirc, and ZBar libraries! Those are all the open source libraries that I'm aware of. When possible, each of the libraries was tuned to detect QR Codes robustly. Results are shown below for detection under several different categories. F-Measure is the performance metric. A value of 1 means perfect performance and 0 means it failed to detect anything.

Detection Performance by Category

One thing to take away from this chart is that there's no clear winner across every category, but there are libraries which clearly do better overall. BoofCV's new detector does very well in situations that it was designed for. The benchmark is freely available, too, and can be found here in the third-party directory. More images are being added to it on a regular basis. You can help if you have access to images from a factory environment by sending them over.

What about speed? This benchmark wasn't designed to evaluate how fast individual libraries run. It does keep track of total compute time, which includes reading the images and saving the output. I was hesitant in including those results, but decided that the conclusion was unlikely to change as a result of more careful analysis.

Library

Processing Time Seconds
(Lower the Better)

Quirc 37.4
BoofCV 41.6
ZXing 78.3
ZBar 115.4

The two fastest libraries are clearly Quirc and BoofCV, while BoofCV does much better than Quirc in most categories. In some cases, like with ZXing, a library can be tuned to run faster at the sacrifice of being able to detect QR Codes robustly. If there's interest, I'll do a follow-up article which will go into much more detail about how tuning affects performance in each library and goes into a greater discussion of how the results are found.

Head on over to http://boofcv.org if you want to check out the new detector. Feel free to post questions below, too! It's easy to run on any desktop computer (Windows, Mac OS X, Linux) and Android.

Topics:
mobile ,performance ,android ,open source ,qr codes ,libraries

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}