Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. # Find characters in the resulting images
  2. def segment_characters(image) :
  3.  
  4. # Preprocess cropped license plate image
  5. img = cv2.resize(image, (333, 75))
  6. img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  7. _, img_binary = cv2.threshold(img_gray, 200, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)
  8. img_erode = cv2.erode(img_binary, (3,3))
  9. img_dilate = cv2.dilate(img_erode, (3,3))
  10.  
  11. LP_WIDTH = img_dilate.shape[0]
  12. LP_HEIGHT = img_dilate.shape[1]
  13.  
  14. # Make borders white
  15. img_dilate[0:3,:] = 255
  16. img_dilate[:,0:3] = 255
  17. img_dilate[72:75,:] = 255
  18. img_dilate[:,330:333] = 255
  19.  
  20. # Estimations of character contours sizes of cropped license plates
  21. dimensions = [LP_WIDTH/6, LP_WIDTH/2, LP_HEIGHT/10, 2*LP_HEIGHT/3]
  22.  
  23. # Get contours within cropped license plate
  24. char_list = find_contours(dimensions, img_dilate)
  25.  
  26. return char_list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement