Skip to content

Commit 58aa9e8

Browse files
committed
Support generated dataset and HTML report
1 parent 33b95a9 commit 58aa9e8

181 files changed

Lines changed: 3023 additions & 16 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*.pyc
5+
*$py.class
6+
*.so
7+
.Python
8+
build/
9+
develop-eggs/
10+
dist/
11+
downloads/
12+
eggs/
13+
.eggs/
14+
lib/
15+
lib64/
16+
parts/
17+
sdist/
18+
var/
19+
wheels/
20+
*.egg-info/
21+
.installed.cfg
22+
*.egg
23+
24+
# Virtual Environment
25+
venv/
26+
env/
27+
ENV/
28+
.venv
29+
30+
# Test data and results
31+
test_data/
32+
results/
33+
test_results/
34+
test_results_fixed/
35+
generated_dataset/
36+
37+
# IDE
38+
.vscode/
39+
.idea/
40+
*.swp
41+
*.swo
42+
*~
43+
44+
# OS
45+
.DS_Store
46+
Thumbs.db
47+
48+
# Logs
49+
*.log
50+
51+
# Temporary files
52+
*.tmp
53+
*.bak
54+
*.old
55+
56+
# Configuration (keep template)
57+
config/benchmark_config.json
58+
59+
# Deprecated files
60+
scandit-*.txt
61+
test_fix.py
62+
verify_*.py

examples/official/zxing_zbar/README.md

