Number / License Plate Recognition is an image-processing technology with various features and used to identify vehicles by recognition of their number plates. This technology is used in various security and traffic applications. We were success to complete this project using simple Python code.

Steps Involved

Let’s take a sample image of a car with license plate visible and start with detecting the License Plate on that car. We will then use the same image for Character Segmentation and Character Recognition.

Step 1:  Resize the image to the required size and then grayscale it.

The code for the same is given below

img = cv2.resize(img, (620,480) )

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) #convert to grey scale

Resizing we help us to avoid any problems with bigger resolution images, make sure the number plate still remains in the frame after resizing. Gray scaling is common in all image processing steps.

Step 2: Every image will have useful and useless information, in this case for us only the license plate is the useful information the rest are pretty much useless for our program. This useless information is called noise. Normally using a bilateral filter (Blurring) will remove the unwanted details from an image. The code for the same is blurred

gray = cv2.bilateralFilter(gray, 13, 15, 15)

Step 3: The next step is interesting where we perform edge detection. There are many ways to do it, the most easy and popular way is to use the canny edge method from OpenCV.

edged = cv2.Canny(gray, 30, 200)

Step 4: Now we can start looking for contours on our image



Above code provides the contour within image and via which we can track the number with a rectangular bound.

To filter the license plate image among the obtained results, we will loop though all the results and check which has a rectangle shape contour with four sides and closed figure. Since a license plate would definitely be a rectangle four-sided figure.

The output is shown below as we can detect number plate.