-
Notifications
You must be signed in to change notification settings - Fork 0
/
qr_code.py
54 lines (20 loc) · 907 Bytes
/
qr_code.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import cv2
from pyzbar import pyzbar
image = cv2.imread('test2.png', cv2.IMREAD_GRAYSCALE)
barcodes = pyzbar.decode(image)
if(len(barcodes) == 0):
print('qr code bulunamadı')
else:
for barcode in barcodes:
(x, y, w, h) = barcode.rect
rect = barcode.rect
center_x = int(x + w/2)
center_y = int(y + h/2)
center_qr = (int(rect.left + rect.width / 2), int(rect.top + rect.height / 2))
#cv2.rectangle(image, (rect.left, rect.top), (rect.left + rect.width, rect.top + rect.height), (255, 0, 255), 2)
#cv2.circle(image, center, 2, (255, 0, 255), 5)
qr_code_text = barcode.data.decode('utf-8')
print(qr_code_text)
cv2.imshow("QR Code Detection", image)
cv2.waitKey(0)
cv2.destroyAllWindows()