Finding the location of the QR code in an image

Oct 13, 2013 at 10:43 PM
Edited Oct 13, 2013 at 10:44 PM
First LOVE this lib. Nice work.

My Question:

Rather than having my application decode the QR value and launch a new window to view data related to a tag, I want to render on the video feed a link "next" to the QR Tag on screen.

To do this I need to know the location of the QR tag in the source image.

This is a WP8 application.

Any pointers would be helpful.

Thanks in advance
Oct 16, 2013 at 5:48 PM
The demo client in the source code shows you how to do this. That link is HERE

The object returned from the decode method contains a ResultPoints collection which you can use to build a bounding rectangle. The result points are not the edges of the QR code but the center of the location squares.

Here is the relevant code.
if (result.ResultPoints.Length > 0)
                  var rect = new Rectangle((int) result.ResultPoints[0].X, (int) result.ResultPoints[0].Y, 1, 1);
                  foreach (var point in result.ResultPoints)
                     if (point.X < rect.Left)
                        rect = new Rectangle((int) point.X, rect.Y, rect.Width + rect.X - (int) point.X, rect.Height);
                     if (point.X > rect.Right)
                        rect = new Rectangle(rect.X, rect.Y, rect.Width + (int) point.X - rect.X, rect.Height);
                     if (point.Y < rect.Top)
                        rect = new Rectangle(rect.X, (int) point.Y, rect.Width, rect.Height + rect.Y - (int) point.Y);
                     if (point.Y > rect.Bottom)
                        rect = new Rectangle(rect.X, rect.Y, rect.Width, rect.Height + (int) point.Y - rect.Y);
                  using (var g = picBarcode.CreateGraphics())
                     g.DrawRectangle(Pens.Green, rect);
Jun 2, 2014 at 8:02 PM
Edited Jun 2, 2014 at 8:08 PM
I expected the Windows Forms sample to draw a green rectangle around the area identified as a barcode. It never worked this way. Always a line - height 1 px - was drawn... :(

To be precise: testing with the sample-Images like
draws a green rectangle.
The rectangle around the decoded Barcode detected on
limits to a line.
Jun 3, 2014 at 10:03 PM
It's "by design" for 1D barcodes because of decoding speed.
The result points array gives a rectangle only for 2D code (like Aztec, QR, PDF417 or Data Matrix).