Frage

I've got scanned image files that I perform some preprocessing on and get them looking something like this:

QR Code Image

My phone's ZBar app can read this QR code fine, but zbarimg seems to be unable to figure it out. I've tried all sorts of things in ImageMagick to make it smoother (-smooth, -morphology) but even with slightly better-looking results, zbarimg still comes up blank.

Why would my phone's ZBar be so much better than my computer's (zbar-0.10)? Is there anything I can do to get zbarimg to read this successfully?

War es hilfreich?

Lösung

You can try morphological closing.

Python code:

# -*- coding: utf-8 -*-
import qrtools
import cv2
import numpy as np

imgPath = "Fdnm1.png"

img = cv2.imread(imgPath, 0)
kernel = np.ones((5, 5), np.uint8)
processed=cv2.morphologyEx(img, cv2.MORPH_CLOSE, kernel)
cv2.imwrite('test.png', processed)
d = qrtools.QR(filename='test.png')
d.decode()
print d.data

Result:

1MB24
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top