pyxploiter / Barcode-Detection-and-Decoding

Barcode detection and decoding using openCV and Zbar.
Apache License 2.0
89 stars 37 forks source link

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

Open nivb52 opened 3 years ago

nivb52 commented 3 years ago

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 commented 3 years ago

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.

SureshbabuAkash1999 commented 3 years ago

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