Skip to content

Commit

Permalink
update to v10.4.20
Browse files Browse the repository at this point in the history
  • Loading branch information
JaneYe-Dynamsoft committed Oct 10, 2024
1 parent 96b1b19 commit 23f709c
Show file tree
Hide file tree
Showing 26 changed files with 278 additions and 1,236 deletions.
290 changes: 184 additions & 106 deletions Legal.txt

Large diffs are not rendered by default.

40 changes: 15 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Dynamsoft Barcode Reader samples for Python edition
# 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%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)](https://www.python.org/downloads/)
[![PyPI downloads](https://img.shields.io/pypi/dm/dbr)](https://pypistats.org/packages/dbr)
[![Current version number](https://img.shields.io/pypi/v/dynamsoft_barcode_reader_bundle?color=orange)](https://pypi.org/project/dynamsoft_barcode_reader_bundle/)
[![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/)
[![PyPI downloads](https://img.shields.io/pypi/dm/dynamsoft_barcode_reader_bundle)](https://pypistats.org/packages/dynamsoft_barcode_reader_bundle)

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

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

### Supported Platforms
- Windows x64
- Linux (x64, ARM32, ARM64)
- Linux (x64, ARM64)
- macOS (10.15+)

### Supported Python Versions

- Python 3.6
- Python 3.7
- Python 3.8
- Python 3.9
- Python 3.10
- Python 3.11
- Python 3.12
- Python 3.11
- Python 3.10
- Python 3.9
- Python 3.8

## Installation

```
pip install dbr
pip install dynamsoft_barcode_reader_bundle
```

or

```
pip3 install dbr
pip3 install dynamsoft_barcode_reader_bundle
```

## Samples

| Sample Name | Description |
| ----------- | ----------- |
| [`hello-world`](samples/hello-world.py) | Shows the simplest way to recognize barcodes from images in Python using Dynamsoft Barcode Reader SDK. |
| [`general-settings`](samples/general-settings.py) | Shows how to adjust general scan settings, e.g., barcode format, barcode count, scan region. |
| [`image-decoding`](samples/image-decoding.py) | Shows how to decode images in various formats, e.g., file bytes, opencv image, raw image buffer. |
| [`video-decoding`](samples/video-decoding.py) | Shows how to decode barcodes from a video from a file or camera. |
| [`video-decoding-for-picamera`](samples/video-decoding-for-picamera.py) | Shows how to scan barcodes from videos from a Raspberry Pi camera (PiCamera). |
| [`batch-decode`](samples/performance/batch-decode.py) | Shows how to batch decode image files from a specified folder. |
| [`speed-first-settings`](samples/performance/speed-first-settings.py) | Shows how to configure the scan settings for best barcode reading speed. |
| [`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. |
| [`accuracy-first-settings`](samples/performance/accuracy-first-settings.py) | Shows how to configure the scan settings for best barcode reading accuracy. |
| [`read-dpm-barcode`](samples/use-case/read-dpm-barcode.py) | Shows how to read DPM (Direct Part Mark) barcodes. |
| [`ReadAnImage`](Samples/read_an_image.py) | Shows the simplest way to read barcodes from an image file and output barcode format and text. |
| [`ReadMultipleImages`](Samples/read_multiple_images.py) | Shows the simplest way to read barcodes from directory with image files and output barcode format and text. |

## Documentation

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

## License

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.
The library requires a license to work, you use the API `LicenseManager.init_license` to initialize license key and activate the SDK.

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.
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.

## Contact Us

Expand Down
26 changes: 26 additions & 0 deletions Samples/read_an_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from dynamsoft_barcode_reader_bundle import *
import os

if __name__ == '__main__':
# Initialize license.
# You can request and extend a trial license from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
# The string 'DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9' here is a free public trial license. Note that network connection is required for this license to work.
errorCode, errorMsg = LicenseManager.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
if errorCode != EnumErrorCode.EC_OK and errorCode != EnumErrorCode.EC_LICENSE_CACHE_USED:
print("License initialization failed: ErrorCode:", errorCode, ", ErrorString:", errorMsg)
else:
cvr = CaptureVisionRouter()
result = cvr.capture("../Images/GeneralBarcodes.png", EnumPresetTemplate.PT_READ_BARCODES.value)
if result.get_error_code() != EnumErrorCode.EC_OK:
print("Error:", result.get_error_code(), result.get_error_string())
barcode_result = result.get_decoded_barcodes_result()
if barcode_result is None or barcode_result.get_items() == 0:
print("No barcode detected.")
else:
items = barcode_result.get_items()
print("Decoded", len(items), "barcodes.")
for index,item in enumerate(items):
print("Result", index+1)
print("Barcode Format:", item.get_format_string())
print("Barcode Text:", item.get_text())
input("Press Enter to quit...")
53 changes: 53 additions & 0 deletions Samples/read_multiple_images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from dynamsoft_barcode_reader_bundle import *
import os

class MyCapturedResultReceiver(CapturedResultReceiver):

def __init__(self) -> None:
super().__init__()
def on_decoded_barcodes_received(self, result: "DecodedBarcodesResult") -> None:
tag = result.get_original_image_tag()
if isinstance(tag, FileImageTag):
print("File:", tag.get_file_path())
if result.get_error_code() != EnumErrorCode.EC_OK:
print("Error:", result.get_error_string())
else:
items = result.get_items()
print("Detected", len(items), "barcodes.")
for index, item in enumerate(items):
print("Result", index+1)
print("Barcode Format:", item.get_format_string())
print("Barcode Text:", item.get_text())

class MyImageSourceStateListener(ImageSourceStateListener):
def __init__(self, cvr:CaptureVisionRouter) -> None:
super().__init__()
self.cvr = cvr
def on_image_source_state_received(self, state: int) -> None:
if state == EnumImageSourceState.ISS_EXHAUSTED:
if self.cvr != None:
self.cvr.stop_capturing()
if __name__ == '__main__':
# Initialize license.
# You can request and extend a trial license from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python
# The string 'DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9' here is a free public trial license. Note that network connection is required for this license to work.
errorCode, errorMsg = LicenseManager.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
if errorCode != EnumErrorCode.EC_OK and errorCode != EnumErrorCode.EC_LICENSE_CACHE_USED:
print("License initialization failed: ErrorCode:", errorCode, ", ErrorString:", errorMsg)
else:
cvr = CaptureVisionRouter()

fetcher = DirectoryFetcher()
fetcher.set_directory("../Images")
cvr.set_input(fetcher)

receiver = MyCapturedResultReceiver()
cvr.add_result_receiver(receiver)

listener = MyImageSourceStateListener(cvr)
cvr.add_image_source_state_listener(listener)

errorCode, errorMsg = cvr.start_capturing("", True)
if errorCode != EnumErrorCode.EC_OK:
print("error:", errorMsg)
input("Press Enter to quit...")
Binary file removed images/AllSupportedBarcodeTypes.png
Binary file not shown.
Binary file removed images/Codabar1.jpg
Binary file not shown.
Binary file added images/GS1 DataBar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/GeneralBarcodes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/PatchCode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Pharmacode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/PostalCode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/codabar.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/dpm.jpg
Binary file not shown.
65 changes: 0 additions & 65 deletions samples/general-settings.py

This file was deleted.

31 changes: 0 additions & 31 deletions samples/hello-world.py

This file was deleted.

94 changes: 0 additions & 94 deletions samples/image-decoding.py

This file was deleted.

Loading

0 comments on commit 23f709c

Please sign in to comment.