Zbar-py
Simple python 2 and 3 compatible interface to the zbar barcode-reading library
Example
Example
import zbar
import cv2
# Zbar 라이브러리로 QR코드를 인식하기위해서 opcnCV로 이미지를 그레이 스케일로 읽어옵니다
im = cv2.imread("image/QR2.jpg", cv2.IMREAD_GRAYSCALE)
scanner = zbar.Scanner()
results = scanner.scan(im)
for result in results:
print(result.data)
Draw Polylines
import zbar
import cv2
import numpy as np
ori = cv2.imread("test.jpg")
image = cv2.cvtColor(ori, cv2.COLOR_BGR2GRAY)
scanner = zbar.Scanner()
results = scanner.scan(image)
for result in results:
print(result.type, result.data, result.quality, result.position)
pts1 = np.array(result.position, dtype=np.int32)
ori = cv2.polylines(ori, [pts1], True, (0, 0, 255), 2, cv2.LINE_AA)
cv2.imwrite("result-zbar-py.jpg", ori)
See also
- QRCode
- BarCode
- libzbar - QR Code scanner engine for QR+Emoji
- zbar-py - zbar package
- pyzbar - Read one-dimensional barcodes and QR codes from Python 2 and 3.
- QReader - Robust and Straight-Forward solution for reading difficult and tricky QR codes within images in Python. Supported by a YOLOv8 QR Segmentation model.
- cv2.QRCodeDetector - OpenCV 에 내장된 QR 코드 검출기.