Giter Club home page Giter Club logo

vehicle-plate-ocr's Introduction

Vehicle-Plate-OCR

Implementation of an image processing pipeline to extract and recognize text from a number plate using OpenCV and Tesseract OCR. It captures frames from a webcam, allows you to save an image by pressing the spacebar, processes the saved image, detects the number plate, crops it, and finally uses Tesseract OCR to extract the text from the number plate. ๐Ÿš˜๐Ÿ“ธ

How Program Work

  • It initializes the necessary libraries and sets the Tesseract OCR executable path.
    pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
  • It captures frames from the webcam using OpenCV's VideoCapture function and displays them in a window.
    cam = cv2.VideoCapture(0)
  • While running, the program waits for key events. If the SPACE key is pressed, it saves the current frame as an image file.
  • After capturing an image, it reads the saved image using OpenCV's imread function and performs a series of image processing steps:
    • Resizes the image to a specific width using imutils.resize.
    • Converts the image to grayscale using cv2.cvtColor.
    • Reduces noise in the image using bilateral filtering with cv2.bilateralFilter.
    • Detects edges in the image using Canny edge detection with cv2.Canny.
    • Finds contours in the image using cv2.findContours.
    • It draws the contours on the image using cv2.drawContours and displays the image with drawn contours.
  • It sorts the contours by area and selects the top contours.
  • It loops through the selected contours and checks if any contour has four sides. If it does, it considers it as the number plate contour and performs the following steps:
    • Extracts the bounding rectangle coordinates of the number plate using cv2.boundingRect.
    • Crops the image to the bounding rectangle to obtain the number plate region.
    • Saves the cropped image with a sequentially numbered file name.
    • It draws the identified number plate contour on the original image using cv2.drawContours and displays the final image with the identified number plate.
  • It uses Tesseract OCR (pytesseract.image_to_string) to extract text from the cropped number plate image.
  • If text is successfully extracted, it prints the current date and time along with the extracted text. Otherwise, it prints "No text found".
  • The program waits for a key press to exit.

Packages ๐Ÿ“ฆ

  • OpenCV (import cv2): OpenCV is a popular computer vision library that provides various functions and algorithms for image and video processing.

  • imutils (import imutils): imutils is a convenience library built on top of OpenCV, providing additional image processing functions and utilities.

  • pytesseract (import pytesseract): pytesseract is a Python wrapper for Tesseract OCR, an open-source optical character recognition engine. It allows you to extract text from images.

  • datetime (from datetime import datetime): The datetime module is part of Python's standard library and provides classes for manipulating dates and times.

Install โฌ‡

pip install {Package}

License

License

vehicle-plate-ocr's People

Contributors

sasankaweera123 avatar

Watchers

 avatar  avatar

vehicle-plate-ocr's Issues

Add Video Capturing Ability

Is your feature request related to a problem? Please describe.
There is no ability to capture the image using a video cam in this repository

Describe the solution you'd like
get the vehicle plate image using a video cam

Describe alternatives you've considered
using OpenCV video capture function

Add the exact Date Time

Is your feature request related to a problem? Please describe.
There is no way to know about the image capture time

Describe the solution you'd like
Using python dateTime can get the current time , using simple if condition can add the current time and date to the captured image

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.