Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/command-line/test_AppendTemplateFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def OutputRuntimeSettingsToFile(outputFileName):

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

Expand Down
52 changes: 32 additions & 20 deletions examples/command-line/test_DecodeFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,43 @@ def InitLicense(license):
dbr.InitLicense(license)

def DecodeFile(fileName):
results = dbr.DecodeFile(fileName)
textResults = results["TextResults"]
# intermediateResults = results["IntermediateResults"]
print(len(textResults))
for textResult in textResults:
print(textResult["BarcodeFormatString"])
print(textResult["BarcodeText"])
localizationResult = textResult["LocalizationResult"]
x1 = localizationResult["X1"]
y1 = localizationResult["Y1"]
x2 = localizationResult["X2"]
y2 = localizationResult["Y2"]
x3 = localizationResult["X3"]
y3 = localizationResult["Y3"]
x4 = localizationResult["X4"]
y4 = localizationResult["Y4"]
localizationPoints = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)]
print(localizationPoints)
try:
results = dbr.DecodeFile(fileName)
textResults = results["TextResults"]
resultsLength = len(textResults)
print("count: " + str(resultsLength))
if resultsLength != 0:
for textResult in textResults:
print(textResult["BarcodeFormatString"])
print(textResult["BarcodeText"])
localizationResult = textResult["LocalizationResult"]
x1 = localizationResult["X1"]
y1 = localizationResult["Y1"]
x2 = localizationResult["X2"]
y2 = localizationResult["Y2"]
x3 = localizationResult["X3"]
y3 = localizationResult["Y3"]
x4 = localizationResult["X4"]
y4 = localizationResult["Y4"]
localizationPoints = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)]
print(localizationPoints)
else :
print("No barcode detected")
except Exception as err:
print(err)


if __name__ == "__main__":

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

InitLicense(licenseKey)
errorCode = dbr.InitRuntimeSettingsByJsonFile(inputFileName)
if errorCode != 0:
print("Failed!")
else:
print("Successful")
DecodeFile(fileName)
2 changes: 1 addition & 1 deletion examples/command-line/test_DecodeFileInMemory.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def DecodeFileStream(imagePath):

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

InitLicense(licenseKey)
DecodeFileStream(fileName)
2 changes: 1 addition & 1 deletion examples/command-line/test_DecodeImageBufferByOpencv.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def DecodeBuffer(imageByOpencv):

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

InitLicense(licenseKey)
image = cv2.imread(fileName)
Expand Down
51 changes: 29 additions & 22 deletions examples/command-line/test_DecodeImagesInFolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


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

def dynamsoftReader (fileName, key):

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

# image = cv2.imread(fileName)
# results = dbr.DecodeBuffer(image, image.shape[0], image.shape[1], image.strides[0])

results = dbr.DecodeFile(fileName)

if results:
textResults = results["TextResults"]
for textResult in textResults:
print("BarcodeFormat : " + textResult["BarcodeFormatString"])
print("BarcodeText : " + textResult["BarcodeText"])
localizationResult = textResult["LocalizationResult"]
x1 = localizationResult["X1"]
y1 = localizationResult["Y1"]
x2 = localizationResult["X2"]
y2 = localizationResult["Y2"]
x3 = localizationResult["X3"]
y3 = localizationResult["Y3"]
x4 = localizationResult["X4"]
y4 = localizationResult["Y4"]
localizationPoints = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)]
print("LocalizationPoints : " + str(localizationPoints))
else:
print('No Barcode Found.')
try:
results = dbr.DecodeFile(fileName)

if results:
textResults = results["TextResults"]
textResultsLength = len(textResults)
if textResultsLength != 0:
for textResult in textResults:
print("BarcodeFormat : " + textResult["BarcodeFormatString"])
print("BarcodeText : " + textResult["BarcodeText"])
localizationResult = textResult["LocalizationResult"]
x1 = localizationResult["X1"]
y1 = localizationResult["Y1"]
x2 = localizationResult["X2"]
y2 = localizationResult["Y2"]
x3 = localizationResult["X3"]
y3 = localizationResult["Y3"]
x4 = localizationResult["X4"]
y4 = localizationResult["Y4"]
localizationPoints = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)]
print("LocalizationPoints : " + str(localizationPoints))
else:
print('No Barcode Found.')
else:
print('No Barcode Found.')
except Exception as err:
print(err)


for idx, img in enumerate(glob.glob(os.path.join(PATH_TO_IMAGEs, "*.*"))):
print(img)
print('Test', idx+1)
print(40*'#')
print('Dynamsoft Barcode Reader 7.2.0.09242:')
Expand Down
2 changes: 1 addition & 1 deletion examples/command-line/test_DecodeLocalVideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def read_barcode():
global results
video_width = 0
video_height = 0
testVideo = r"D:\Work\TestVideoOrImage\20191202145135.mp4"
testVideo = r"Please input your own local video path"

vc = cv2.VideoCapture(testVideo)
video_width = vc.get(cv2.CAP_PROP_FRAME_WIDTH)
Expand Down
2 changes: 1 addition & 1 deletion examples/command-line/test_DecodeLocalVideos.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
sys.path.append('../')

license_ = "Input your own license"
batch_folder_path = ""
batch_folder_path = "Input your own local videos library path"

# import config

Expand Down
4 changes: 2 additions & 2 deletions examples/command-line/test_InitRuntimeSettingsByFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def OutputRuntimeSettingsToFile(outputFileName):

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

InitLicense(licenseKey)
InitRuntimeSettingsByJsonFile(inputFileName)
Expand Down
Loading