-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqrcode_reader.py
More file actions
31 lines (26 loc) · 958 Bytes
/
Copy pathqrcode_reader.py
File metadata and controls
31 lines (26 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import cv2
import numpy as np
img = cv2.imread("89999900000000007940.png")
qrcode = cv2.QRCodeDetector()
data, bbox, rectified = qrcode.detectAndDecode(img)
if bbox is not None:
print(data)
# 取得座標的函式
# def boxSize(arr):
# global data
# box_roll = np.rollaxis(arr,1,0) # 轉置矩陣,把 x 放在同一欄,y 放在同一欄
# xmax = int(np.amax(box_roll[0])) # 取出 x 最大值
# xmin = int(np.amin(box_roll[0])) # 取出 x 最小值
# ymax = int(np.amax(box_roll[1])) # 取出 y 最大值
# ymin = int(np.amin(box_roll[1])) # 取出 y 最小值
# return (xmin,ymin,xmax,ymax)
# 如果 bbox 是 None 表示圖片中沒有 QRCode
# if bbox is not None:
# print(data)
# print(bbox)
# print(rectified)
# box = boxSize(bbox[0])
# cv2.rectangle(img,(box[0],box[1]),(box[2],box[3]),(0,0,255),5) # 畫矩形
# cv2.imshow('oxxostudio', img)
# cv2.waitKey(0)
# cv2.destroyAllWindows()