Reconhecer a placa do carro é uma tarefa muito importante para um sistema de segurança baseado em câmera de vigilância. Podemos extrair a placa de uma imagem usando algumas técnicas de visão computacional e, em seguida, podemos usar o reconhecimento óptico de caracteres para reconhecer o número da licença. Aqui, vou guiá-lo por todo o procedimento desta tarefa.

Requisitos:

opencv-python 3.4.2
numpy 1.17.2
skimage 0.16.2
tensorflow 1.15.0
imutils 0.5.3

Exemplo:

Entrada:

Saída:
29A33185



def preprocess(self, input_img): 
  
    imgBlurred = cv2.GaussianBlur(input_img, (7, 7), 0) 
      
    
    gray = cv2.cvtColor(imgBlurred, 
                        cv2.COLOR_BGR2GRAY)  
      
    
    sobelx = cv2.Sobel(gray, cv2.CV_8U,  
                       1, 0, ksize = 3)   
      
     
    ret2, threshold_img = cv2.threshold(sobelx,0, 255, 
                           cv2.THRESH_BINARY + cv2.THRESH_OTSU) 
 
    element = self.element_structure 
    morph_n_thresholded_img = threshold_img.copy() 
    cv2.morphologyEx(src = threshold_img, 
                     op = cv2.MORPH_CLOSE, 
                     kernel = element,  
                     dst = morph_n_thresholded_img) 
      
    return morph_n_thresholded_img