AkcharaSRS / Mother-TerasaWomen-University-Sonline-Internship

0 stars 1 forks source link

numberplatedetection #11

Open archithakumar opened 3 years ago

archithakumar commented 3 years ago

from cv2 import cv2 import numpy as np from keras import image

frameWidth = 640 #Frame Width franeHeight = 480 # Frame Height

plateCascade = cv2.CascadeClassifier("haarcascade_russian_plate_number.xml") minArea = 500

cap =cv2.VideoCapture(0) cap.set(3,frameWidth) cap.set(4,franeHeight) cap.set(10,150) count = 0

while True: success , img = cap.read()

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

numberPlates = plateCascade .detectMultiScale(imgGray, 1.1, 4)

for (x, y, w, h) in numberPlates:
    area = w*h
    if area > minArea:
        cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
        cv2.putText(img,"NumberPlate Detected",(x,y-5),cv2.FONT_HERSHEY_COMPLEX,1,(0,0,255),2)
        imgRoi = img[y:y+h,x:x+w]
        cv2.imshow("ROI",imgRoi)
        numberPlates = img[y:y+h, x:x+w]
        cv2.imwrite('temp.jpg',numberPlates)
        test_image=image.load_img('temp.jpg',target_size=(1280,720,10))
        #t=cv2.imshow("ROI",imgRoi)
        #print(t)
cv2.imshow("Result",img)

if cv2.waitKey(1) & 0xFF ==ord('s'):
    cv2.imwrite("C:\\Sankar"+str(count)+".jpg",imgRoi)   #Path to save the file  
    cv2.rectangle(img,(0,200),(640,640),(0,255,0),cv2.FILLED)
    cv2.putText(img,"Scan Saved",(15,265),cv2.FONT_HERSHEY_COMPLEX,2,(0,0,255),2)

    cv2.imshow("Result",img)
    t=cv2.imshow("Result",img)
    print(t)
    cv2.waitKey(500)
    count+=1
archithakumar commented 3 years ago

Real time Number Plate Detection