Unable to decode QR code using any Python libraries but works on QR scanners app

108 Views Asked by At

Following is a QR code captured from holography experiment with highest level of error correction. I can decode the image using my native camera app on iPhone but unable to decode using any of the Python QR code decoding libraries.

enter image description here

#---- Using opencv ----#
import cv2
img = cv2.imread('image.jpg')
detector = cv2.QRCodeDetector()
val, pts, qr_code = detector.detectAndDecode(img)
print(val)

#---- Using zxing ----#
import zxing
reader = zxing.BarCodeReader()
result = reader.decode('image.jpg')
result_content = result.raw if result else "Unable to decode"
print(result_content)

#---- using zbarlight ----#
from PIL import Image
import zbarlight
image = Image.open('image.jpg')
image = image.convert('L')

codes = zbarlight.scan_codes(['qrcode'], image)
decoded_code = codes[0].decode('utf-8') if codes else "Unable to decode"
print(decoded_code)

I understand that the image has noise and pincushion distortion in it. I just don't understand how a simple iPhone camera app can decode it straight away but none of the above libraries couldn't.

0

There are 0 best solutions below