Skip to content

Commit 37b2299

Browse files
committed
Update C++ SDK to dbr v9.4
1 parent ffb3e8c commit 37b2299

17 files changed

+38
-36
lines changed

examples/camera/camera_async_api.py

+37-35
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,49 @@
11
import barcodeQrSDK
22
import numpy as np
3-
4-
# set license
5-
barcodeQrSDK.initLicense("DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ==")
6-
7-
# initialize barcode scanner
8-
scanner = barcodeQrSDK.createInstance()
3+
import cv2
94

105
g_results = None
116

127
def callback(results):
13-
global g_results
8+
global g_results
149
g_results = results
15-
16-
import cv2
17-
scanner.addAsyncListener(callback)
1810

19-
cap = cv2.VideoCapture(0)
20-
while True:
21-
ret, image = cap.read()
22-
if image is not None:
23-
scanner.decodeMatAsync(image)
24-
25-
if g_results != None:
26-
for result in g_results:
27-
print("barcode format: " + result.format)
28-
print("barcode value: " + result.text)
29-
x1 = result.x1
30-
y1 = result.y1
31-
x2 = result.x2
32-
y2 = result.y2
33-
x3 = result.x3
34-
y3 = result.y3
35-
x4 = result.x4
36-
y4 = result.y4
37-
38-
cv2.drawContours(image, [np.int0([(x1, y1), (x2, y2), (x3, y3), (x4, y4)])], 0, (0, 255, 0), 2)
39-
11+
def run():
12+
# set license
13+
barcodeQrSDK.initLicense("DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ==")
4014

41-
cv2.imshow('Barcode QR Code Scanner', image)
42-
ch = cv2.waitKey(1)
43-
if ch == 27:
44-
break
15+
# initialize barcode scanner
16+
scanner = barcodeQrSDK.createInstance()
17+
scanner.addAsyncListener(callback)
4518

19+
cap = cv2.VideoCapture(0)
20+
while True:
21+
ret, image = cap.read()
22+
if image is not None:
23+
scanner.decodeMatAsync(image)
24+
25+
if g_results != None:
26+
for result in g_results:
27+
print("barcode format: " + result.format)
28+
print("barcode value: " + result.text)
29+
x1 = result.x1
30+
y1 = result.y1
31+
x2 = result.x2
32+
y2 = result.y2
33+
x3 = result.x3
34+
y3 = result.y3
35+
x4 = result.x4
36+
y4 = result.y4
37+
38+
cv2.drawContours(image, [np.int0([(x1, y1), (x2, y2), (x3, y3), (x4, y4)])], 0, (0, 255, 0), 2)
39+
4640

41+
cv2.imshow('Barcode QR Code Scanner', image)
42+
ch = cv2.waitKey(1)
43+
if ch == 27:
44+
break
45+
46+
scanner.clearAsyncListener()
4747

48+
if __name__ == '__main__':
49+
run()

0 commit comments

Comments
 (0)