Python recognizes QR codes. Get the webpage link in the QR code

Method 1:
#Read image

imgs = cv2.imread(‘图片地址')

#decoding

QR_code = decode(imgs)

The decode function here needs to be imported additionally, from pyzbar.pyzbar import decode, to import the decode package, you need to download the dynamic link library: https://download.microsoft.com/download/F/3/5/F3500770-8A08-488E-94B6-17A1E1DD526F/vcredist_x64.exe
output display:

[Decoded(data=b'http://weixin.qq.com/q/02WVJAQnled7i1y9d7hA18', type='QRCODE', rect=Rect(left=568, top=307, width=256, height=256), polygon=[Point(x=568, y=307), Point(x=568, y=563), Point(x=824, y=563), Point(x=824, y=307)], quality=1, orientation='UP')]

The function will return us the webpage link contained in the QR code and the parameters of the QR code.
Here, the webpage link in data cannot be returned directly, because it is stored in the form of bytes.

for i in QR_code:
    QR_data = i.data.decode('utf-8')

Method 2:
I learned it in a teaching video

imgs = cv2.imread(图片地址)
qrcode = cv2.QRCodeDetector()
result,point,code = qrcode.detectAndDecode(imgs)
qrcode.detectAndDecode(imgs)
 print(result,point,code)

The returned result is the webpage address, the other two are the vertex parameters of the QR code, and the latter two parameters return two matrices

Guess you like

Origin blog.csdn.net/weixin_44052130/article/details/130662018