Code Monkey home page Code Monkey logo

turkish-license-plate-detector's Introduction

License Plate Detector

This repository contains the codes, samples images and tutorial necessary to train a haar cascade using Python and OpenCV to detect turkish and european union license plates.

1 - Gather pos images put in positive_images folder For EU license plates you can find positive image dataset in openalpr repository: https://github.com/openalpr/train-detector/tree/master/eu

2 - Gather neg images put in negative_. You can also find negatives images in the same repository.

3 - Resize positive images to 200x200. We can use imagemagick tool to resize our images. Used a script to resize all images in a folder:

for i in *.JPG; do
    printf "Resize $i\n"
    convert "$i" -resize 200x200 "$i"
done

4 - Now let's create a text file containing all the negative image names.

find ./negative_images -iname "*.jpg" > negatives.txt

5 - In the same way create a text file for positive images

find ./positive_images -iname "*.jpg" > positives.txt

5 - Run sample creator script. This script will create 10 samples for each positive image. Change the positive image folder path and negative text file path and the number of sample to be created

6 - Create vec file:

opencv_createsamples -info info/info.lst -num 4000 -w 52 -h 13 -vec positives.vec

7 - Let's start training. Use less pictures in training than created samples: 4000 -> 3800. And also try to keep positive/negative images ratio to 2:1.

opencv_traincascade -data data -vec positives.vec -bg negatives.txt -numPos 3800 -numNeg 1900 -numStages 10 -w 52 -h 13

### If you want to run training in background;
nohup opencv_traincascade -data data -vec positives.vec -bg negatives.txt -numPos 3800 -numNeg 1900 -numStages 10 -w 52 -h 13 &

In my mac the last step took about 7 hours. (Processor: i5, Memory: 8 GB)

8 - After the training, you will see a cascade file under data. Let's test our trained cascade using test.py. But first change the cascade file path in test.py and then run commnand:

 python test.py --image [IMAGE_PATH]

9 - Output

alt text

The output is not great but still works. Will try to rerun training after collecting more images.

Features to be added

  • Reading license plate number using Tesseract
  • Capturing license plates in videos

turkish-license-plate-detector's People

Contributors

muratlutfigoncu avatar

Stargazers

 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

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.