Skip to content

Commit 75cf386

Browse files
authored
Update barcode_scanner.py
1 parent 046e3c0 commit 75cf386

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

barcode_scanner/barcode_scanner.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
1+
#!/usr/bin/python
12
from pyzbar.pyzbar import decode
23
from glob import glob
34
import cv2
45

6+
57
def barcode(decoded, image):
6-
imge = cv2.rectangle(image, (decoded.rect.left,
7-
decoded.rect.top), (decoded.rect.left + decoded.rect.width,
8-
decoded.rect.top + decoded.rect.height),
9-
color=(0, 255, 0), thickness=5)
8+
imge = cv2.rectangle(image, (decoded.rect.left, decoded.rect.top),
9+
(decoded.rect.left + decoded.rect.width,
10+
decoded.rect.top + decoded.rect.height),
11+
color=(0, 255, 0), thickness=5)
1012
return imge
1113

14+
1215
def scan(image):
1316
dcode = decode(image)
1417
for obj in dcode:
15-
print("Given barcode:", obj)
18+
print ('Given barcode:', obj)
1619
image = barcode(obj, image)
17-
print("Barcode Type:", obj.type)
18-
print("Scanned Data:", obj.data)
19-
print()
20+
print ('Barcode Type:', obj.type)
21+
print ('Scanned Data:', obj.data)
22+
print ()
2023
return image
2124

2225

23-
data = input("Enter the path of the barcode")
24-
dat = glob(data)
25-
for code in dat:
26+
dat = input('Enter the path of the barcode')
27+
data = glob(dat)
28+
for code in data:
2629
img = cv2.imread(code)
2730
img = scan(img)
28-
cv2.imshow("img", img)
31+
cv2.imshow('img', img)
2932
cv2.waitKey(0)

0 commit comments

Comments
 (0)