Code Monkey home page Code Monkey logo

plate_detect_and_recognize's Introduction

Update

(29/7/2020)

  • Rename utils.py to local_utils.py to avoid conflicit with default Python library utils.py.
  • Replace error index out of range to No License plate is founded!.
  • In case error No License Plate is founded! popped up, try to adjust Dmin from get_plate() function. Keep in mind that larger Dmin means more highly plate's information is lost.

Tools and Libraries

  • Python==3.6
  • Keras==2.3.1
  • Tensorflow==1.14.0
  • Numpy==1.17.4
  • Matplotlib==3.2.1
  • OpenCV==4.1.0
  • sklearn==0.21.3

Detect and Recognize Vehicle’s License Plate with Machine Learning and Python




Credit

sergiomsilva

plate_detect_and_recognize's People

Contributors

quangnhat185 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plate_detect_and_recognize's Issues

Detect 0 letters

Hey my men,
I'm trying to reproduce you project. I succeed in part1.
However, when I want to start part2, I stuck at detect 0 letters.
I used python3.7 opencv 4.2.0 numpy 1.18.5 matplotlib 3.2.2 with Jupyter notebook.
Any help would be appreciated!!!

End-to-end

image
Everytime i run the findContours function from cv2

how to re-train wpod-net?

hello anh! em đang muốn train lại thằng wpod ! mà cái môi trường của nó setup khó quá ( vì cũ quá rồi ). xưa anh train lại có cần cài ubuntu-16 opencv, tensorflow giống hưỡng dẫn để train k? hay anh có cách nào chỉ em với ạ. em cảm ơn

Issue reading other plates

Hi there. As soon as I change the index number in image_plates to read other plate numbers the code stops recognising glob module and the variable 'image_plates'
Screenshot 2020-09-12 at 3 35 38 PM
. Even if I change it back to how it was the error doesn't go away. Any suggestions on what can be done?

Dimension error in prediction

I used the character recognition model from this repo and got this error while predicting the character.
ValueError: Input 0 of layer bn_Conv1 is incompatible with the layer: expected ndim=4, found ndim=5. Full shape received: (None, 80, 40, 2, 32)
This is my image:
image

any help will be welcomed.

wpod-net.h5 file

Hi @quangnhat185 ,

Can you please let me know whether you have trained the WPOD-Net from the scratch and saved the weights in wpod-net.h5 file or You have taken it from @sergiomsilva repo?

Thanks
Harsha

Problem with square number plates

Hello! I'm a beginner, tell me what could be the problem, it does not determine the outline of licensed symbols for square numbers

and also when letters of different sizes are also not defined 😰
image

LICENSE

When I run the code in anaconda prompt I see this error...

File "License", line 2
MIT License
^
SyntaxError: invalid syntax

can anyone help me through it?

Error when importing MobileNetV2.


ImportError Traceback (most recent call last)
in
4
5 from keras.preprocessing.image import ImageDataGenerator
----> 6 from keras.applications import MobileNetV2
7 from keras.layers import AveragePooling2D
8 from keras.layers import Dropout

ImportError: cannot import name 'MobileNetV2' from 'keras.applications' (C:\Users\IMAKA\AppData\Roaming\Python\Python39\site-packages\keras\applications_init_.py)

I HAVE ALL THE PRE REQUSISTS INSTALLED LOCALLY.

Does the provided 1st stage model is for only detection of LP or for the Vehicle as well

Hello Quang,

Firstly thanks for your in depth article on medium.com.

Its mentioned in the Sérgio Montazzolli paper that, three main steps:
Vehicle detection, LP detection and OCR.

My question is:
Does the wpod-net.h5 trained model also detects the Vehicle in a given raw image or its the second stage (LP detection).

If the wpod-net.h5 is only for detecting the LP from output of 1st stage(Vehicle Detection), where can I get the trained model for Vehicle Detection.

Please let me know if anything is not clear.

Thanks
Harsha

I want to test the WPOD network on my own Dataset and measure the model metrics (mAP and Recall)

Hi Quang,

I want to test only the WPOD Network on my own dataset(10K Cropped Images of Cars) but not the End to End Model(Full ALPR). Depending on the Model metrics, I want to strengthen the WPOD model by doing transfer learning by training WPOD Network with my Dataset.

  1. Can you please tell me how can I test the WPOD model with metrics (mAP and Recall).

  2. Any idea how can I label my 10K cropped car images with less effort

Thank in Advance

Regards
Harsha

I'm getting an import error for detect_lp

I've tried windows and linux and I get this trace:
from utils import detect_lp
ImportError: cannot import name 'detect_lp' from 'utils' (F:\Python\ANPR\venv\lib\site-packages\utils_init_.py)

Converter wpod-net.h5 to tflite

Hi bro
Thank you for share code
I have problem converter .h5 to tflite
I using code
import tensorflow as tf
from keras.models import model_from_json

Model reconstruction from JSON file

with open('wpod-net.json', 'r') as f:
model = model_from_json(f.read())

Load weights into the new model

model.load_weights('wpod-net.h5')
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_model)

and TypeError: call() got an unexpected keyword argument 'training'

Please help me to answer the question.
Thank you so much!

local_utils nature

