INDEX
CERTIFICATE i
INDEX ii
LIST OF FIGURES iii
CHAPTER 1 INTRODUCTION 1
CHAPTER 2 METHODOLOGY 2
CHAPTER 3 TOOLS/PLATFORMS 3
CHAPTER 4 DESIGN & IMPLEMENTATION 4-8
4.1 ALGORITHM
4.2 FLOWCHART
4.3 SOURCE CODE
CHAPTER 5 RESULT & DISCUSSION 9-10
5.1 OUTPUT
5.2 DISCUSSION
5.3 APPLICATION
CHAPTER 6 CONCLUSION 11
REFERENCES 12
LIST OF FIGURE
FIG. NO. TITLE OF FIGURE PAGE NO.
1 Encoding 5
2 Decoding 6
3 Encoding Output 9
4 Decoding Output 9
iii
CHAPTER 1
INTRODUCTION
In the modern world, our objective is to always have a secure and convenient way of accessing
things. Nobody wants to read and click on elongated URL links or lengthy word sequences. Also, in
the world of the recent pandemic, it is usually considered best to avoid touches and achieve
transactions without much physical contact.
This objective is achieved with the help of bar codes and QR codes. Bar codes suffer from some
spacing limitations, which are handled by the introduction of QR codes. QR Codes are typically two-
dimensional pictographic codes that offer the users a large storage capacity and fast readability in the
form of black modules arranged in a square pattern on a white background.
QR codes are a fantastic resource for tracking information about numerous products, exchanging
data, directing customers to a landing page or website, downloading apps, paying bills (at restaurants
or other places), shopping, e-commerce, and so much more!
In this projrct, we will learn how we can utilize Python programming to create QR codes for any
specific purpose. We will generate some bar codes for specific purposes and also find out how we
can decode these generated codes with the help of some decoding steps. Finally, we will look at
some of the additional stuff that you can accomplish with the encoding and decoding of QR codes.
1
CHAPTER 2
METHODOLOGY
Step 1.First we have to do some installations of packages then we have to import that
packages.Following are the packages that we have to install.
pip install qrcode
pip install png
pip install open-cv
Step 2.In this step we have to generate a QR Code or to encode a QR Code. To generate a QR-
code for any data be it text, urls or numbers we can use two main methods – the API option or using
the CLI version of the package. We can generate a simple QR code using the make function of
qrcode and pass the data as its parameter. Firstly I simply put the data for QR code then created a
empty QR Code file and save this QR code in image.png
Step 3.I have imported the qrcode library and defined a variable that uses the make() function
of the qrcode library to generate a QR code and then saved the code using the save() function in the
directory.
Step 4.Changing Image and Box Size.We can change the QR code image size using the version
parameter in the QRCode class. It accepts an integer between 1 and 40 where 1 is equivalent to
21x21 matrix and 40 is equivalent to 185x185 matrix. Note that the data doesn’t fit in the specified
size, the version will scale up automatically. We can change the fill color of the QR code by using
the fill_color parameter.
Step 5.Now for decoding the QR Code we have to import libaray open-cv .OpenCV has an inbuilt
QR code detector. Using the detector we can decode data out of the QR code.
Step 6. If the image provided is a valid QR code, decoded data will be displayed. In this case, the
data of QR Code display by which we can go the any site otherwise the error will displayed.
2
CHAPTER 3
TOOLS/PLATFORMS
3.1 SOFTWARE REQUIREMENT:
a. IDE / FRAMEWORK: Visual code data. link
b. LIBRARIES: pyqrcode, pyopen-cv, pypng
c. OPERATING SYSTEM: Windows 11
d. LANGUAGE: Python, Version: - 3.10.4
pyqrcode:
The pyqrcode module is a QR code generator that is simple to use and written in pure python. The
module can automates most of the building process for creating QR codes. Most codes can be
created using only two lines of code.
pyopen-cv: OpenCV is a Python open-source library, which is used for computer vision in
Artificial intelligence, Machine Learning, face recognition, etc.
pypng:PyPNG is pure Python and has no dependencies. It requires Python 3.5 or any compatible
higher version.
Python: Python is a popular programming language. It was created by Guido van Rossum, and
released in 1991.
It is used for:
web development (server-side),
software development,
mathematics,
system scripting.
Visual code: Visual Studio Code is a streamlined code editor with support for development
operations like debugging, task running, and version control. It aims to provide just the tools a
developer needs for a quick code-build-debug cycle and leaves more complex workflows to fuller
featured IDEs, such as Visual Studio IDE.
3
CHAPTER 4
DESIGN & IMPLEMENTATION
4.1 ALGORITHM
For Encoding:
Step 1.Import libraries
Step 2.Store the data that you want to display after scanning the QR Code
Step 3.Create QR Code
Step 4.Generate QR code by using make() function
Step 5.Adding color features in QR code
Step 5. Compile the data into a QR code
array Step 6.Display the QR code
For Decoding:
Step 1.Import libraries for decoding the QR Code
Step 2. Give name of the QR Code Image file
Step 3. initialize the cv2 QR Code detector
Step 4. detect and decode the QR code
Step 5. if there is a QR code
print the data
else
Error will occure
4
4.2 FLOWCHART
Encoding QR code:
Fig.4.2.1 Encoding
5
Decoding QR code:
Fig.4.2.1 Decoding
6
4.3 SOURCE CODE
For Encoding:
import qrcode
#define the data
data = 'https://www.youtube.com/'
#create qrcode
QRCodefile =
"image.png" # Generating
the QR code
QRimage = qrcode.make(data)
# Saving image into a file
QRimage.save(QRCodefile)
qrObject = qrcode.QRCode(version=1, box_size=12,border=10)
# add data to the QR code
qrObject.add_data(data)
# compile the data into a QR code array
qrObject.make()
image = qrObject.make_image(fill_color="red")
image.save(QRCodefile)
For Decoding:
import pyqrcode
import cv2
# Name of the QR Code Image file
filename = "image.png"
# read the QRCODE image
image = cv2.imread(filename)
# initialize the cv2 QRCode detector
detector = cv2.QRCodeDetector()
# detect and decode
data, vertices_array, binary_qrcode = detector.detectAndDecode(image)
# if there is a QR code
7
# print the data
8
if vertices_array is not None:
print("QRCode data:")
print(data)
else:
print("There was some error")
9
CHAPTER 5
RESULT & DISCUSSION
5.1 OUTPUT
Fig .5.1.1 Encoding Output
Fig.5.1.2 Decoding Output
5.2 DISCUSSION
Fig.5.1.1 Encoding Output:If we scan this QR code then directly youtube will open.
Fig.5.1.2 Decoding Output:If we click on link with the help of ctrl+mouse click then also
the youtube will open.
5.3 APPLICATION
QR codes are widely used in a number of industries, be it information technology, online and
traditional marketing, advertising, manufacturing, construction, and many others. QR codes are one
of the easiest ways of providing information to customers and other individuals, allowing them to
9
Downloaded by KING Kong
extract valuable data with just scanning them with the help of an optical reader. They offer endless
possibilities, as their functionality is versatile. Once perceived as a tool for manufacturing concerns
and warehouses for tracking products on assembly lines and inventory management, they have
expanded their roots to many other industries.
Personalized Gift Messages
Inside Elevators
QR Codes in Museums
Bar Bathrooms
Creatives Ads for Mobile Applications
Mountain Chair Lifts and Safety Bars
Luggage Tags
Video and Charging Kiosks
Walking Trails and Historical Sites
10
Downloaded by KING Kong
CHAPTER 6
CONCLUSION
In this project, I showed how to generate QR Code in Python by using QRcode library and decode
them using the pyopen-cv library. In this project, we understood how easy it is to generate QR codes
with the help of Python programming in less than ten lines of code. With the installation of the
required libraries, you can generate your own QR codes and decode them accordingly. You can
embed useful URL links or important information in these QR codes and convey it to others in a
simplistic, highly structured format.
11
REFERENCE
https://www.geeksforgeeks.org/generate-qr-code-using-qrcode-in-python
https://www.javatpoint.com/generate-a-qr-code-using-python
https://www.makeuseof.com/how-to-create-and-decode-a-qr-code-using-python
12
Downloaded by KING Kong
Downloaded by KING Kong