Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 3 months 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 (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-06-21T22:31:16.000Z (over 2 years ago)
- Last Synced: 2024-07-30T17:16:52.536Z (6 months ago)
- Topics: barcode, opencv, python
- Language: Python
- Size: 66.4 KB
- Stars: 9
- Watchers: 2
- Forks: 3
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![barcode reader logo](logo.png)
# 2D Barcode Reader
[![Build Status](https://travis-ci.org/floscha/2d-barcode-reader.svg?branch=master)](https://travis-ci.org/floscha/2d-barcode-reader)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/d85fb6267312422baa08c6c8385da846)](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)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](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:
![clean marker](example/clean_marker.png)
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:
![marker with contours](example/debug.png)