Skip to content

Commit

Permalink
Merge pull request #40 from Dynamsoft/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
DMGithubPublisher authored Mar 31, 2022
2 parents 9e79ddc + 8821ffd commit baba6cb
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 70 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ License Notice

This folder contains code samples ("Sample Code") for use with Dynamsoft Barcode Reader, a commercial software development kit licensed by Dynamsoft. The Sample Code may be modified and included in your end user software under the terms of the Dynamsoft Software License Agreement   https://www.dynamsoft.com/barcode-reader/license-agreement/ (“Commercial License”). Except as expressly stated in the Commercial License, no other rights are granted in the Sample Code. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

Copyright © 2003–2021 Dynamsoft. All rights reserved.
Copyright © 2003–2022 Dynamsoft. All rights reserved.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Dynamsoft Barcode Reader samples for Python edition

[![Current version number](https://img.shields.io/pypi/v/dbr?color=orange)](https://pypi.org/project/dbr/)
[![Supported Python versions](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8%20%7C%203.9-blue)](https://www.python.org/downloads/)
[![Supported Python versions](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8%20%7C%203.9%20%7C%203.10-blue)](https://www.python.org/downloads/)
[![PyPI downloads](https://img.shields.io/pypi/dm/dbr)](https://pypistats.org/packages/dbr)

![Dynamsoft](https://dynamsoft.github.io/styleguide/assets/images/icons/dynamsoft_logos/dynamsoft_logo_original.png "Dynamsoft")
Expand All @@ -23,6 +23,7 @@ This repository contains multiple samples that demonstrates how to use the [Dyna
- Python3.7
- Python3.8
- Python3.9
- Python3.10

## Installation

Expand All @@ -49,8 +50,13 @@ https://www.dynamsoft.com/barcode-reader/programming/python/?ver=latest&utm_sour

## License

- If you want to use an offline license, please contact [Dynamsoft Support](https://www.dynamsoft.com/company/contact/)
- You can also request a 30-day trial license in the [customer portal](https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python)
The library requires a license to work, you use the API init_license to initialize license key and activate the SDK.

These samples use a <a href="https://www.dynamsoft.com/license-server/docs/about/terms.html?ver=latest&product=dbr&utm_source=samples&package=python#public-trial-license" target="_blank">free public trial license</a>. Note that network connection is required for this license to work.

You can also request a 30-day trial license from <a href="https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python" target="_blank">Customer Portal</a>

For more information, please refer to https://www.dynamsoft.com/license-server/docs/about/licensefaq.html.

## Contact Us

Expand Down
7 changes: 2 additions & 5 deletions samples/general-settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
if __name__ == "__main__":
try:
# 1.Initialize license.
# The organization id 200001 here will grant you a free public trial license. Note that network connection is required for this license to work.
# If you want to use an offline license, please contact Dynamsoft Support: https://www.dynamsoft.com/company/contact/
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
para = BarcodeReader.init_dls_connection_parameters()
para.organization_id = "200001"
error = BarcodeReader.init_license_from_dls(para)
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
if error[0] != EnumErrorCode.DBR_OK:
print("License error: "+ error[1])

Expand Down
7 changes: 2 additions & 5 deletions samples/hello-world.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
if __name__ == "__main__":
try:
# 1.Initialize license.
# The organization id 200001 here will grant you a free public trial license. Note that network connection is required for this license to work.
# If you want to use an offline license, please contact Dynamsoft Support: https://www.dynamsoft.com/company/contact/
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
para = BarcodeReader.init_dls_connection_parameters()
para.organization_id = "200001"
error = BarcodeReader.init_license_from_dls(para)
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
if error[0] != EnumErrorCode.DBR_OK:
print("License error: "+ error[1])

Expand Down
7 changes: 2 additions & 5 deletions samples/image-decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@ def choose_number() -> int:
if __name__ == "__main__":
try:
# 1.Initialize license.
# The organization id 200001 here will grant you a free public trial license. Note that network connection is required for this license to work.
# If you want to use an offline license, please contact Dynamsoft Support: https://www.dynamsoft.com/company/contact/
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
para = BarcodeReader.init_dls_connection_parameters()
para.organization_id = "200001"
error = BarcodeReader.init_license_from_dls(para)
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
if error[0] != EnumErrorCode.DBR_OK:
print("License error: "+ error[1])

Expand Down
7 changes: 2 additions & 5 deletions samples/performance/accuracy-first-settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,9 @@ def output_results(results:TextResult):
if __name__ == "__main__":
try:
# 1.Initialize license.
# The organization id 200001 here will grant you a free public trial license. Note that network connection is required for this license to work.
# If you want to use an offline license, please contact Dynamsoft Support: https://www.dynamsoft.com/company/contact/
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
para = BarcodeReader.init_dls_connection_parameters()
para.organization_id = "200001"
error = BarcodeReader.init_license_from_dls(para)
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
if error[0] != EnumErrorCode.DBR_OK:
print("License error: "+ error[1])

Expand Down
7 changes: 2 additions & 5 deletions samples/performance/batch-decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
if __name__ == "__main__":
try:
# 1.Initialize license.
# The organization id 200001 here will grant you a free public trial license. Note that network connection is required for this license to work.
# If you want to use an offline license, please contact Dynamsoft Support: https://www.dynamsoft.com/company/contact/
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
para = BarcodeReader.init_dls_connection_parameters()
para.organization_id = "200001"
error = BarcodeReader.init_license_from_dls(para)
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
if error[0] != EnumErrorCode.DBR_OK:
print("License error: "+ error[1])

Expand Down
7 changes: 2 additions & 5 deletions samples/performance/read-rate-first-settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,9 @@ def output_results(results:TextResult):
if __name__ == "__main__":
try:
# 1.Initialize license.
# The organization id 200001 here will grant you a free public trial license. Note that network connection is required for this license to work.
# If you want to use an offline license, please contact Dynamsoft Support: https://www.dynamsoft.com/company/contact/
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
para = BarcodeReader.init_dls_connection_parameters()
para.organization_id = "200001"
error = BarcodeReader.init_license_from_dls(para)
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
if error[0] != EnumErrorCode.DBR_OK:
print("License error: "+ error[1])

Expand Down
7 changes: 2 additions & 5 deletions samples/performance/speed-first-settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,9 @@ def output_results(results:TextResult):
if __name__ == "__main__":
try:
# 1.Initialize license.
# The organization id 200001 here will grant you a free public trial license. Note that network connection is required for this license to work.
# If you want to use an offline license, please contact Dynamsoft Support: https://www.dynamsoft.com/company/contact/
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
para = BarcodeReader.init_dls_connection_parameters()
para.organization_id = "200001"
error = BarcodeReader.init_license_from_dls(para)
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
if error[0] != EnumErrorCode.DBR_OK:
print("License error: "+ error[1])

Expand Down
7 changes: 2 additions & 5 deletions samples/use-case/read-dpm-barcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ def output_results(results:TextResult):
if __name__ == "__main__":
try:
# 1.Initialize license.
# The organization id 200001 here will grant you a free public trial license. Note that network connection is required for this license to work.
# If you want to use an offline license, please contact Dynamsoft Support: https://www.dynamsoft.com/company/contact/
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
para = BarcodeReader.init_dls_connection_parameters()
para.organization_id = "200001"
error = BarcodeReader.init_license_from_dls(para)
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
if error[0] != EnumErrorCode.DBR_OK:
print("License error: "+ error[1])

Expand Down
27 changes: 8 additions & 19 deletions samples/video-decoding-for-picamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
import cv2

# you can change the following variables' value to your own value.
license_key = "Input your own license"
json_file = r"Please input your own template path"

reader = BarcodeReader()

def intermediate_results_callback_func(frame_id, i_results, user_data):
print(frame_id)
for result in i_results:
Expand Down Expand Up @@ -163,22 +160,14 @@ def read_barcode():

print("-------------------start------------------------")

# Apply for a trial license: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=github
reader.init_license(license_key)

## The code snippet below shows how to use the full license in DBR 8.x:
# connection_paras = BarcodeReader.init_dls_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_dls(connection_paras)
# if error[0] != EnumErrorCode.DBR_OK:
# print(error[1])
# except BarcodeReaderError as bre:
# print(bre)
# Initialize license.
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
if error[0] != EnumErrorCode.DBR_OK:
print("License error: "+ error[1])

reader = BarcodeReader()

error = reader.init_runtime_settings_with_file(json_file)
if error[0] != EnumErrorCode.DBR_OK:
Expand Down
11 changes: 4 additions & 7 deletions samples/video-decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def decode_video():
# video_file = "Put your video file path here."
# vc = cv2.VideoCapture(video_file)

video_width = vc.get(cv2.CAP_PROP_FRAME_WIDTH)
video_height = vc.get(cv2.CAP_PROP_FRAME_HEIGHT)
video_width = int(vc.get(cv2.CAP_PROP_FRAME_WIDTH))
video_height = int(vc.get(cv2.CAP_PROP_FRAME_HEIGHT))
vc.set(3, video_width) #set width
vc.set(4, video_height) #set height

Expand Down Expand Up @@ -104,12 +104,9 @@ def decode_video():

try:
# Initialize license.
# The organization id 200001 here will grant you a free public trial license. Note that network connection is required for this license to work.
# If you want to use an offline license, please contact Dynamsoft Support: https://www.dynamsoft.com/company/contact/
# The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
# You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
para = BarcodeReader.init_dls_connection_parameters()
para.organization_id = "200001"
error = BarcodeReader.init_license_from_dls(para)
error = BarcodeReader.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
if error[0] != EnumErrorCode.DBR_OK:
print("License error: "+ error[1])

Expand Down

0 comments on commit baba6cb

Please sign in to comment.