Skip to content

Commit 94f69b8

Browse files
authored
Merge pull request #7 from dynamsoft-dbr/Python-DBR7.2.2-Zoro
Python dbr7.2.2 zoro
2 parents 79131fb + a9fb0e2 commit 94f69b8

9 files changed

Lines changed: 565 additions & 118 deletions

examples/command-line/test_AppendTemplateFile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ def OutputRuntimeSettingsToFile(outputFileName):
3535

3636
#you can change the following five variables' value to your own value.
3737
licenseKey = "Input your own license"
38-
inputFileName = r"D:\Work\InputFile\Input20191206-1.json"
39-
appendFileName = r"D:\Work\InputFile\Input20191206-2.json"
40-
outputFileName = r"D:\Work\OutputFile\Output20191206-2.json"
38+
inputFileName = r"Please input your own template path"
39+
appendFileName = r"Please input your own template path"
40+
outputFileName = r"Please input your own output template path"
4141
#conflictMode has two optional values : dbr.CM_OVERWRITE and dbr.CM_IGNORE
4242
conflictMode = dbr.CM_OVERWRITE
4343

examples/command-line/test_DecodeFile.py

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,43 @@ def InitLicense(license):
99
dbr.InitLicense(license)
1010

1111
def DecodeFile(fileName):
12-
results = dbr.DecodeFile(fileName)
13-
textResults = results["TextResults"]
14-
# intermediateResults = results["IntermediateResults"]
15-
print(len(textResults))
16-
for textResult in textResults:
17-
print(textResult["BarcodeFormatString"])
18-
print(textResult["BarcodeText"])
19-
localizationResult = textResult["LocalizationResult"]
20-
x1 = localizationResult["X1"]
21-
y1 = localizationResult["Y1"]
22-
x2 = localizationResult["X2"]
23-
y2 = localizationResult["Y2"]
24-
x3 = localizationResult["X3"]
25-
y3 = localizationResult["Y3"]
26-
x4 = localizationResult["X4"]
27-
y4 = localizationResult["Y4"]
28-
localizationPoints = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)]
29-
print(localizationPoints)
12+
try:
13+
results = dbr.DecodeFile(fileName)
14+
textResults = results["TextResults"]
15+
resultsLength = len(textResults)
16+
print("count: " + str(resultsLength))
17+
if resultsLength != 0:
18+
for textResult in textResults:
19+
print(textResult["BarcodeFormatString"])
20+
print(textResult["BarcodeText"])
21+
localizationResult = textResult["LocalizationResult"]
22+
x1 = localizationResult["X1"]
23+
y1 = localizationResult["Y1"]
24+
x2 = localizationResult["X2"]
25+
y2 = localizationResult["Y2"]
26+
x3 = localizationResult["X3"]
27+
y3 = localizationResult["Y3"]
28+
x4 = localizationResult["X4"]
29+
y4 = localizationResult["Y4"]
30+
localizationPoints = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)]
31+
print(localizationPoints)
32+
else :
33+
print("No barcode detected")
34+
except Exception as err:
35+
print(err)
3036

3137

3238
if __name__ == "__main__":
3339

34-
#you can change the following two variables' value to your own value.
40+
#you can change the following three variables' value to your own value.
3541
licenseKey = "Input your own license"
36-
fileName = r"D:\Work\Python\python-barcode\images\test.jpg"
42+
fileName = r"Please input your own image path"
43+
inputFileName = r"Please input your own template path"
3744

3845
InitLicense(licenseKey)
46+
errorCode = dbr.InitRuntimeSettingsByJsonFile(inputFileName)
47+
if errorCode != 0:
48+
print("Failed!")
49+
else:
50+
print("Successful")
3951
DecodeFile(fileName)

examples/command-line/test_DecodeFileInMemory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def DecodeFileStream(imagePath):
3535

3636
#you can change the following two variables' value to your own value.
3737
licenseKey = "Input your own license"
38-
fileName = r"D:\Work\Python\python-barcode\images\test.jpg"
38+
fileName = r"Please input your own image path"
3939

4040
InitLicense(licenseKey)
4141
DecodeFileStream(fileName)

examples/command-line/test_DecodeImageBufferByOpencv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def DecodeBuffer(imageByOpencv):
3333

3434
#you can change the following two variables' value to your own value.
3535
licenseKey = "Input your own license"
36-
fileName = r"D:\Work\Python\python-barcode\images\test.jpg"
36+
fileName = r"Please input your own image path"
3737

