Nothing Special   »   [go: up one dir, main page]

Individual Assignments of Emerging

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

INDIVIDUAL ASSIGNMENTS OF EMERGING

OUESTION 1

Plate recognition with python

License plate Recognition (LPR) is the capacity to capture photographic


video or images from license plates and transform the optical data into
digital information in real-time.

License Plate Recognition using OpenCV Python License Plate Recognition is


an image-processing technology used to identify vehicles by their
license plates. This technology is used in various security and traffic
applications.

Automatic License Plate Recognition system is a real time embedded system which automatically
recognizes the license plate of vehicles. There are many applications ranging from complex security
systems to common areas and from parking admission to urban traffic control. Automatic license
plate recognition (ALPR) has complex characteristics due to diverse effects such as of light and
speed. Most of the ALPR systems are built using proprietary tools like Matlab. This paper presents
an alternative method of implementing ALPR systems using Free Software including Python and the
Open Computer Vision Library. Keywords—License plate, Computer Vision, Pattern Recognition,
Python, OCR. 

OpenCV
OpenCV (Open Source Computer Vision) is a library of programming functions mainly aimed at real-
time computer vision. Originally developed by Intel's research center in Nizhny Novgorod (Russia), it
was later supported by Willow Garage and is now maintained by Itseez. The library is cross-platform
and free for use under the open-source BSD license.

Python is a widely used high-level, general-purpose, interpreted, dynamic programming language.


Its design philosophy emphasizes code readability, and its syntax allows programmers to express
concepts in fewer lines of code than possible in languages such as C++ or Java. The language
provides constructs intended to enable writing clear programs on both a small and large scale

License Plate Recognition is an image-processing technology used to


identify vehicles by their license plates. This technology is used in
various security and traffic applications. I made this using simple
Python code.

#@programming_fever

import cv2

import imutils

import numpy as np

import pytesseract

pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files (x86)\Tesseract-OCR\tesseract.exe'

img = cv2.imread('D://skoda1.jpg',cv2.IMREAD_COLOR)

img = cv2.resize(img, (600,400) )

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

gray = cv2.bilateralFilter(gray, 13, 15, 15)


edged = cv2.Canny(gray, 30, 200)

contours = cv2.findContours(edged.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

contours = imutils.grab_contours(contours)

contours = sorted(contours, key = cv2.contourArea, reverse = True)[:10]

screenCnt = None

for c in contours:

peri = cv2.arcLength(c, True)

approx = cv2.approxPolyDP(c, 0.018 * peri, True)

if len(approx) == 4:

screenCnt = approx

break

if screenCnt is None:

detected = 0

print ("No contour detected")

else:

detected = 1

if detected == 1:

cv2.drawContours(img, [screenCnt], -1, (0, 0, 255), 3)

mask = np.zeros(gray.shape,np.uint8)

new_image = cv2.drawContours(mask,[screenCnt],0,255,-1,)

new_image = cv2.bitwise_and(img,img,mask=mask)
(x, y) = np.where(mask == 255)

(topx, topy) = (np.min(x), np.min(y))

(bottomx, bottomy) = (np.max(x), np.max(y))

Cropped = gray[topx:bottomx+1, topy:bottomy+1]

text = pytesseract.image_to_string(Cropped, config='--psm 11')

You might also like