Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created October 23, 2020 08:20
Show Gist options
  • Save amankharwal/33242b5cbe6abd41c806ca71fbd07866 to your computer and use it in GitHub Desktop.
Save amankharwal/33242b5cbe6abd41c806ca71fbd07866 to your computer and use it in GitHub Desktop.
def read_barcodes(frame):
barcodes = pyzbar.decode(frame)
for barcode in barcodes:
x, y , w, h = barcode.rect
barcode_info = barcode.data.decode('utf-8')
cv2.rectangle(frame, (x, y),(x+w, y+h), (0, 255, 0), 2)
font = cv2.FONT_HERSHEY_DUPLEX
cv2.putText(frame, barcode_info, (x + 6, y - 6), font, 2.0, (255, 255, 255), 1)
with open("barcode_result.txt", mode ='w') as file:
file.write("Recognized Barcode:" + barcode_info)
return frame
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment