Skip to content

Instantly share code, notes, and snippets.

@yushulx
Created November 20, 2020 09:25
Show Gist options
  • Save yushulx/b02dbef9e73cceacebf822271d5c8beb to your computer and use it in GitHub Desktop.
Save yushulx/b02dbef9e73cceacebf822271d5c8beb to your computer and use it in GitHub Desktop.
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