Object Recognition using CNN model for RTO Web Application.

Sachin Joshi
4 min readAug 27, 2021

In this Blog we will ,

👉Create a model that will detect a car in a live stream or video and recognize characters on number plate of the car .

👉Secondly , it will use the characters and fetch the owners information using RTO API’s .

👉Create a Web portal where all this information will be displayed (using html,css,and js)

📌 Note : You may create your own detection model .

Now let’s us start with the Coding Part. Here we have imported some library then trained our model to detect number plate of our car

Now import the image from your local device and convert the image of the car captured in Black and White.

Now we’ll need to apply some pre-processing in OpenCV to make contour detection work. Namely we convert the image to gray scale, apply bilateral filter with cv2.bilateralFilter. After that, using OpenCV’s bilateralFilter fuunction, we reduce the noise in the image for a better edge detection.

cv2.drawContours() function takes five arguments-

  1. The first argument is the image in which the detected contours will be drawn.
  2. The second argument is the variable that stores all the detected contours.
  3. Then, the third argument is contour indexes. Here we use the value -1 which will use the indexes of all the contours detected in our image. Hence all of the contours will be drawn on the image.
  4. After that, the fourth argument is the color in which contours will be drawn.
  5. The fifth argument is the thickness of the contour curve to be drawn.

A series of convenience functions to make basic image processing functions such as translation, rotation, resizing, skeletonization, and displaying Matplotlib images easier with OpenCV

if you have the contours detected, you can crop the contours by adding the following lines to your code, just after contours, hierarchy = cv2.findContours(threshold, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE):

You can extract text from images with EasyOCR, a deep learning-based OCR tool in Python. EasyOCR performs very well on invoices, handwriting, car plates, and public signs as shown above.

Now inOpenCV-Python is a library of Python bindings designed to solve computer vision problems. cv2.putText() method is used to draw a text string on any image.

Syntax: cv2.putText(image, text, org, font, fontScale, color[, thickness[, lineType[, bottomLeftOrigin]]])

Parameters:
image: It is the image on which text is to be drawn.
text: Text string to be drawn.
org: It is the coordinates of the bottom-left corner of the text string in the image. The coordinates are represented as tuples of two values i.e. (X coordinate value, Y coordinate value).
font: It denotes the font type of the text . Some of font types are as following: FONT_HERSHEY_SIMPLEX, FONT_HERSHEY_PLAIN, , etc.
fontScale: Font scale factor that is font-specific base size.
color: It is the color of text you want. For BGR(Blue,Green,Red), we pass a tuple. eg: (255, 0, 0) for blue color.
thickness: It is the thickness of the line in px(Pixels).
lineType: This is an optional parameter.It gives the type of the line to be used.
bottomLeftOrigin: This is an optional parameter. When it is true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner.

Return Value: It returns an image.

Output
Web App

You can integrate this python code in with CGI Programming . I have shown in the below link on how to integrate it with java script and CGI.

Important Links

You can find the source code Below:

https://github.com/sachinjoshi72/Object-Recognition-using-CNN-model-for-RTO-Web-Application.

You can find connect me here:

— — — — — — — — — — — — Thankyou, Do share — — — — — — — — — — —

--

--