|
| 1 | +# Barcode Annotation Tool |
| 2 | + |
| 3 | +A desktop application for annotating barcode locations in images. It automatically detects barcodes using **Dynamsoft Barcode Reader** and **ZXing-C++**, then lets you review, edit, and export the annotations. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Dual-engine detection** — Runs both Dynamsoft DBR and ZXing-C++ on every image, showing results side-by-side with differences highlighted. |
| 8 | +- **Drag-and-drop** — Drop images or folders onto the file list or directly onto the image display area. |
| 9 | +- **Adjustable quad overlays** — Every detected barcode quad has draggable corner handles. Drag any vertex to fine-tune the bounding polygon. |
| 10 | +- **4-click manual annotation** — Press **D** to enter draw mode, then click four points to define a custom quad. A dialog lets you enter barcode text and format. |
| 11 | +- **Delete / Delete All** — Remove the current image (and its annotations) or clear everything at once. |
| 12 | +- **Structured results panel** — A tree view for each barcode showing: |
| 13 | + - Quad point coordinates (updated live when dragging) |
| 14 | + - Dynamsoft result (text, format, coordinates) |
| 15 | + - ZXing result (text, format, coordinates) |
| 16 | + - Differences between the two engines |
| 17 | +- **JSON export** — Save all annotations to a JSON file that includes `total_images` and `total_barcodes` counts. |
| 18 | + |
| 19 | +## Requirements |
| 20 | + |
| 21 | +- Python 3.9+ |
| 22 | +- A valid [Dynamsoft Barcode Reader license key](https://www.dynamsoft.com/customer/license/trialLicense/?product=dcv&package=cross-platform) |
| 23 | + |
| 24 | +## Installation |
| 25 | + |
| 26 | +```bash |
| 27 | +pip install -r requirements.txt |
| 28 | +``` |
| 29 | + |
| 30 | +## Usage |
| 31 | + |
| 32 | +```bash |
| 33 | +python main.py |
| 34 | +``` |
| 35 | + |
| 36 | +### Keyboard Shortcuts |
| 37 | + |
| 38 | +| Key | Action | |
| 39 | +|---|---| |
| 40 | +| **←** / **→** | Previous / Next image | |
| 41 | +| **D** | Toggle draw mode | |
| 42 | +| **C** | Toggle crop mode | |
| 43 | +| **Esc** | Exit draw / crop mode or cancel current quad | |
| 44 | +| **Delete** | Remove current image | |
| 45 | +| **Scroll wheel** | Zoom in / out | |
| 46 | +| **Right-click** (draw mode) | Cancel current quad-in-progress | |
| 47 | + |
| 48 | +### Workflow |
| 49 | + |
| 50 | +1. **Load images** — Use *Load Files*, *Load Folder*, or drag-and-drop. |
| 51 | +2. **Review detections** — Images are automatically sorted into *Verified*, *Needs Review*, and *No Result* lists. |
| 52 | +3. **Fix mismatches** — Click an image in *Needs Review*, then edit text/format by clicking a polygon or drag its corner handles to correct the quad position. |
| 53 | +4. **Handle missed barcodes** — Click an image in *No Result* to re-run detection. If it still fails, use **Crop Mode** (drag a rectangle over the barcode) or **Draw Mode** (press **D**, click four corners, fill the dialog). |
| 54 | +5. **Verify** — Click *✔ Verify* to manually promote any image to the Verified list. |
| 55 | +6. **Import previous work** — Click *Import JSON* to reload a prior session's annotations onto the loaded images instantly. |
| 56 | +7. **Export / Save dataset** — Click *Export JSON* to save annotations for all images, or *Save Verified Dataset* to write only the Verified images and their annotations to a new folder. |
| 57 | + |
| 58 | +### Export Format |
| 59 | + |
| 60 | +```json |
| 61 | +{ |
| 62 | + "format": "barcode-benchmark/1.0", |
| 63 | + "dataset": "Annotated Collection", |
| 64 | + "total_images": 42, |
| 65 | + "total_barcodes": 87, |
| 66 | + "images": [ |
| 67 | + { |
| 68 | + "file": "label_001.png", |
| 69 | + "barcodes": [ |
| 70 | + { |
| 71 | + "text": "1Z999AA10123456784", |
| 72 | + "format": "Code128", |
| 73 | + "points": [[x1,y1], [x2,y2], [x3,y3], [x4,y4]] |
| 74 | + } |
| 75 | + ] |
| 76 | + } |
| 77 | + ] |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | + |
| 82 | +## Annotation Viewer (`viewer.py`) |
| 83 | + |
| 84 | +A companion read-only viewer for inspecting exported `barcode-benchmark/1.0` JSON annotation files alongside the original images. |
| 85 | + |
| 86 | +Built with **tkinter** (Python built-in) and **Pillow** only, making it easy to distribute and run anywhere Python is installed. |
| 87 | + |
| 88 | +```bash |
| 89 | +pip install Pillow |
| 90 | +``` |
| 91 | + |
| 92 | +### Usage |
| 93 | + |
| 94 | +```bash |
| 95 | +python viewer.py |
| 96 | +``` |
| 97 | + |
| 98 | +### Keyboard Shortcuts |
| 99 | + |
| 100 | +| Key | Action | |
| 101 | +|---|---| |
| 102 | +| **←** / **→** | Previous / Next image | |
| 103 | +| **O** | Open JSON annotation file | |
| 104 | +| **Scroll wheel** | Zoom in / out | |
| 105 | + |
| 106 | +### Workflow |
| 107 | + |
| 108 | +1. **Load images** — Use *Load Images…*, *Load Folder…*, or drag-and-drop image files/folders. |
| 109 | +2. **Load JSON** — Use *Open JSON…* or drag-and-drop a `.json` file exported by the annotation tool. |
| 110 | +3. **Browse** — Select any image in the list. If its filename appears in the JSON, overlays and barcode details are shown automatically. |
0 commit comments