forked from owenlyn0123/python-gui-barcode-reader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
42 lines (33 loc) · 959 Bytes
/
test.py
File metadata and controls
42 lines (33 loc) · 959 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
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
'''
Usage:
test.py <image file>
'''
import cv2
from dbr import *
def main():
try:
file_path = sys.argv[1]
except:
print(__doc__)
return
image = cv2.imread(file_path)
reader = BarcodeReader()
try:
text_results = reader.decode_buffer(image)
if text_results != None:
for text_result in text_results:
print("Barcode Format : ")
print(text_result.barcode_format_string)
print("Barcode Text : ")
print(text_result.barcode_text)
print("Localization Points : ")
print(text_result.localization_result.localization_points)
print("Exception : ")
print(text_result.exception)
print("-------------")
except BarcodeReaderError as bre:
print(bre)
print('Quit the app.')
if __name__ == '__main__':
main()