-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsourcecode.py
More file actions
32 lines (25 loc) · 909 Bytes
/
sourcecode.py
File metadata and controls
32 lines (25 loc) · 909 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
32
#input your code
import cv2
import pyzbar.pyzbar as pyzbar
import numpy as np
def decode(image):
for object in pyzbar.decode(image):
print("DATA : ", object.data, '\n')
return pyzbar.decode(image)
def display(image, decoded_objects):
for decode_object in decoded_objects:
points = decode_object.polygon
if len(points) > 4:
convex_hull = cv2.convexHull(np.array([point for point in points], dtype=np.float32))
convex_hull = list(map(tuple, np.squeeze(convex_hull)))
else:
convex_hull = points
n = len(convex_hull)
for j in range(0, n):
cv2.line(image, convex_hull[j], convex_hull[(j + 1) % n], (255, 0, 0), 3)
cv2.imshow("Result", image)
cv2.waitKey(0)
if __name__ == '__main__':
image = cv2. imread('QR_gachonuniversity.jpg')
decoded = decode(image)
display(image, decoded)