https://github.com/floscha/2d-barcode-reader
A Python/OpenCV-based barcode reader for 2D barcode markers
https://github.com/floscha/2d-barcode-reader
barcode opencv python
Last synced: 13 days ago
JSON representation
A Python/OpenCV-based barcode reader for 2D barcode markers
- Host: GitHub
- URL: https://github.com/floscha/2d-barcode-reader
- Owner: floscha
- License: mit
- Created: 2018-01-07T16:20:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-31T00:00:11.000Z (9 months ago)
- Last Synced: 2025-03-30T14:23:33.727Z (about 1 month ago)
- Topics: barcode, opencv, python
- Language: Python
- Size: 68.4 KB
- Stars: 9
- Watchers: 1
- Forks: 4
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# 2D Barcode Reader
[](https://travis-ci.org/floscha/2d-barcode-reader)
[](https://www.codacy.com/app/floscha/2d-barcode-reader?utm_source=github.com&utm_medium=referral&utm_content=floscha/2d-barcode-reader&utm_campaign=Badge_Grade)
[](https://opensource.org/licenses/MIT)A Python/OpenCV-based barcode reader for 2D barcode markers.
## Example
Assume we have an image containing one or several markers like the one below:

To extract the marker(s) we can use the following script similar to the [example reader](example/example_reader.py):
```python
import cv2from barcode_reader import MarkerDetector
image_path = 'clean_marker.png'
frame = cv2.imread(image_path, cv2.IMREAD_COLOR)if frame is None:
raise ValueError("Image could not be read")detector = MarkerDetector(min_contour_length_allowed=10000)
detected_markers = detector.process_frame(frame)print("%d markers detected:" % len(detected_markers))
for marker in detected_markers:
print(marker.points)
```This outputs the detected contour(s).
```
2 markers detected:
[[119.43042755 120.34486389]
[380.50708008 120.37145233]
[380.46075439 379.82989502]
[119.41880798 379.66653442]]
[[119.43190002 120.3412323 ]
[380.51220703 120.37619019]
[380.45599365 379.8331604 ]
[119.41361237 379.66433716]]
```Also, when debugging is enabled, it draws-in the contours like shown below:
