0

I am having trouble doing some barcode reading. All of my barcodes are encoded in Code 39.

Here is the code I got from the zbar site and endless googling has returned Null.

from sys import argv
import zbar
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:
# do something useful with results
print 'decoded', symbol.type, 'symbol', '"%s"' % symbol.data

# clean up
del(image)

Any kind of help would be greatly appreciated.

thedemon
  • 329
  • 1
  • 6
  • 19
  • so whats teh problem? (on a side note most bar code scanners can talk over serial ports (or pseudo-serial ports) and just send the string of decoded values... – Joran Beasley Aug 14 '12 at 20:12
  • I bet you are not passing any command line arguments to the script... – Joran Beasley Aug 14 '12 at 20:22
  • I am passing the location of a png image as the argument. My issue is that I only have a folder full of PNG images and want to take this code and loop through the barcodes taking the values and making a CSV file. But for now I cant get one image to read. – thedemon Aug 14 '12 at 20:37

1 Answers1

0

It appears that my barcodes are just bad. Also to note that if the barcode is on a document with other data it wont pickup either unless I enable my webcam to scan the barcode. Seems like a limitation or just bad barcodes.

thedemon
  • 329
  • 1
  • 6
  • 19