Giter VIP home page Giter VIP logo

roee-by / ipcams_and_webcams_licence_plate_reader Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 3.0 21.63 MB

Using yolov4 object detection and image processing with OpenCV, the project enables detecting and reading licence plates and storing a log plates detected. The detection is achieved by detecing all the vehicles in the photo using a yolov4 tiny model that was converted to tflite and for each of the detected vehicles using image processing the lince plate is detected and after enhancing the contrast between the letters and the background the letters the licence plate is being processed by tesseract-ocr and we get the licence plate number.

License: MIT License

Python 10.79% Jupyter Notebook 89.21%
ipcam garage-door-opener garage-door webcam security-camera licence-plates

ipcams_and_webcams_licence_plate_reader's Introduction

IP Security Cameras and WebCameras Licence Plate Recognizer

Using yolov4 object detection and image processing with OpenCV, the project enables detecting and reading licence plates and storing a log plates detected. The detection is achieved by detecing all the vehicles in the photo using a yolov4 tiny model that was converted to tflite and for each of the detected vehicles using image processing the lince plate is detected and after enhancing the contrast between the letters and the background the letters the licence plate is being processed by tesseract-ocr and we get the licence plate number.

Usage Examples

the project was made light weight to enable deployment on low power hardware such as a raspberry pi or jetson nano or PCs and some usage example of it are:

  1. Automation of a garage door to open upon recognition of your car
  2. Keeping track of the vehicles entering to a certain event

execution example py recognize_video.py -a rtsp://[username]:[password]@[ipaddress]/[stream settings] -v True -cl obj.names -m tflite_vehicle_recognition.tflite

Getting Started

The repository includes the following files:

  1. pretrained tflite model which can recognize cars motorcycles trucks people ambulances and buses
  2. two folders of code files that are used to operate the process
  3. the following 3 scripts:
    1. recognize_video.py - this script allows licence plate recognition in video streams and supports the following options:
      • pay attention!! all options have default values if you are uncertain about the values leave them at default
      • -m/--model - path to tflite trained model [STRING]
      • -a/--address - stream address
        • [rtsp] = rtsp://[username]:[password]@[ipaddress]/[camera specific additions] [STRING]
        • [webcam] = 0 [INT]
      • -cl/--classes - path to classes file of the model [STRING]
      • -l/--log - creating a log of recognized numbers [True\False]
      • -v/--view - viewing result for debugging [True/False]
      • -sl/--sleep" - amount of sleep time between frames in seconds [DOUBLE]
      • -si/--size" - size of the pictures the model was trained on [INT]
      • -c/--confidence" - minimum probability to filter weak detections [DOUBLE]
      • -sig/--sigma - the alphabet allowed in the licence plate [STRING]
      • -lr/--lengthrange - the length allowed for a licence plate {format: 7-8 or 3-6 etc.} [STRING]
    2. recognize_photo.py - this script allows licence plate recognition in photos
      • -m/--model - path to tflite trained model [STRING]
      • -p/--picture - path to input picture [STRING]
      • -o/--output - path to output picture defaults to null (in this case there wont be a output image)[STRING]
      • -cl/--classes - path to classes file of the model [STRING]
      • -si/--size" - size of the pictures the model was trained on [INT]
      • -c/--confidence" - minimum probability to filter weak detections [DOUBLE]
      • -sig/--sigma - the alphabet allowed in the licence plate [STRING]
      • -lr/--lengthrange - the length allowed for a licence plate {format: 7-8 or 3-6 etc.} [STRING]
    3. take_photo.py - this script allows you to check that the video stream you chose works by taking a single picture from the stream, it supports the following options:
      • -a/--address - stream address
        • [rtsp] = rtsp://[username]:[password]@[ipaddress]/[camera specific additions] [STRING]
        • [webcam] = 0 [INT]
      • -o/--out - path for the output photo [STRING]

Prerequisites

you will need the following dependencies to use the project:

  • tesseract
  • scikit-image
  • numpy
  • pytesseract
  • tensorflow (version 2.3 and above)
  • opencv
  • argparse

Installing

To install the following dependencies with pip use the following commands:

  • tesseract
on debian(ubuntu/raspbian etc.)

apt-get install tesseract-ocr

or on windows 

https://github.com/UB-Mannheim/tesseract/wiki
  • scikit-image
py -m pip install scikit-image
  • numpy
py -m pip install numpy
  • pytesseract
py -m pip install pytesseract
  • tensorflow (version 2.3 and above)
py -m pip install tensorflow==2.3.0
  • opencv
py -m pip install opencv-python
  • argparse
py -m pip install argparse

Tensorflow Lite Model

if you want to you can always train the model yourself and try to achieve better results or using more powerful hardware on larger photos in this case you can change the size of the picture the model train on , for that purpose i included the google colab notebook that i used to train the model to train a new model create a dataset (i recommend using roboflow) and using the notebook train the model and export the following files:

  1. the tflite weights file which is in android\app\src\main\assets\yolov4-416-fp32.tflite
  2. the obj.names file

Built With

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Authors

  • Roee Ben Yosef - Initial work - Roee-BY

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Hat tip to anyone whose code was used
  • Inspiration
  • etc

ipcams_and_webcams_licence_plate_reader's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 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.