3838
InitLicense(licenseKey)
3939
image = cv2.imread(fileName)

examples/command-line/test_DecodeImagesInFolder.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
LICENSE_KEY = "Input your own license"
12-
PATH_TO_IMAGEs = r'D:\DBR\DBR7.2.2\DLL\Images'
12+
PATH_TO_IMAGEs = r"Please input your own images library path"
1313

1414
def dynamsoftReader (fileName, key):
1515

@@ -19,30 +19,37 @@ def dynamsoftReader (fileName, key):
1919

2020
# image = cv2.imread(fileName)
2121
# results = dbr.DecodeBuffer(image, image.shape[0], image.shape[1], image.strides[0])
22-
23-
results = dbr.DecodeFile(fileName)
24-
25-
if results:
26-
textResults = results["TextResults"]
27-
for textResult in textResults:
28-
print("BarcodeFormat : " + textResult["BarcodeFormatString"])
29-
print("BarcodeText : " + textResult["BarcodeText"])
30-
localizationResult = textResult["LocalizationResult"]
31-
x1 = localizationResult["X1"]
32-
y1 = localizationResult["Y1"]
33-
x2 = localizationResult["X2"]
34-
y2 = localizationResult["Y2"]
35-
x3 = localizationResult["X3"]
36-
y3 = localizationResult["Y3"]
37-
x4 = localizationResult["X4"]
38-
y4 = localizationResult["Y4"]
39-
localizationPoints = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)]
40-
print("LocalizationPoints : " + str(localizationPoints))
41-
else:
42-
print('No Barcode Found.')
22+
try:
23+
results = dbr.DecodeFile(fileName)
24+
25+
if results:
26+
textResults = results["TextResults"]
27+
textResultsLength = len(textResults)
28+
if textResultsLength != 0:
29+
for textResult in textResults:
30+
print("BarcodeFormat : " + textResult["BarcodeFormatString"])
31+
print("BarcodeText : " + textResult["BarcodeText"])
32+
localizationResult = textResult["LocalizationResult"]
33+
x1 = localizationResult["X1"]
34+
y1 = localizationResult["Y1"]
35+
x2 = localizationResult["X2"]
36+
y2 = localizationResult["Y2"]
37+
x3 = localizationResult["X3"]
38+
y3 = localizationResult["Y3"]
39+
x4 = localizationResult["X4"]
40+
y4 = localizationResult["Y4"]
41+
localizationPoints = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)]
42+
print("LocalizationPoints : " + str(localizationPoints))
43+
else:
44+
print('No Barcode Found.')
45+
else:
46+
print('No Barcode Found.')
47+
except Exception as err:
48+
print(err)
4349

4450

4551
for idx, img in enumerate(glob.glob(os.path.join(PATH_TO_IMAGEs, "*.*"))):
52+
print(img)
4653
print('Test', idx+1)
4754
print(40*'#')
4855
print('Dynamsoft Barcode Reader 7.2.0.09242:')

examples/command-line/test_DecodeLocalVideo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def read_barcode():
2323
global results
2424
video_width = 0
2525
video_height = 0
26-
testVideo = r"D:\Work\TestVideoOrImage\20191202145135.mp4"
26+
testVideo = r"Please input your own local video path"
2727

2828
vc = cv2.VideoCapture(testVideo)
2929
video_width = vc.get(cv2.CAP_PROP_FRAME_WIDTH)

examples/command-line/test_DecodeLocalVideos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
sys.path.append('../')
99

1010
license_ = "Input your own license"
11-
batch_folder_path = ""
11+
batch_folder_path = "Input your own local videos library path"
1212

1313
# import config
1414

examples/command-line/test_InitRuntimeSettingsByFile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def OutputRuntimeSettingsToFile(outputFileName):
2424

2525
#you can change the following three variables' value to your own value.
2626
licenseKey = "Input your own license"
27-
inputFileName = r"D:\Work\InputFile\Input20191206-1.json"
28-
outputFileName = r"D:\Work\OutputFile\Output20191206-1.json"
27+
inputFileName = r"Please input your own template path"
28+
outputFileName = r"Please input your own output template path"
2929

3030
InitLicense(licenseKey)
3131
InitRuntimeSettingsByJsonFile(inputFileName)

0 commit comments

Comments
 (0)