Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Find characters in the resulting images
- def segment_characters(image) :
- # Preprocess cropped license plate image
- img = cv2.resize(image, (333, 75))
- img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
- _, img_binary = cv2.threshold(img_gray, 200, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)
- img_erode = cv2.erode(img_binary, (3,3))
- img_dilate = cv2.dilate(img_erode, (3,3))
- LP_WIDTH = img_dilate.shape[0]
- LP_HEIGHT = img_dilate.shape[1]
- # Make borders white
- img_dilate[0:3,:] = 255
- img_dilate[:,0:3] = 255
- img_dilate[72:75,:] = 255
- img_dilate[:,330:333] = 255
- # Estimations of character contours sizes of cropped license plates
- dimensions = [LP_WIDTH/6, LP_WIDTH/2, LP_HEIGHT/10, 2*LP_HEIGHT/3]
- # Get contours within cropped license plate
- char_list = find_contours(dimensions, img_dilate)
- return char_list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement