Skip to content

Commit b7e9fc2

Browse files
committed
ADD two new samples
For InitLicenseFromLTS and DecodeIntermediateResults
1 parent 5b51f9f commit b7e9fc2

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import os
2+
import sys
3+
import json
4+
from typing import List
5+
from dbr import *
6+
7+
# you can change the following variables' value to your own value.
8+
license_key = "Input your own license"
9+
#license_server = "Input the name/IP of the license server"
10+
json_file = r"Please input your own template path"
11+
image = r"Please input your own image path"
12+
13+
reader = BarcodeReader()
14+
15+
# Apply for a trial license: https://www.dynamsoft.com/CustomerPortal/Portal/Triallicense.aspx
16+
reader.init_license(license_key)
17+
18+
#reader.init_license_from_server(license_server, license_key)
19+
#license_content = reader.output_license_to_string()
20+
#reader.init_license_from_license_content(license_key, license_content)
21+
22+
settings = reader.get_runtime_settings()
23+
settings.intermediate_result_types = EnumIntermediateResultType.IRT_ORIGINAL_IMAGE | EnumIntermediateResultType.IRT_CONTOUR | EnumIntermediateResultType.IRT_BINARIZED_IMAGE
24+
settings.intermediate_result_saving_mode = EnumIntermediateResultSavingMode.IRSM_MEMORY
25+
error = reader.update_runtime_settings(settings)
26+
if error[0] != EnumErrorCode.DBR_OK:
27+
print(error[1])
28+
29+
try:
30+
text_results = reader.decode_file(image)
31+
32+
# if your python version is equal to or higher than python3.6, you can use the following code to replace the above code
33+
# text_results:List[TextResult] = reader.decode_file(image)
34+
35+
if text_results != None:
36+
for text_result in text_results:
37+
print("Barcode Format :")
38+
print(text_result.barcode_format_string)
39+
print("Barcode Text :")
40+
print(text_result.barcode_text)
41+
print("Localization Points : ")
42+
print(text_result.localization_result.localization_points)
43+
print("-------------")
44+
45+
intermediate_results = reader.get_all_intermediate_results()
46+
47+
text_results_2 = reader.decode_intermediate_results(intermediate_results)
48+
if text_results_2 != None:
49+
for text_result_2 in text_results_2:
50+
print("Barcode Format :")
51+
print(text_result_2.barcode_format_string)
52+
print("Barcode Text :")
53+
print(text_result_2.barcode_text)
54+
print("Localization Points : ")
55+
print(text_result_2.localization_result.localization_points)
56+
print("-------------")
57+
58+
except BarcodeReaderError as bre:
59+
print(bre)
60+
61+

samples/test_InitLicenseFromLTS.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import os
2+
import sys
3+
from dbr import *
4+
5+
reader = BarcodeReader()
6+
7+
connection_paras = BarcodeReader.init_lts_connection_parameters()
8+
# If DBR service is already built on your server, you can fill in the address of your server, or leave this property's default value.
9+
connection_paras.main_server_url = "Input your own server url"
10+
connection_paras.handshake_code = "Input your own handshake"
11+
connection_paras.deployment_type = EnumDMDeploymentType.DM_DT_DESKTOP
12+
connection_paras.uuid_generation_method = EnumDMUUIDGenerationMethod.DM_UUIDGM_RANDOM
13+
14+
try:
15+
error = BarcodeReader.init_licesne_from_lts(connection_paras)
16+
if error[0] != EnumErrorCode.DBR_OK:
17+
print(error[1])
18+
except BarcodeReaderError as bre:
19+
print(bre)
20+

0 commit comments

Comments
 (0)