-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathtest.py
76 lines (65 loc) · 1.79 KB
/
test.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import cv2
import barcodeQrSDK
from time import sleep
file_path = "images/test.png"
# set license
ret = barcodeQrSDK.initLicense(
"DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ==")
print('initLicense: {}'.format(ret))
# initialize barcode reader
reader = barcodeQrSDK.createInstance()
# Get runtime settings
settings = reader.getParameters()
print(reader.getParameters())
# Set runtime settings
ret = reader.setParameters(settings)
print(ret)
# decodeFile()
results, elapsed_time = reader.decodeFile(file_path)
print('Elapsed time: ' + str(elapsed_time) + 'ms')
for result in results:
print(result.format)
print(result.text)
print(result.x1)
print(result.y1)
print(result.x2)
print(result.y2)
print(result.x3)
print(result.y3)
print(result.x4)
print(result.y4)
# decodeMat()
image = cv2.imread(file_path)
results, elapsed_time = reader.decodeMat(image)
print('Elapsed time: ' + str(elapsed_time) + 'ms')
for result in results:
print(result.format)
print(result.text)
print(result.x1)
print(result.y1)
print(result.x2)
print(result.y2)
print(result.x3)
print(result.y3)
print(result.x4)
print(result.y4)
# decodeMatAsync()
print('')
print('Test decodeMatAsync()')
def callback(results, elapsed_time):
print('Elapsed time: ' + str(elapsed_time) + 'ms')
for result in results:
print(result.format)
print(result.text)
print(result.x1)
print(result.y1)
print(result.x2)
print(result.y2)
print(result.x3)
print(result.y3)
print(result.x4)
print(result.y4)
image = cv2.imread(file_path)
reader.addAsyncListener(callback)
reader.decodeMatAsync(image)
sleep(1)