I would like to extend the code here to extract the corners of the QCodes.
#!/usr/bin/python
from sys import argv
import zbar
from PIL import Image
if len(argv) < 2: exit(1)
# create a reader
scanner = zbar.ImageScanner()
# configure the reader
scanner.parse_config('enable')
# obtain image data
pil = Image.open(argv[1]).convert('L')
width, height = pil.size
raw = pil.tostring()
# wrap image data
image = zbar.Image(width, height, 'Y800', raw)
# scan the image for barcodes
scanner.scan(image)
# extract results
for symbol in image.symbols:
# do something useful with results
print 'decoded', symbol.type, 'symbol', '"%s"' % symbol.data
# clean up
del(image)
In a previous posting, the author indicates that this is possible "*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 %**>"
See Detect the size of a QR Code in Python using OpenCV and Zbar )
I referred to the Zbar SDK ( http://zbar.sourceforge.net/api/classzbar_1_1Symbol.html ), and still couldn't figure out how to extract the corners. I'd appreciate it if someone could show me how (to extract the corners using Python).
Three corners of the QR Code contain the finder pattern, a nested series of black and white squares that, when detected by an optical scanner and interpreted by software, allow the scanning device to determine the orientation of the QR Code. Two other patterns are also present.
In your loop, try:
topLeftCorners, bottomLeftCorners, bottomRightCorners, topRightCorners = [item for item in symbol.location]
You'll get the 4 corners
Late answer but this can help others Dom
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With