Barcode-Detection-and-Decoding icon indicating copy to clipboard operation
Barcode-Detection-and-Decoding copied to clipboard

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

Open nivb52 opened this issue 4 years ago • 2 comments

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 ?

nivb52 avatar Aug 31 '21 09:08 nivb52

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.

nivb52 avatar Aug 31 '21 11:08 nivb52

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

SureshbabuAkash1999 avatar Dec 02 '21 05:12 SureshbabuAkash1999