https://github.com/xnacly/barcode-detection
detecting barcodes in images
https://github.com/xnacly/barcode-detection
barcode-detection image-processing python
Last synced: over 1 year ago
JSON representation
detecting barcodes in images
- Host: GitHub
- URL: https://github.com/xnacly/barcode-detection
- Owner: xNaCly
- Created: 2023-11-13T12:04:17.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-01-03T10:28:46.000Z (over 2 years ago)
- Last Synced: 2025-01-18T12:20:11.446Z (over 1 year ago)
- Topics: barcode-detection, image-processing, python
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# barcode detection
> detect barcodes in images and draw a border with a custom color around them
```shell
$ python3 barcode-detector.py --path example.tif --color "255:0:255"
```

## Usage
```
usage: barcode-detector.py [-h] -p PATH [-c COLOR]
options:
-h, --help show this help message and exit
-p PATH, --path PATH Path to the input image
-c COLOR, --color COLOR Color of the border, fmt: r:g:b
```
## Inner workings
The barcode detector works by applying several filters to an image and
extracting the contours of the barcodes. If a barcode could not be detected
consider tweaking constants in the source file.
The algorithm is made up of the following filters and stages:
1. sharr gradient in x and y direction
2. subtract y from x gradient for finding barcode region
3. blur and threshold
4. Closing kernel
5. Series of dilations and erosions
6. Largest contour should be the barcode