Skip to content

Commit cc7d1b9

Browse files
update to v9.6.30
1 parent 3374bb3 commit cc7d1b9

12 files changed

+56
-43
lines changed

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ License Notice
22

33
This folder contains code samples ("Sample Code") for use with Dynamsoft Barcode Reader, a commercial software development kit licensed by Dynamsoft. The Sample Code may be modified and included in your end user software under the terms of the Dynamsoft Software License Agreement   https://www.dynamsoft.com/barcode-reader/license-agreement/ ("Commercial License"). Except as expressly stated in the Commercial License, no other rights are granted in the Sample Code. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44

5-
Copyright © 2003–2022 Dynamsoft. All rights reserved.
5+
Copyright © 2003–2023 Dynamsoft. All rights reserved.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ https://www.dynamsoft.com/barcode-reader/programming/python/?ver=latest&utm_sour
6060

6161
The barcode reader library requires a license to work. You can use the API `init_license` to initialize license key and activate the SDK.
6262

63-
These samples use a free public trial license which require network connection to function. You can request a 30-day free trial license key from <a href="https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python" target="_blank">Customer Portal</a> which works offline.
63+
These samples use a free public trial license which require network connection to function. You can request a 30-day free trial license key from <a href="https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=python" target="_blank">Customer Portal</a> which works offline.
6464

6565
## Contact Us
6666

samples/general-settings.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
try:
66
# 1.Initialize license.
77
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
8-
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
8+
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=python
99
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
1010
if error[0] != EnumErrorCode.DBR_OK:
1111
print("License error: "+ error[1])
1212

1313
# 2.Create an instance of Barcode Reader.
14-
reader = BarcodeReader()
15-
14+
reader = BarcodeReader.get_instance()
15+
if reader == None:
16+
raise BarcodeReaderError("Get instance failed")
1617
# There are two ways to configure runtime parameters. One is through PublicRuntimeSettings, the other is through parameters template.
1718
# 3. General settings (including barcode format, barcode count and scan region) through PublicRuntimeSettings
1819
# 3.1 Obtain current runtime settings of instance.
@@ -59,7 +60,6 @@
5960
print("No data detected.")
6061

6162
# 6.Release resource
62-
del reader
63-
63+
reader.recycle_instance()
6464
except BarcodeReaderError as bre:
6565
print(bre)

samples/hello-world.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
try:
66
# 1.Initialize license.
77
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
8-
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
8+
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=python
99
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
1010
if error[0] != EnumErrorCode.DBR_OK:
1111
print("License error: "+ error[1])

samples/image-decoding.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ def choose_number() -> int:
2626
try:
2727
# 1.Initialize license.
2828
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
29-
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
29+
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=python
3030
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
3131
if error[0] != EnumErrorCode.DBR_OK:
3232
print("License error: "+ error[1])
3333

3434
# 2.Create an instance of Barcode Reader.
35-
dbr = BarcodeReader()
36-
35+
dbr = BarcodeReader.get_instance()
36+
if dbr == None :
37+
raise BarcodeReaderError("Get instance failed")
38+
3739
# Replace by your own image path
3840
image_path = os.path.dirname(os.path.abspath(__file__)) + os.path.sep + "../images/AllSupportedBarcodeTypes.png"
3941

@@ -87,6 +89,6 @@ def choose_number() -> int:
8789
i = i+1
8890
else:
8991
print("No data detected.")
90-
92+
dbr.recycle_instance()
9193
except BarcodeReaderError as bre:
9294
print(bre)

samples/performance/accuracy-first-settings.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ def output_results(results:TextResult):
4848
try:
4949
# 1.Initialize license.
5050
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
51-
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
51+
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=python
5252
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
5353
if error[0] != EnumErrorCode.DBR_OK:
5454
print("License error: "+ error[1])
5555

5656
# 2.Create an instance of Barcode Reader.
57-
dbr = BarcodeReader()
58-
57+
dbr = BarcodeReader.get_instance()
58+
if dbr == None:
59+
raise BarcodeReaderError("Get instance failed")
5960
# Replace by your own image path
6061
image_path = os.path.dirname(os.path.abspath(__file__)) + os.path.sep + "../../images/AllSupportedBarcodeTypes.png"
6162

@@ -81,6 +82,7 @@ def output_results(results:TextResult):
8182

8283
# 5.b Output the barcode format and barcode text.
8384
output_results(results)
84-
85+
86+
dbr.recycle_instance()
8587
except BarcodeReaderError as bre:
8688
print(bre)

samples/performance/batch-decode.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
try:
88
# 1.Initialize license.
99
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
10-
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
10+
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=python
1111
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
1212
if error[0] != EnumErrorCode.DBR_OK:
1313
print("License error: "+ error[1])
1414

1515
# 2.Create an instance of Barcode Reader.
16-
reader = BarcodeReader()
17-
16+
reader = BarcodeReader.get_instance()
17+
if reader == None :
18+
raise BarcodeReaderError("Get instance failed")
1819
# Replace by your own image path
1920
image_folder = os.path.dirname(os.path.abspath(__file__)) + os.path.sep + "../../images"
2021

