Question

I have code that takes an image from the webcam, scans it for QR codes using zBar and returns the value of the code and an image with the QR code highlighted (based off http://sourceforge.net/p/qrtracker/wiki/Home/). How can I also make it tell me the size of the code (as a pixel value or % of the screen)?

Additional question: is there a way to detect how skewed it is (e.g rotation in Z about the Y-axis)?

Was it helpful?

Solution

Regarding the size of Code

zBar provides a method to do this in terms of pixel values (Once you know the size in pixel values, you can find it in %)

I would like to extend the code here: http://sourceforge.net/apps/mediawiki/zbar/index.php?title=HOWTO:_Scan_images_using_the_API

Above code finds a QR code in an image, prints its data etc. Now checking last few lines of code:

import math
scanner.scan(image)
[a,b,c,d] = x.location   # it returns the four corners of the QR code in an order
w = math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2)  # Just distance between two points
h = math.sqrt((b[0]-c[0])**2 + (b[1]-c[1])**2)
Area = w*h

Skewness of QRCode

I think you want to transform it into a pre-defined shape (like square, rectangle, etc). If so, you can define corners of a pre-defined shape, say ((100,100), (300,100),(300,300),(100,300)). Then find the perspective transform and apply the transformation if you would like. An example in OpenCV is provided here: http://docs.opencv.org/trunk/doc/py_tutorials/py_imgproc/py_geometric_transformations/py_geometric_transformations.html#perspective-transformation

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top