-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96b1b19
commit 23f709c
Showing
26 changed files
with
278 additions
and
1,236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from dynamsoft_barcode_reader_bundle import * | ||
import os | ||
|
||
if __name__ == '__main__': | ||
# Initialize license. | ||
# You can request and extend a trial license from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python | ||
# The string 'DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9' here is a free public trial license. Note that network connection is required for this license to work. | ||
errorCode, errorMsg = LicenseManager.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9") | ||
if errorCode != EnumErrorCode.EC_OK and errorCode != EnumErrorCode.EC_LICENSE_CACHE_USED: | ||
print("License initialization failed: ErrorCode:", errorCode, ", ErrorString:", errorMsg) | ||
else: | ||
cvr = CaptureVisionRouter() | ||
result = cvr.capture("../Images/GeneralBarcodes.png", EnumPresetTemplate.PT_READ_BARCODES.value) | ||
if result.get_error_code() != EnumErrorCode.EC_OK: | ||
print("Error:", result.get_error_code(), result.get_error_string()) | ||
barcode_result = result.get_decoded_barcodes_result() | ||
if barcode_result is None or barcode_result.get_items() == 0: | ||
print("No barcode detected.") | ||
else: | ||
items = barcode_result.get_items() | ||
print("Decoded", len(items), "barcodes.") | ||
for index,item in enumerate(items): | ||
print("Result", index+1) | ||
print("Barcode Format:", item.get_format_string()) | ||
print("Barcode Text:", item.get_text()) | ||
input("Press Enter to quit...") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from dynamsoft_barcode_reader_bundle import * | ||
import os | ||
|
||
class MyCapturedResultReceiver(CapturedResultReceiver): | ||
|
||
def __init__(self) -> None: | ||
super().__init__() | ||
def on_decoded_barcodes_received(self, result: "DecodedBarcodesResult") -> None: | ||
tag = result.get_original_image_tag() | ||
if isinstance(tag, FileImageTag): | ||
print("File:", tag.get_file_path()) | ||
if result.get_error_code() != EnumErrorCode.EC_OK: | ||
print("Error:", result.get_error_string()) | ||
else: | ||
items = result.get_items() | ||
print("Detected", len(items), "barcodes.") | ||
for index, item in enumerate(items): | ||
print("Result", index+1) | ||
print("Barcode Format:", item.get_format_string()) | ||
print("Barcode Text:", item.get_text()) | ||
|
||
class MyImageSourceStateListener(ImageSourceStateListener): | ||
def __init__(self, cvr:CaptureVisionRouter) -> None: | ||
super().__init__() | ||
self.cvr = cvr | ||
def on_image_source_state_received(self, state: int) -> None: | ||
if state == EnumImageSourceState.ISS_EXHAUSTED: | ||
if self.cvr != None: | ||
self.cvr.stop_capturing() | ||
if __name__ == '__main__': | ||
# Initialize license. | ||
# You can request and extend a trial license from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python | ||
# The string 'DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9' here is a free public trial license. Note that network connection is required for this license to work. | ||
errorCode, errorMsg = LicenseManager.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9") | ||
if errorCode != EnumErrorCode.EC_OK and errorCode != EnumErrorCode.EC_LICENSE_CACHE_USED: | ||
print("License initialization failed: ErrorCode:", errorCode, ", ErrorString:", errorMsg) | ||
else: | ||
cvr = CaptureVisionRouter() | ||
|
||
fetcher = DirectoryFetcher() | ||
fetcher.set_directory("../Images") | ||
cvr.set_input(fetcher) | ||
|
||
receiver = MyCapturedResultReceiver() | ||
cvr.add_result_receiver(receiver) | ||
|
||
listener = MyImageSourceStateListener(cvr) | ||
cvr.add_image_source_state_listener(listener) | ||
|
||
errorCode, errorMsg = cvr.start_capturing("", True) | ||
if errorCode != EnumErrorCode.EC_OK: | ||
print("error:", errorMsg) | ||
input("Press Enter to quit...") |
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.