5

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).

lucidbrot
  • 5,378
  • 3
  • 39
  • 68
user3614305
  • 81
  • 1
  • 5

1 Answers1

5

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

Dominique
  • 455
  • 1
  • 8
  • 18