Python 3 (OpenCV + Numpy + Qrcode) Example Script to Scan or Read Qr Codes and Generate QR Codes Full Example Project For Beginners

You are currently viewing Python 3 (OpenCV + Numpy + Qrcode) Example Script to Scan or Read Qr Codes and Generate QR Codes Full Example Project For Beginners

 

Welcome folks today in this post we will be scanning or reading  qr codes and also generating qr codes in python using opencv and numpy and qrcode library. All the source code of the application is given below.

 

 

 

Get Started

 

 

 

In order to get started you need to install the following libraries

 

pip install qrcode

 

pip install opencv-python

 

pip install numpy

 

After installing all these libraries we need to create an app.py file and copy paste the following code

 

First of all we will be generating simple qr codes using qrcode library and numpy

 

app.py

 

 

 

Simply we are importing the qrcode library and then we are generating the simple qr code containing the website url codingshiksha.com and we have given the output file name as codingshiksha.png so when you run the python script as shown below

 

python app.py

 

You will see the qr code image being created as shown below

 

 

 

 

 

 

 

You can even make colored qr codes having custom border as well as shown below in the example

 

app.py

 

 

 

Now this will be a red colored qr code as shown below when you run it

 

 

 

 

Reading QR Codes

 

 

Now we will look at how to read the data which is contained inside the qr codes as shown below in the example

 

app.py

 

 

 

Here we are using the python-opencv library to read the data of qr code as shown below

 

 

 

 

 

 

 

Leave a Reply