Hello, id like to know a little more about the file local_utils. Looks like it is the responsible for all the magic to happen. Where did this file came from? Is it also from the author of the trained model?

I am willing to know a little more about it so please if you could reference its author would be very helpful for me. Thanks

[Question] Currently model can be run smoothly on RPi Zero W?

Hi Quang, thank you very much for your great work. We a Vietnamese startup company base in HCM City. We're having a smart parking project and our hardware is running on RPi Zero W and use Pi Camera for car detection and license plate recognition.
Let me know if you can give a hand to help project go futher and become a part of project.
Thanks and Best Regards,
Kenny

Plate character segmentation with OpenCV error

Hi,when trying to determine the contours of the license characters,I am getting an error called digit_w and digit_h are undefined.I tried replacing these with the extracted box's width and height.And then the code is working again.

Help in calculating Model metrics

Hello Quang,

Thank you for the very helpful repo.

I have labelled my own dataset and used the WPOD-Net to find the license Plates coordinates. Now, I want to calculate the Average Precision metric so that I can evaluate the WPOD-Net on my dataset. If the Average Precision is bad, I want to train the WPOD-Net on my dataset and Improve the Model.

So, do you have any inputs for calculating the AP metric until License Plate detection.

Thanks

W not recognized

This issue I find a showstopper for me actually.
all Ws even the ones that are clear and straight are recognized as N. I guess this is something to do with the training.
I don't expect a solution here (but feel free to surprise me :)) but just to let you know that you might be expecting that.

bounding boxes not found

Hi,
First of all thank you for this repo. I enjoyed it a lot.
I see that there is an issue with the boxes around characters.
When using
cv2.findContours
sometimes the contours are not found. I find that it is in large extent because of the frames that are around the plates.
I have solved it with removing a margin of 5% from the plate picture.
(
Later of course the coordinates of the frames must be adjusted for this margin in respect to the original picture.)

It is not the most elegant solution but it helped:

    cont, _  = cv2.findContours(binary, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
    marginh=0
    marginw=0
    if(len(cont)<=1):
        print('havent found any characters -  cutting margings')
        m=0.05
        marginh=round(m*maxh)
        marginw=round(m*maxw)
        cut_plate_image=plate_image[marginh:maxh-marginh,marginw:maxw-marginw]
        cut_binary=binary[marginh:maxh-marginh,marginw:maxw-marginw]
        cont, _  = cv2.findContours(cut_binary, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
        test_roi = cut_plate_image.copy()

    cut_plate_image=plate_image[marginh:maxh-marginh,marginw:maxw-marginw]
    cut_binary=binary[marginh:maxh-marginh,marginw:maxw-marginw]

And then of course adjust when cropping images:


# extract the img
            curr_num = cut_binary[y:y+h,x:x+w]
            curr_num = cv2.resize(curr_num, dsize=(digit_w, digit_h))
            _, curr_num = cv2.threshold(curr_num, 220, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
            curr_num_orig = cut_plate_image[y:y+h,x:x+w]
            crop_characters.append(curr_num) 
            crop_characters_orig.append(curr_num_orig)

Ram blowing up on windows

model.predict() never returns and the kernels become dead on windows, but the same thing is working on linux machines

How to ignore specific contours in an image?

I would like it to ignore the top non-English letters as I don't need them, but I don't know how to ignore them. I thought about removing the index of these areas but unfortunately the index is not the same for all plate numbers so it's not going to work. Does anyone know how I can take the contours of the numbers and the bottom English letters only without the top non-English letters. I would highly appreciate your help.
The image:
c1
The code:
`
import cv2
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import gridspec
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
img = cv2.imread('c1.png')
img1 = img.copy()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
blur = cv2.GaussianBlur(gray,(7,7),0)

binary = cv2.threshold(blur, 180, 255,cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1]

kernel3 = cv2.getStructuringElement(cv2.MORPH_RECT, (3, 3))
thre_mor = cv2.morphologyEx(binary, cv2.MORPH_DILATE, kernel3)
contours, hierarchy = cv2.findContours(thre_mor,cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
def sort_contours(cnts,reverse = False):
i = 0
boundingBoxes = [cv2.boundingRect(c) for c in cnts]
(cnts, boundingBoxes) = zip(*sorted(zip(cnts, boundingBoxes),key=lambda b: b[1][i], reverse=reverse))
return cnts
cont, _ = cv2.findContours(binary, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
crop_characters = []
digit_w, digit_h = 30, 60
for c in sort_contours(cont):
(x, y, w, h) = cv2.boundingRect(c)
ratio = h/w
if 1<=ratio<=10:

    if h/img.shape[0]>=0.20:
        cv2.rectangle(img1, (x, y), (x + w, y + h), (255, 0,0), 2)
    
       
        curr_num = thre_mor[y:y+h,x:x+w]
        curr_num = cv2.resize(curr_num, dsize=(digit_w, digit_h))
        _, curr_num = cv2.threshold(curr_num, 220, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
        crop_characters.append(curr_num)

print("Detect {} letters...".format(len(crop_characters)))
fig = plt.figure(figsize=(10,6))
plt.axis(False)
plt.imshow(img1)
plt.show()`

The output:
output

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.