InfinityCodeX

Unlock the power of Python, Data Science, Machine Learning, and Deep Learning with our comprehensive guides! Whether you're a beginner eager to dive into AI or an experienced professional looking to sharpen your skills, our blog offers easy-to-follow tutorials, insightful tips, and expert advice to fuel your AI career. Dive in today and start mastering the cutting-edge technologies shaping the future!

Easy Number Plate Scanner Project Using OpenCV



Before diving into the project let us discuss the term Artificial Intelligence, then we will see what is computer vision, and finally we will start with our project.


CAR
CAR

What is Artificial Intelligence?

The theory and the development of a computer system able to perform tasks normally requiring human intelligence, such as visual perceptron, speech recognition, etc.

Now let’s divide this term into 2 parts i.e Artificial and Intelligence.

So what do we mean by Artificial, Anything that is made by humans things which are not natural and what do we mean by Intelligence, It is the ability to understand think and learn.

When we combine both these terms Artificial + Intelligence we get a field where it seems like machines have human intelligence. The goal of AI is to mimic the human brain and create systems that can function intelligently and independently.

                                           
ARTIFICIAL INTELLIGENCE
ARTIFICIAL INTELLIGENCE

What is Computer Vision?

Human vision is far advance and complex than any camera on this planet. As the AI field is developing rapidly computer vision plays an important role in it.

Computer Vision is the way of teaching intelligence to the machines and making them see things just like humans. So what happens when a human sees an image, that human will be able to recognize that image through patterns, colors, etc. So simply we can say that computer vision is what allows the computer to see and process visual data like humans. Computer vision involves analyzing images to produce useful information. For example, your face recognition system can easily detect your face and unlock your phone quite easily.

Computer vision is a form of Artificial Intelligence that let’s computer identify things using various algorithms trained to collect predefined features helping them pick objects out of the crowd potentially millions of objects with faster and faster recognition.


COMPUTER VISION
COMPUTER VISION

What is OpenCV?

OpenCV stands for Open Source Computer Vision it is a library of programming functions mainly aimed at real-time computer vision, it is originally developed by Intel and it was later supported by Willow Garage and now it’s supported and maintained by itseez.


OPENCV
OPENCV
Now OpenCV is a cross-platform library which means that we can use it on Mac, Windows, and Linux.
OPERATING SYSTEMS
OPERATING SYSTEMS
You can work on OpenCV with languages such as C, C++, Python, etc. Your project will be done using python. OpenCV is free and Open source, easy to use, and install.

To install OpenCV just go to the command prompt and type:
                       
pip install opencv-python

To know more about the image processing by the computer you can read this article, which will help you a lot.


Now let’s began with the project, so here is the final output of our project.


FINAL RESULT
FINAL RESULT
This project will not only identify the number plate of the vehicle, but it will take a snap-shot of it and save it in a folder by clicking "S".

Don’t forget to download this and save it in the same folder or the folder you want.

harrcascade_russian_plate_number

This project will be created in five easy steps:


Step one, you will be importing some essential libraries.

Step two, you will be creating haarcascade variable.

Step three, you will be initializing the variables. 

Step four, the most important step in this you will be creating a frame and creating an area where the number plate would be cropped in real-time.

Step five, you will be creating a snap-shot feature where if you click "S" the snap-shot will be taken of that cropped number plate and saved it in a folder. 

# Import Import Libraries

import cv2                    #For computer vision
import numpy as np     # provides a high-performance multidimensional array

# ----------------------------------------------------------------------------------------------------------

# Creating Haarcascade Variable

nplateCascade =
cv2.CascadeClassifier("E:\OpenCV_PROJECT\Resources\haarcascade_russian_plate_number.xml")

# ---------------------------------------------------------------------------------------------------------

# Initializing Variable

minarea = 500
count = 0
framewidth = 6400
frameheight = 480

# ---------------------------------------------------------------------------------------------------------

# Number Plate Capturing

web_cap = cv2.VideoCapture(0)
web_cap.set(3,framewidth)
web_cap.set(4,frameheight)
web_cap.set(10,1000) # Brightness id = 10 and 100 intensity level

while True :
    success, img = web_cap.read()

    imgGray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

    numberplates = nplateCascade.detectMultiScale(imgGray, 1.1, 4) # 4 : minimum neighbour

    # Create bounding box

    for (x, y, w, h) in numberplates:
        area = w*h
        if area > minarea:
            cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0),2) # (x,y) : Initial points & (x+w,y+h) : Diagonal points
            cv2.putText(img,"Number plate",(x,y-5),cv2.FONT_HERSHEY_COMPLEX,1,(255,0,0),2)
            imgRoi = img[y:y+h,x:x+w] # Region of number plate
            cv2.imshow("ROI IMAGE", imgRoi)


# ---------------------------------------------------------------------------------------------------------

# Saving Snap-Shot

    cv2.imshow("Video",img)
    if cv2.waitKey(1) & 0xFF == ord("s"):
        cv2.imwrite("Resources/scan/NoPlate "+str(count)+".jpg",imgRoi)
        cv2.rectangle(img,(0,200),(640,300),(0,255,0),cv2.FILLED)
        cv2.putText(img,"scan saved",(150,265),cv2.FONT_HERSHEY_COMPLEX,2,(0,255,0),2)
        cv2.imshow("Result",img)
        cv2.waitKey(5000)
        count += 1



So we hope that you enjoyed this project. If you did then please share it with your friends and spread this knowledge.

Follow us at :

Instagram : 

https://www.instagram.com/infinitycode_x/


Facebook :

https://www.facebook.com/InfinitycodeX/


Twitter :

https://twitter.com/InfinityCodeX1

1 comment:

  1. Sublime post. I genuinely value scrutinizing and moreover esteem your work. This thought is a viable technique for further developing data. Keep on sharing this kind of articles, Thank you.AI in Safety Management

    ReplyDelete

No Spamming and No Offensive Language

Powered by Blogger.