Skip to content

Commit 23f709c

Browse files
update to v10.4.20
1 parent 96b1b19 commit 23f709c

26 files changed

+278
-1236
lines changed

Legal.txt

+184-106
Large diffs are not rendered by default.

README.md

+15-25
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Dynamsoft Barcode Reader samples for Python edition
1+
# Dynamsoft Barcode Reader Samples for Python Edition
22

3-
[![Current version number](https://img.shields.io/pypi/v/dbr?color=orange)](https://pypi.org/project/dbr/)
4-
[![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%20%7C%203.11%20%7C%203.12-blue)](https://www.python.org/downloads/)
5-
[![PyPI downloads](https://img.shields.io/pypi/dm/dbr)](https://pypistats.org/packages/dbr)
3+
[![Current version number](https://img.shields.io/pypi/v/dynamsoft_barcode_reader_bundle?color=orange)](https://pypi.org/project/dynamsoft_barcode_reader_bundle/)
4+
[![Supported Python versions](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)](https://www.python.org/downloads/)
5+
[![PyPI downloads](https://img.shields.io/pypi/dm/dynamsoft_barcode_reader_bundle)](https://pypistats.org/packages/dynamsoft_barcode_reader_bundle)
66

77
![Dynamsoft](https://dynamsoft.github.io/styleguide/assets/images/icons/dynamsoft_logos/dynamsoft_logo_original.png "Dynamsoft")
88

@@ -14,55 +14,45 @@ This repository contains multiple samples that demonstrate how to use the [Dynam
1414

1515
### Supported Platforms
1616
- Windows x64
17-
- Linux (x64, ARM32, ARM64)
17+
- Linux (x64, ARM64)
1818
- macOS (10.15+)
1919

2020
### Supported Python Versions
2121

22-
- Python 3.6
23-
- Python 3.7
24-
- Python 3.8
25-
- Python 3.9
26-
- Python 3.10
27-
- Python 3.11
2822
- Python 3.12
23+
- Python 3.11
24+
- Python 3.10
25+
- Python 3.9
26+
- Python 3.8
2927

3028
## Installation
3129

3230
```
33-
pip install dbr
31+
pip install dynamsoft_barcode_reader_bundle
3432
```
3533

3634
or
3735

3836
```
39-
pip3 install dbr
37+
pip3 install dynamsoft_barcode_reader_bundle
4038
```
4139

4240
## Samples
4341

4442
| Sample Name | Description |
4543
| ----------- | ----------- |
46-
| [`hello-world`](samples/hello-world.py) | Shows the simplest way to recognize barcodes from images in Python using Dynamsoft Barcode Reader SDK. |
47-
| [`general-settings`](samples/general-settings.py) | Shows how to adjust general scan settings, e.g., barcode format, barcode count, scan region. |
48-
| [`image-decoding`](samples/image-decoding.py) | Shows how to decode images in various formats, e.g., file bytes, opencv image, raw image buffer. |
49-
| [`video-decoding`](samples/video-decoding.py) | Shows how to decode barcodes from a video from a file or camera. |
50-
| [`video-decoding-for-picamera`](samples/video-decoding-for-picamera.py) | Shows how to scan barcodes from videos from a Raspberry Pi camera (PiCamera). |
51-
| [`batch-decode`](samples/performance/batch-decode.py) | Shows how to batch decode image files from a specified folder. |
52-
| [`speed-first-settings`](samples/performance/speed-first-settings.py) | Shows how to configure the scan settings for best barcode reading speed. |
53-
| [`read-rate-first-settings`](samples/performance/read-rate-first-settings.py) | Shows how to configure the scan settings to read as many barcodes as possible at one time. Recommended when decoding multiple barcodes from a single image. |
54-
| [`accuracy-first-settings`](samples/performance/accuracy-first-settings.py) | Shows how to configure the scan settings for best barcode reading accuracy. |
55-
| [`read-dpm-barcode`](samples/use-case/read-dpm-barcode.py) | Shows how to read DPM (Direct Part Mark) barcodes. |
44+
| [`ReadAnImage`](Samples/read_an_image.py) | Shows the simplest way to read barcodes from an image file and output barcode format and text. |
45+
| [`ReadMultipleImages`](Samples/read_multiple_images.py) | Shows the simplest way to read barcodes from directory with image files and output barcode format and text. |
5646

5747
## Documentation
5848

5949
https://www.dynamsoft.com/barcode-reader/docs/server/programming/python/?ver=latest&utm_source=samples
6050

6151
## License
6252

63-
The barcode reader library requires a license to work. You can use the API `init_license` to initialize the license key and activate the SDK.
53+
The library requires a license to work, you use the API `LicenseManager.init_license` to initialize license key and activate the SDK.
6454

65-
These samples use a free public trial license which requires a network connection to function. You can request a 30-day free trial license key from <a href="https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=python" target="_blank">Customer Portal</a> which works offline.
55+
These samples use a free public trial license which require network connection to function. You can request a 30-day free trial license via the <a href="https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=github&package=python" target="_blank">Request a Trial License</a> link which works offline.
6656

6757
## Contact Us
6858

Samples/read_an_image.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from dynamsoft_barcode_reader_bundle import *
2+
import os
3+
4+
if __name__ == '__main__':
5+
# Initialize license.
6+
# You can request and extend a trial license from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
7+
# The string 'DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9' here is a free public trial license. Note that network connection is required for this license to work.
8+
errorCode, errorMsg = LicenseManager.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
9+
if errorCode != EnumErrorCode.EC_OK and errorCode != EnumErrorCode.EC_LICENSE_CACHE_USED:
10+
print("License initialization failed: ErrorCode:", errorCode, ", ErrorString:", errorMsg)
11+
else:
12+
cvr = CaptureVisionRouter()
13+
result = cvr.capture("../Images/GeneralBarcodes.png", EnumPresetTemplate.PT_READ_BARCODES.value)
14+
if result.get_error_code() != EnumErrorCode.EC_OK:
15+
print("Error:", result.get_error_code(), result.get_error_string())
16+
barcode_result = result.get_decoded_barcodes_result()
17+
if barcode_result is None or barcode_result.get_items() == 0:
18+
print("No barcode detected.")
19+
else:
20+
items = barcode_result.get_items()
21+
print("Decoded", len(items), "barcodes.")
22+
for index,item in enumerate(items):
23+
print("Result", index+1)
24+
print("Barcode Format:", item.get_format_string())
25+
print("Barcode Text:", item.get_text())
26+
input("Press Enter to quit...")

Samples/read_multiple_images.py

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from dynamsoft_barcode_reader_bundle import *
2+
import os
3+
4+
class MyCapturedResultReceiver(CapturedResultReceiver):
5+
6+
def __init__(self) -> None:
7+
super().__init__()
8+
def on_decoded_barcodes_received(self, result: "DecodedBarcodesResult") -> None:
9+
tag = result.get_original_image_tag()
10+
if isinstance(tag, FileImageTag):
11+
print("File:", tag.get_file_path())
12+
if result.get_error_code() != EnumErrorCode.EC_OK:
13+
print("Error:", result.get_error_string())
14+
else:
15+
items = result.get_items()
16+
print("Detected", len(items), "barcodes.")
17+
for index, item in enumerate(items):
18+
print("Result", index+1)
19+
print("Barcode Format:", item.get_format_string())
20+
print("Barcode Text:", item.get_text())
21+
22+
class MyImageSourceStateListener(ImageSourceStateListener):
23+
def __init__(self, cvr:CaptureVisionRouter) -> None:
24+
super().__init__()
25+
self.cvr = cvr
26+
def on_image_source_state_received(self, state: int) -> None:
27+
if state == EnumImageSourceState.ISS_EXHAUSTED:
28+
if self.cvr != None:
29+
self.cvr.stop_capturing()
30+
if __name__ == '__main__':
31+
# Initialize license.
32+
# You can request and extend a trial license from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
33+
# The string 'DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9' here is a free public trial license. Note that network connection is required for this license to work.
34+
errorCode, errorMsg = LicenseManager.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
35+
if errorCode != EnumErrorCode.EC_OK and errorCode != EnumErrorCode.EC_LICENSE_CACHE_USED:
36+
print("License initialization failed: ErrorCode:", errorCode, ", ErrorString:", errorMsg)
37+
else:
38+
cvr = CaptureVisionRouter()
39+
40+
fetcher = DirectoryFetcher()
41+
fetcher.set_directory("../Images")
42+
cvr.set_input(fetcher)
43+
44+
receiver = MyCapturedResultReceiver()
45+
cvr.add_result_receiver(receiver)
46+
47+
listener = MyImageSourceStateListener(cvr)
48+
cvr.add_image_source_state_listener(listener)
49+
50+
errorCode, errorMsg = cvr.start_capturing("", True)
51+
if errorCode != EnumErrorCode.EC_OK:
52+
print("error:", errorMsg)
53+
input("Press Enter to quit...")

images/AllSupportedBarcodeTypes.png

-335 KB
Binary file not shown.

images/Codabar1.jpg

-134 KB
Binary file not shown.

images/GS1 DataBar.png

69.3 KB
Loading

images/GeneralBarcodes.png

140 KB
Loading

images/PatchCode.png

13.6 KB
Loading

images/Pharmacode.png

7.48 KB
Loading

images/PostalCode.png

50.6 KB
Loading

images/codabar.jpg

-53.6 KB
Loading

images/dpm.jpg

-64.8 KB
Binary file not shown.

samples/general-settings.py

-65
This file was deleted.

samples/hello-world.py

-31
This file was deleted.

samples/image-decoding.py

-94
This file was deleted.

0 commit comments

Comments
 (0)