Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ImageMagick/ZBar to read QR codes

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?

like image 337
JacobEvelyn Avatar asked Jan 16 '14 20:01

JacobEvelyn


People also ask

Is it possible to crack QR code?

But can hackers get through a QR code? Unfortunately, the answer is yes. Hackers have recently caught up with the QR code craze and have begun placing infected and decoy QR codes in order to infect phones and hack private users directly through their personal devices.

How do I open a QR link from an image?

Your Phone's Gallery App (Android) Open the photo with the QR code in the native Gallery app. Tap on the Google Lens icon to scan the code. The results should appear immediately.


1 Answers

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
like image 67
Jaroslaw Matlak Avatar answered Oct 04 '22 17:10

Jaroslaw Matlak