|
Dynamsoft's Barcode Reader SDK enables you to efficiently embed barcode reading functionality in your web, desktop or mobile application using just a few lines of code. Saving you months of added development time and resources, our SDK can create high-speed and reliable barcode scanner software applications to meet your business needs.
Dynamsoft Barcode Reader's Python Edition comes with all the general features of Dynamsoft Barcode Reader, bringing convenience for customers who develop in Python. In addition, you could refer to the Python samples available in our Github when building your own application. If you have any inquiries about our product, please contact us at support@dynamsoft.com. If you need more information, please check out our documentation site.
Windows x64
Linux(x64, ARM32, ARM64)
macOS(10.15+)
Python3.6
Python3.7
Python3.8
Python3.9
pip install dbr or pip3 install dbr
We support all major barcodes symbologies across a variety of industries such as government, finance, retail, warehouse inventory, and healthcare.
import os
import sys
import cv2
import json
from typing import List
from dbr import *
# you can replace the following variables' value with yours.
license_key = "Input your own license"
#license_server = "Input the name/IP of the license server"
json_file = r"Please input your own template path"
image = r"Please input your own image path"
## The code snippet below shows how to use the full license in DBR 8.x:
# connection_paras = BarcodeReader.init_lts_connection_parameters()
## If DBR service is already built on your server, you can fill in the address of your server, or leave this property's default value.
# connection_paras.main_server_url = "Input your own server url"
# connection_paras.handshake_code = "Input your own handshake"
# connection_paras.deployment_type = EnumDMDeploymentType.DM_DT_DESKTOP
# connection_paras.uuid_generation_method = EnumDMUUIDGenerationMethod.DM_UUIDGM_RANDOM
# try:
# error = BarcodeReader.init_license_from_lts(connection_paras)
# if error[0] != EnumErrorCode.DBR_OK:
# print(error[1])
# except BarcodeReaderError as bre:
# print(bre)
reader = BarcodeReader()
reader.init_license(license_key)
#reader.init_license_from_server(license_server, license_key)
#license_content = reader.output_license_to_string()
#reader.init_license_from_license_content(license_key, license_content)
error = reader.init_runtime_settings_with_file(json_file)
if error[0] != EnumErrorCode.DBR_OK:
print(error[1])
if sys.version_info.major == 3 and sys.version_info.minor >= 6:
try:
text_results:List[TextResult] = reader.decode_file(image)
if text_results != None:
for text_result in text_results:
print("Barcode Format : ")
print(text_result.barcode_format_string)
print("Barcode Text : ")
print(text_result.barcode_text)
print("Localization Points : ")
print(text_result.localization_result.localization_points)
print("Exception : ")
print(text_result.exception)
print("-------------")
except BarcodeReaderError as bre:
print(bre)
else:
try:
text_results = reader.decode_file(image)
if text_results != None:
for text_result in text_results:
print("Barcode Format : ")
print(text_result.barcode_format_string)
print("Barcode Text :")
print(text_result.barcode_text)
print("Localization Points : ")
print(text_result.localization_result.localization_points)
print("Exception : ")
print(text_result.exception)
print("-------------")
except BarcodeReaderError as bre:
print(bre)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。