QR Code Reader in Python

In the previous post, we have learned How to Generate QR Code in Python. So, in this post, we learn How to make QR Code Reader in Python. We will read QR code and get data using python so let’s start.

Installation

We need ZBar tool to read QR code. ZBar is an open source software suite for reading bar codes from various sources, such as video streams, image files and raw intensity sensors. It supports many popular symbologies (types of bar codes) including EAN-13/UPC-A, UPC-E, EAN-8, Code 128, Code 39, Interleaved 2 of 5 and QR Code.

Linux

sudo apt-get install zbar-tools

Windows

See this for Windows http://zbar.sourceforge.net/download.html

Other Python module installation

pip install pypng
pip install pyqrcode
pip install pillow
pip install pyzbar

Code

from pyzbar.pyzbar import decode
from PIL import Image

d = decode(Image.open("codesnail-qr-code.png"))
# print(d)
print(d[0].data.decode())

#Follow @code_snail

Here we read codesnail-qr-code.png

Output

qr code generator in python

I hope you like this QR code reader in python. Try this code and scan your QR code. Share it with your friends.

You may also like,

Leave a Comment

Copy link
Powered by Social Snap