@@ -34,6 +35,6 @@
3435
print("-------------")
3536

3637
print(40*'#')
37-
38+
reader.recycle_instance()
3839
except BarcodeReaderError as bre:
3940
print(bre)

samples/performance/read-rate-first-settings.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,15 @@ def output_results(results:TextResult):
7575
try:
7676
# 1.Initialize license.
7777
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
78-
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
78+
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=python
7979
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
8080
if error[0] != EnumErrorCode.DBR_OK:
8181
print("License error: "+ error[1])
8282

8383
# 2.Create an instance of Barcode Reader.
84-
dbr = BarcodeReader()
85-
84+
dbr = BarcodeReader.get_instance()
85+
if dbr == None :
86+
raise BarcodeReaderError("Get instance failed")
8687
# Replace by your own image path
8788
image_path = os.path.dirname(os.path.abspath(__file__)) + os.path.sep + "../../images/AllSupportedBarcodeTypes.png"
8889

@@ -108,6 +109,6 @@ def output_results(results:TextResult):
108109

109110
# 5.b Output the barcode format and barcode text.
110111
output_results(results)
111-
112+
dbr.recycle_instance()
112113
except BarcodeReaderError as bre:
113114
print(bre)

samples/performance/speed-first-settings.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,15 @@ def output_results(results:TextResult):
8181
try:
8282
# 1.Initialize license.
8383
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
84-
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
84+
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=python
8585
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
8686
if error[0] != EnumErrorCode.DBR_OK:
8787
print("License error: "+ error[1])
8888

8989
# 2.Create an instance of Barcode Reader.
90-
dbr = BarcodeReader()
91-
90+
dbr = BarcodeReader.get_instance()
91+
if dbr == None:
92+
raise BarcodeReaderError("Get instance failed")
9293
# Replace by your own image path
9394
image_path = os.path.dirname(os.path.abspath(__file__)) + os.path.sep + "../../images/AllSupportedBarcodeTypes.png"
9495

@@ -115,6 +116,8 @@ def output_results(results:TextResult):
115116

116117
# 5.b Output the barcode format and barcode text.
117118
output_results(results)
118-
119+
120+
dbr.recycle_instance()
121+
119122
except BarcodeReaderError as bre:
120123
print(bre)

samples/use-case/read-dpm-barcode.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ def output_results(results:TextResult):
1818
try:
1919
# 1.Initialize license.
2020
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
21-
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
21+
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=python
2222
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
2323
if error[0] != EnumErrorCode.DBR_OK:
2424
print("License error: "+ error[1])
2525

2626
# 2.Create an instance of Barcode Reader.
27-
dbr = BarcodeReader()
28-
27+
dbr = BarcodeReader.get_instance()
28+
if dbr == None:
29+
raise BarcodeReaderError("Get instance failed")
2930
# 3.Config runtime settings for dmp
3031
sts = dbr.get_runtime_settings()
3132

@@ -53,6 +54,7 @@ def output_results(results:TextResult):
5354
# 4 Output the barcode format and barcode text.
5455
output_results(results)
5556

56-
57+
dbr.recycle_instance()
58+
5759
except BarcodeReaderError as bre:
5860
print(bre)

samples/video-decoding-for-picamera.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,17 @@ def read_barcode():
162162

163163
# Initialize license.
164164
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
165-
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
165+
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=python
166166
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
167167
if error[0] != EnumErrorCode.DBR_OK:
168168
print("License error: "+ error[1])
169169

170-
reader = BarcodeReader()
170+
reader = BarcodeReader.get_instance()
171+
if reader != None:
172+
error = reader.init_runtime_settings_with_file(json_file)
173+
if error[0] != EnumErrorCode.DBR_OK:
174+
print(error[1])
171175

172-
error = reader.init_runtime_settings_with_file(json_file)
173-
if error[0] != EnumErrorCode.DBR_OK:
174-
print(error[1])
175-
176-
read_barcode()
176+
read_barcode()
177+
reader.recycle_instance()
177178
print("-------------------over------------------------")

samples/video-decoding.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ def decode_video():
5353

5454
windowName = "Video Barcode Reader"
5555

56-
reader = BarcodeReader()
57-
56+
reader = BarcodeReader.get_instance()
57+
if reader == None:
58+
raise BarcodeReaderError("Get instance failed")
5859
parameters = reader.init_frame_decoding_parameters()
5960
parameters.max_queue_length = 30
6061
parameters.max_result_queue_length = 30
@@ -96,7 +97,7 @@ def decode_video():
9697

9798
reader.stop_video_mode()
9899
cv2.destroyWindow(windowName)
99-
100+
reader.recycle_instance()
100101

101102
if __name__ == "__main__":
102103

@@ -105,7 +106,7 @@ def decode_video():
105106
try:
106107
# Initialize license.
107108
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
108-
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
109+
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=python
109110
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
110111
if error[0] != EnumErrorCode.DBR_OK:
111112
print("License error: "+ error[1])

0 commit comments

Comments
 (0)