Created
November 20, 2020 09:25
-
-
Save yushulx/b02dbef9e73cceacebf822271d5c8beb to your computer and use it in GitHub Desktop.
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
from dbr import * | |
# Initialize Dynamsoft Barcode Reader | |
reader = BarcodeReader() | |
# Apply for a trial license: https://www.dynamsoft.com/customer/license/trialLicense | |
license_key = "LICENSE KEY" | |
reader.init_license(license_key) | |
def decodeframe(frame, left, top, right, bottom): | |
settings = reader.reset_runtime_settings() | |
settings = reader.get_runtime_settings() | |
settings.region_bottom = bottom | |
settings.region_left = left | |
settings.region_right = right | |
settings.region_top = top | |
settings.barcode_format_ids = EnumBarcodeFormat.BF_QR_CODE | |
settings.expected_barcodes_count = 1 | |
reader.update_runtime_settings(settings) | |
try: | |
text_results = reader.decode_buffer(frame) | |
if text_results != None: | |
return text_results[0] | |
except BarcodeReaderError as bre: | |
print(bre) | |
return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment