Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QR Code Scanner Web Application #164

Merged
merged 14 commits into from
Jun 13, 2021
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added GUIScripts/QR Code Scanner/Images/Final.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GUIScripts/QR Code Scanner/Images/LGM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions GUIScripts/QR Code Scanner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
![](http://ForTheBadge.com/images/badges/made-with-python.svg)
![](https://forthebadge.com/images/badges/built-by-developers.svg)</br>
[![Prettier](https://img.shields.io/badge/Code%20Style-Prettier-red.svg)](https://github.com/prettier/prettier)
![License](https://img.shields.io/badge/License-MIT-red.svg)</br>

## Description:
- Let's [**look**](https://github.com/Iamtripathisatyam/Awesome_Python_Scripts/blob/main/GUIScripts/QR%20Code%20Scanner/qr_code_scan.py) at a Python script that scans a picture and outputs the results.
- This project will read **QR** codes and show the information contained within them.
- It will first accept an image as input, then use **pzbar** to convert it to text, and then show the result.

## Procedure to follow:
- pip install **pyzbar**
- pip install **pywebio**
- pip install **Pillow**
- Change to the directory where the image will be scanned.
- Take the user's input and verify whether or not the input file name exists.
- Open the image and use **decode** to decode it.
- Finally, use **UTF-8** to decode the text and show it on the output screen.

Sample Output:

![hey](https://user-images.githubusercontent.com/69134468/121784148-eecccc80-cbcf-11eb-9241-e404fb7e3451.gif)

39 changes: 39 additions & 0 deletions GUIScripts/QR Code Scanner/qr_code_scan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# # # Import and Install following modules

from pyzbar.pyzbar import decode # pip install pyzbar
from PIL import Image # pip install Pillow
from pywebio.input import * # pip install pywebio
from pywebio.output import *
from pywebio.session import *
import time
import os

# Check if the image to be scanned exists or not with this function.


def is_exists(file_name):
if not os.path.exists(file_name):
# An error occurs if the image does not exist.
return "File does not exists"


# Change the directory where the scanned image is located.
os.chdir(r"C:\Users\Dell\Downloads")
while True:
clear()
put_html("<p><h3> QR Code Scanner </h3></p>")
file_name = input(placeholder="File name",
required=True, validate=is_exists) # Taking the image's name from the user
clear()
deco = decode(Image.open(f"{file_name}")) # Decode the image by opening it.
put_html("<p align=""center""><img src=""https://media.tenor.com/images/6297ebbab51f01867dfc0ff176a5b201/tenor.gif"" width=""300px""></p>") # Put the loading
time.sleep(4) # sleep for 3 seconds
clear() # clear the interface
put_html("<p align=""center""><h4>Scanned Text: </h4></p>")
# Display the results after decoding the scanned text
if not deco:
put_warning("Nothing has been found")
time.sleep(3)
else:
style(put_text(f"{deco[0][0].decode('utf-8')}"), 'color:blue')
time.sleep(5)
3 changes: 3 additions & 0 deletions GUIScripts/QR Code Scanner/requirements.txt"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pip install Pillow
pip install pyzbar
pip install pywebio