Created
August 27, 2021 08:54
-
-
Save songwutk/ce27e4284df4bab5e2fac611ec916efd to your computer and use it in GitHub Desktop.
Python scan QR code and OCR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, cv2 # opencv | |
from PIL import Image # Python Imaging Library | |
from pyzbar.pyzbar import decode # python zbarcode | |
fdemo=sys.argv[1] # get filename from command line | |
img=Image.open(fdemo) # open file | |
width, height=1800,400 # specify crop img size | |
x ,y = 50, 10 # start coordinate | |
area=(x,y,x+width,y+height) | |
cropped_img=img.crop(area) # crop | |
cropped_img.save('opt.jpg') # save to new file | |
data = decode(cropped_img) # QR code decoder | |
print(data) # print decode data from QR Code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment