pyxploiter / Barcode-Detection-and-Decoding

Barcode detection and decoding using openCV and Zbar.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use pyzbar insted of zbar directly (which is python 2)

nivb52 opened this issue · comments

commented

One File in the repository is in python 2 and the other in python 3
How do you suppose to run in in Linux environment ?

the file detect_barcode_opencv.py is in python 3
and the file barcode_detect_and_decode.py is in python 2, due to the zbar dependency.
How do you use this library in production environment ?

commented

I changed the file and the barcode function as the following

from pyzbar.pyzbar import decode
.
.
.


def decodeBarcode(image_read):
	barcodes = decode(image_read)

	for barcode in barcodes:
		barcode_data = barcode.data.decode("utf-8")
		barcode_type = barcode.type
		# (x, y, w, h) = barcode.rect  #to get the barcode locations
		print("[INFO] Found {} barcode: {}".format(barcode_type, barcode_data ))
		# print("Location x {} y {} w {} h {}".format(x, y, w, h))
	print('-----------------------------------------------------------------------')
	del(image_read)

variable image_read is as the follow:

image_read = cv2.imread(args["image"],0) 

but you can use also the image you get after the function preprocess.

Can we use the same method for live video as well?