INFORMATION PRACTICES PROJECT WORK aNpr And Ticketing System: 12th science SUBMITTED TO: SUBMITTED BY: Mr. RAJEEV PATEL PRIYANSHU RAJ PGT (CS) ROLL No:23761387 CERTIFICATE This is to certify that project and titled as ANPR (Automatic Number Plate Recognition) and Ticketing System Is Bonafide work done by Priyanshu Raj of class XII-A (Science) session 2023-2024 in partial fulfilment of CBSE AISSCE Examination 2023-2024 and has been carried out under my direct supervision and guidance. This report or a similar report on the topic has not been submitted for any other examination and does not form a part of any other course undergone by the candidate. SIGNATURE SIGNATURE Mr. RAJEEV PATEL Mr. LAL SHAH P.G.T (CS) PRINCIPAL CONTENTS 1. 2. 3. 4. 5. 6. 7. 8. Acknowledgement Introduction Hardware Requirement Resources Used MYSQL Python Output Screen Bibliography ACKNOWLEDGEMENT I undertook this project work as a part of my XII Informatics Practices course. I had tried to apply my best of knowledge and experience gained during the study and class work experience. However, developing software system is generally are quite complex and time-consuming process. It requires a systematic study, insight vision and professional approach during the design and development. I would like to extend my sincere thanks and gratitude to my teacher Mr. Rajeev Patel. I am very much thankful to our principal Mr. Lal Shah for giving valuable time and moral support to develop this software. I would like to take the opportunity to extend my sincere thanks and gratitude to my parents for being a source of inspiration and providing time and freedom to develop the software project PRIYANSHU RAJ XII – Science INTRODUCTION This software project is developed to automate the functionalities of a Toll Collection System. The purpose of the software project is to develop a program which provides a fast and secure platform for toll collection or various applications requiring vehicle registration. This program mainly brings forth the uses of Machine learning model to detect a number plate in real time using a live video stream. This project mainly consists of a image recognition model which crops a rectangular area which resembles a number plate this image is then saved to the system and then character recognition is performed on the cropped image Using Easy OCR which returns the characters this is then used to generate ticket using the MYSQL database which keeps Information of every vehicle, then the ticket record is updated to the Database. This Provides a Secure Fast and Hassle Free way of maintaining vehicle record. REQUIREMENT HARDWARE 4 GB RAM or more 1 GB Free Space Webcam Graphics Card For Faster Processing SOFTWARE USED Anaconda: Anaconda is a distribution of the Python and R programming languages for scientific computing, that aims to simplify package management and deployment. Visual Studio Code: Visual Studio Code, also commonly referred to as VS Code, is a sourcecode editor developed by Microsoft for Windows, Linux and macOS. MYSQL 8.0.31: MySQL is an open-source relational database management system Python 3.7.11: Python is a high-level, generalpurpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation RESOURCES USED Pandas: Pandas is a software library written for the Python programming language for data manipulation and analysis. EasyOCR:EasyOCR, as the name suggests, is a Python package that allows computer vision developers to effortlessly perform Optical Character Recognition. OpenCV: OpenCV is a library of programming functions mainly for real-time computer vision. MysqlConnector: MySQL Connectors provide connectivity to the MySQL server for client programs Haar Cascades: Haar cascade is an algorithm that can detect objects in images, irrespective of their scale in image and location. This algorithm is not so complex and can run in real-time. MYSQL Host: localhost User: root Password: 1234 Database: new_toll Tables Structures PYTHON CODE import cv2 import easyocr import mysql.connector import pandas as pd from datetime import datetime #Program Loop while True: # Image Recognition def ANPR(): harcascade = "model/haarcascade_russian_plate_number.xml" cap = cv2.VideoCapture(0) cap.set(3, 640) # width cap.set(4, 480) #height min_area = 500 count = 0 while True: success, img = cap.read() plate_cascade = cv2.CascadeClassifier(harcascade) img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) plates = plate_cascade.detectMultiScale(img_gray, 1.1, 4) for (x,y,w,h) in plates: area = w * h if area > min_area: cv2.rectangle(img, (x,y), (x+w, y+h), (0,255,0), 2) cv2.putText(img, "Number Plate", (x,y-5), cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, (255, 0, 255), 2) img_roi = img[y: y+h, x:x+w] cv2.imshow("ROI", img_roi) cv2.imshow("Result", img) if cv2.waitKey(1) & 0xFF == ord('s'): cv2.imwrite("plates/scaned_img_" + str(count) + ".jpg", img_roi) cv2.rectangle(img, (0,200), (640,300), (0,255,0), cv2.FILLED) cv2.putText(img, "Plate Saved", (150, 265), cv2.FONT_HERSHEY_COMPLEX_SMALL, 2, (0, 0, 255), 2) cv2.imshow("Results",img) cv2.waitKey(500) count += 1 break def Vehicles(): col = ["Number","Company","Model","Fuel","NoOfWheels","DOP","Sno"] df = pd.DataFrame(columns=col) query = "SELECT * FROM Vehicle;" cursor.execute(query) # Fetch all rows rows = cursor.fetchall() # Process the rows for row in rows: df = df.append(pd.Series(row,index=col),ignore_index=True) print(df) def Owner(): query = "SELECT * FROM Owner;" cursor.execute(query) # Fetch all rows rows = cursor.fetchall() # Process the rows for row in rows: print(row) def Ticket(): #Scan The Text reader = easyocr.Reader(["en"]) result = reader.readtext("plates/scaned_img_0.jpg") res = (result[-1][1],) query = "SELECT * FROM Vehicle WHERE V_no = %s" cursor.execute(query,res) curtime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") row = cursor.fetchall() #Generate Ticket print("######################################\n ############################") print("---") print("Vehicle_No : ",row[0][0]) print("Vehicle : ",row[0][1],row[0][2]) print() print(curtime) print() print("Amount : Rs100") print() print("######################################") TICKET \n########## db_config = { 'host': 'localhost', 'user': 'root', 'password': '1234', 'database': 'new_toll', } # Establish a connection to the MySQL server try: connection = mysql.connector.connect(**db_config) # Create a cursor object to execute SQL queries cursor = connection.cursor() except mysql.connector.Error as err: print(f"Error: {err}") # User Interface def prog(): print() print() print() print("------------------------------------------------\n Automatic Number Plate Recognition \n-----------------------------------------------") print("---") print("1 - Scan a Number Plate") print("") print("---") print("") print("2 - Generate Ticket For Last Scan") print("") print("---") print("") print("3 - View Vehicles") print("") print("---") print("") print("4 - View Owners") print("") print("---") print("") print("5 - Exit") print("") print("---") print("") i = input("Select An Option \n \n") if i == "1": ANPR() prog() elif i == "2": Ticket() prog() elif i == "3": Vehicles() prog() elif i == "4": Owner() prog() elif i == "5": exit() prog() # Close the cursor and connection if 'cursor' in locals(): cursor.close() if 'connection' in locals() and connection.is_connected(): connection.close() print("MySQL connection is closed") OUTPUT SCREEN -----------------------------------------------Automatic Number Plate Recognition -------------------------------------------------1 - Scan a Number Plate --2 - Generate Ticket For Last Scan --3 - View Vehicles --4 - View Owners --5 - Exit --Select An Option Option 1. # Video Steam # Region Of interest #Plate Saved Option 2. Neither CUDA nor MPS are available - defaulting to CPU. Note: This module is much faster with a GPU. ###################################### TICKET ###################################### --Vehicle_No: UP64A1111 Vehicle: Bajaj Platina 2024-01-03 17:51:07 Amount: Rs100 ###################################### Option 3. Number Company Model Fuel NoOfWheels DOP Sno 0 UP64A1111 Bajaj Platina Petrol 2010-12-12 1 Option 4. (1, 'Sachin', 'NH-1 A-144') (2, 'Rajan', 'NH-1 A-145') (3, 'Virat', 'NH-1 A-146') 2 Bibiliography 1.Youtube.com 2.W3Schools.com 3. GeeksforGeeks.com