Lines changed: 126 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
# ZXing-cpp vs. ZBar vs. Dynamsoft Barcode Reader in Python
2-
This repository compares the barcode recognition performance of three popular libraries: **ZXing-cpp**, **ZBar**, and the [Dynamsoft Capture Vision SDK](https://pypi.org/search/?q=dynamsoft-capture-vision-bundle).
1+
# Barcode SDK Benchmark Framework
2+
Comprehensive benchmarking framework to compare barcode reader SDKs: **ZXing-cpp**, **ZBar**, and [Dynamsoft Capture Vision SDK](https://pypi.org/search/?q=dynamsoft-capture-vision-bundle).
3+
4+
This project focuses on **angled barcode detection** and **multiple barcode scenarios**, designed to identify and showcase competitive advantages in barcode recognition performance.
5+
6+
## Key Features
7+
8+
- **Multiple SDK Support**: ZXing-Cpp, PyZBar (open-source), Dynamsoft (commercial)
9+
- **Dual Benchmark Modes**:
10+
- Simple benchmark with real-world dataset (170 images)
11+
- Advanced benchmark with generated test scenarios
12+
- **Specialized Testing**: Angled barcodes (15°-75°), multiple barcodes (2-20 per image)
13+
- **Core Metrics**: Detection time (ms) and success rate (%)
14+
- **Professional Reports**: HTML reports with interactive charts and strategic insights
15+
- **Extensible Framework**: Easy to add new SDKs and test scenarios
316

417
## Prerequisites
518
- Install required packages:
@@ -10,10 +23,19 @@ This repository compares the barcode recognition performance of three popular li
1023

1124
- Dataset
1225

13-
The dataset is sourced from this [GitHub issue](https://github.com/openfoodfacts/openfoodfacts-ai/issues/15). You can download it directly from: https://drive.google.com/uc?id=1uThXXH8HiHAw6KlpdgcimBSbrvi0Mksf&export=download. We have cleaned the images to ensure each image file name matches the barcode content.
26+
- **Existing Dataset**: The dataset is sourced from this [GitHub issue](https://github.com/openfoodfacts/openfoodfacts-ai/issues/15). You can download it directly from: https://drive.google.com/uc?id=1uThXXH8HiHAw6KlpdgcimBSbrvi0Mksf&export=download. We have cleaned the images to ensure each image file name matches the barcode content. Extract the images to the `existing_dataset/` folder.
27+
28+
- **Generated Dataset**: The benchmark framework can automatically generate test datasets with various conditions (angles, multiple barcodes, etc.). These are stored in the `generated_dataset/` folder and created by running `advanced.py`.
1429

1530
## Usage
16-
1. Obtain a [30-day trial license](https://www.dynamsoft.com/customer/license/trialLicense/?product=dcv&package=cross-platform) and update the code with the license key in `app.py`.
31+
32+
This project provides two benchmark programs:
33+
- **simple.py** - Quick benchmark using existing dataset (real-world barcode images)
34+
- **advanced.py** - Comprehensive benchmark with dataset selection and detailed analysis
35+
36+
### Option 1: Simple Benchmark (simple.py)
37+
38+
1. Obtain a [30-day trial license](https://www.dynamsoft.com/customer/license/trialLicense/?product=dcv&package=cross-platform) and update the code with the license key in `simple.py`.
1739

1840
```python
1941
from dynamsoft_capture_vision_bundle import *
@@ -24,11 +46,11 @@ This repository compares the barcode recognition performance of three popular li
2446
2. Run the Python script:
2547

2648
```bash
27-
python app.py
49+
# Test with a single image
50+
python simple.py -i <image_file>
2851
29-
Usage:
30-
python app.py -i <image_file>
31-
python app.py -d <folder_directory>
52+
# Run benchmark on existing dataset (default: existing_dataset/)
53+
python simple.py -d existing_dataset
3254
```
3355

3456
**ZXing**
@@ -42,7 +64,102 @@ This repository compares the barcode recognition performance of three popular li
4264
**Dynamsoft Barcode Reader**
4365

4466
![python zxing barcode detection](https://www.dynamsoft.com/codepool/img/2024/08/python-dbr-barcode-detection.png)
45-
67+
68+
### Option 2: Advanced Benchmark (advanced.py)
69+
70+
Run the comprehensive benchmark with interactive dataset selection:
71+
72+
```bash
73+
python advanced.py
74+
```
75+
76+
This will:
77+
1. **Select dataset**: Choose between generated dataset, existing dataset, or both
78+
2. **Generate test data** (if using generated dataset and not already created)
79+
3. **Run benchmark tests** with enabled SDKs
80+
4. **Analyze results** and generate reports in `results/`
81+
82+
The program will automatically detect which datasets are available and allow you to:
83+
- Use **generated dataset** for controlled testing (angled barcodes, multiple barcodes, etc.)
84+
- Use **existing dataset** for real-world barcode testing (170 images)
85+
- Use **both datasets** for comprehensive benchmarking
86+
87+
## 🔧 Configuration
88+
89+
Edit `config/benchmark_config.json` to enable/disable SDKs and configure settings:
90+
91+
```json
92+
{
93+
"libraries": {
94+
"zxing_cpp": {
95+
"enabled": true
96+
},
97+
"pyzbar": {
98+
"enabled": true
99+
},
100+
"dynamsoft": {
101+
"enabled": false,
102+
"license": "YOUR_LICENSE_KEY_HERE"
103+
}
104+
},
105+
"test_data": {
106+
"num_samples": 50
107+
}
108+
}
109+
```
110+
111+
**Note**: Dynamsoft requires a valid license key. Visit [Dynamsoft's website](https://www.dynamsoft.com/customer/license/trialLicense/?product=dcv&package=cross-platform) to obtain one.
112+
113+
## Test Scenarios
114+
115+
### 1. Single Barcodes (Baseline)
116+
- Barcode types: CODE128, CODE39, EAN13, EAN8, ITF, QR_CODE
117+
- Clean images for establishing performance baselines
118+
- Measures basic detection capabilities
119+
120+
### 2. Angled Barcodes (Key Focus)
121+
- Rotation angles: 15°, 30°, 45°, 60°, 75°
122+
- Tests SDK ability to handle rotated/tilted barcodes
123+
- **Critical for real-world mobile scanning** where camera angle varies
124+
- Identifies competitive advantage in flexible positioning
125+
126+
### 3. Multiple Barcodes (Key Focus)
127+
- Barcode counts: 2, 5, 10, 15, 20 per image
128+
- Tests batch processing and scalability
129+
- **Important for inventory, logistics, and warehouse applications**
130+
- Demonstrates efficiency in high-density scanning scenarios
131+
132+
### 4. Challenging Conditions
133+
- Combined tests with noise, blur, occlusion, and perspective distortion
134+
- Validates robustness under real-world degraded conditions
135+
136+
### 5. Existing Dataset (Real-world Testing)
137+
- 170 real-world barcode images from production environments
138+
- Various barcode types including EAN, UPC, CODE128, CODE39
139+
- Tests practical performance with authentic scanning conditions
140+
141+
## Project Structure
142+
143+
```
144+
├── simple.py # Simple benchmark using existing dataset
145+
├── advanced.py # Advanced benchmark with dataset selection
146+
├── existing_dataset/ # Real-world barcode images (download separately)
147+
├── generated_dataset/ # Auto-generated test cases (created by advanced.py)
148+
│ ├── single_barcode/
149+
│ ├── angled_barcodes/
150+
│ ├── multiple_barcodes/
151+
│ └── challenging_conditions/
152+
├── results/ # Benchmark results and reports
153+
├── src/ # Benchmark framework modules
154+
└── config/ # Configuration files
155+
```
156+
157+
## Supported Barcode Types
158+
159+
**1D Barcodes**: CODE_128, CODE_39, EAN_13, EAN_8, UPC_A, UPC_E, ITF, CODABAR
160+
161+
**2D Barcodes**: QR_CODE, DATA_MATRIX, PDF_417, AZTEC (support varies by SDK)
162+
46163
47164
## Blog
48165
[Comparing Barcode Scanning in Python: ZXing vs. ZBar vs. Dynamsoft Barcode Reader](https://www.dynamsoft.com/codepool/python-zxing-zbar-barcode.html)

0 commit comments

Comments
 (0)