Pyzbar
Read one-dimensional barcodes and QR codes from Python 2 and 3.
Example
Example
한장의 사진에 QR코드가 여러개 존재한다고 가정하고 이 사진의 각각의 QR 코드 정보를 출력하고 QR코드 영역에 빨간색 사각형을 그리는 코드를 작성한다면,
import cv2
from pyzbar.pyzbar import decode
img = cv2.imread("qrcode_3.jpg")
img = cv2.resize(img, (0, 0), fx=0.3, fy=0.3)
decoded = decode(img)
for d in decoded:
x, y, w, h = d.rect
barcode_data = d.data.decode("utf-8")
barcode_type = d.type
cv2.rectangle(img, (x, y), (x + w, y + h), (0, 0, 255), 5)
print(barcode_data, barcode_type)
cv2.imshow('img', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
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 코드 검출기.