QR Barcode Detection
Machine Vision
Components in QR code readers
Image
Conversion
QR Detector
QR Decoder
http://www.yahoo.com
Photo
QR Code
1010111
0110011
1100011
0010101
Raw Data
This is what we
are focusing on
QR Properties (Basic)
Position Patterns

Determines the
correct orientation
Alignment Pattern

Used for perspective
transformations
corrections
Version Information
Position Patterns may be
detected horizontally or
vertically by the unique
B

W

B

B

B

W

B ratio
Data bit
QR Detection Algorithm
Proceeds by horizontally column scanning the raw image pixels (or vertically
row scanning) to locate the 3 position patterns identified by the 1

1

3

1

1 ratio
After a potential position pattern is located, it is then cross

checked in the
“other” direction for the same ratio and position pattern size
Also determines the center of the position pattern
Triangle Point Ordering
+
+
+
Remember Pythagoras' theorem?
The points at either
end of the hypotenuse
are points ‘A’ and ‘C’
A
B
C
Points ‘A’ and ‘C’ may
be in the wrong order
so we can use the
cross product to
determine the angle
between point B and
the line segment AC
Perspective Corrections
Simply maps points on a
known
square to points on the distorted, rotated or
skewed square
Perspective Correction Algorithm
for (long i = 0; i < dimension; ++i) // y

axis direction
{
for (long j = 0; j < dimension; ++j) // x

axis direction
{
// The QR code is read as if it were an un

rotated and un

skewed image
POINT pt;
pt.x = (j * module_size) + half_module_size;
pt.y = (i * module_size) + half_module_size;
POINT p = transform.TransformPoint(pt); // Does the perspective correcting
qr_store.set(pt, image.IS_BLACK(p));
}
}
Perspective Corrections
and rotation corrections for free (with no use of expensive trigonometry functions)
+
+
+
+
size = “bit size” x dimension
size = “bit size” x dimension
This is why locating 4
points is so important
1
2
3
4
Only
version > 1
has the
alignment
pattern
Results
•
< 1000 Source Lines of Code (SLOC)
•
Almost no floating

point code
–
Working to make it none
•
Very quick
Results
Future Work
•
Image filtering and cleaning
–
Histogram analysis
–
Colour to greyscale to monochrome
•
QR decoding
–
Extracting the contents (Message, URI etc…)
•
Reed
–
Solomon error correction
–
Level L
–
Level M
–
Level Q
–
Level H
Comments 0
Log in to post a comment