![]() The code above doesn't work for second image if used as it is, because I am filtering the search to polygons with 4 sides. Let me know if you need help with that too. The parsing will be more accurate if you perspective transform your number plate image to the bounding box rectangle and also remove the extra borders around. ![]() I get the below output for the sample image you shared. gray = cv2.cvtColor(roi, cv2.COLOR_BGR2GRAY) Now pass this cropped image into your tesseract. The output is the number plate as attached below: #crop the rectangle to get the number plate. X,y,w,h = cv2.boundingRect(largest_rectangle) #find the polygon which has the largest size. If len(approx)=4: #polygons with 4 points is what I need. #the contours can be approximated to minimum polygons, polygons of size 4 are probably rectanglesĪpprox = cv2.approxPolyDP(cnt,0.01*cv2.arcLength(cnt,True),True) #once I have the contours list, i need to find the contours which form rectangles. Thresh = cv2.adaptiveThreshold(gray,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY,11,2)Ĭontours,h = cv2.findContours(thresh,1,2) ![]() #need this to extract the name plate from the image. #perform adaptive threshold so that I can extract proper contours from the image import numpy as np import cv2 from PIL import Image import pytesseract as tess 2. Imports: For this project we need numpy and pillow python libraries with openCV and pytesseract. Now, let’s dive into the number plate recognition code. Gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) Before proceeding ahead, please download the source code: Automatic Number Plate Recognition. Img = cv2.imread('/home/muthu/Documents/3r9OQ.jpg') Read the code comments to understand what I am trying to do. You need to extract the number plate from the image and then send the image to your tesseract. Here is a rough idea on how you can solve your problem.
0 Comments
Leave a Reply. |