GPIO.setup(IR2, GPIO.IN) GPIO.setup(servoPin, GPIO.OUT) #Listening to the IR sensors for input sensor1 = GPIO.input(IR1) sensor2 = GPIO.input(IR2) exitSensor = GPIO.input(exitIR) display = drivers.Lcd() # Importing LCD Drivers #pwm = GPIO.PWM(servoPin, 50) #PWM initialised at 50Hz frequency availableSlots = 0 #initialising the number of empty slots to 0 #beginning of OpenCv for License Plate recognition cap = cv2.VideoCapture(0) #Starting Video Capture #Entering The endless loop for repetitive function while (True): ret, frame = cap.read() #Read Frames plate = extraction(frame) #take a picture try: text = ocr(plate) #Do Optical Character Recognition text = ''.join(e for e in text if e.isalnum()) #Remove spaces from extracted text except: continue if text != '': #If extracted text is not null print(text, end=" ") #print the license plate content = str(text) #convert text to string format ##########Email server configuration for email notifications########## sendTo = '*****@*****.**' #Receiver of email notifications emailSubject = "VEHICLE AUTHORISED!" #Email subject emailContent = "The vehicle with license number: " + content + " " + "has been granted access on:\n " + time.ctime( ) #Email Content
import cv2 #import winsound frequency = 2500 duration = 1200 from PlateExtraction import extraction from OpticalCharacterRecognition import ocr from OpticalCharacterRecognition import check_if_string_in_file image = cv2.imread('./CarPictures/001.jpg') plate = extraction(image) cv2.imshow('frame',plate) text = ocr(plate) text = ''.join(e for e in text if e.isalnum()) print(text, end=" ") if check_if_string_in_file('./Database/Database.txt', text) and text != "": print('Registered') #winsound.Beep(frequency, duration) else: print("Not Registered")
import time GPIO.setmode(GPIO.BOARD) exitIR = 37 servoPin = 11 GPIO.setup(exitIR, GPIO.IN) GPIO.setup(servoPin, GPIO.OUT) exitSensor = GPIO.input(exitIR) display = drivers.Lcd() pwm = GPIO.PWM(servoPin, 50) cap = cv2.VideoCapture(0) while (True): ret, frame = cap.read() plate = extraction(frame) try: text = ocr(plate) text = ''.join(e for e in text if e.isalnum()) except: continue if text != '': print(text, end=" ") content = str(text) if check_if_string_in_file('./Database/Database.txt', text): print('Registered') display.lcd_display_string("WELCOME:", 1) display.lcd_display_string(text, 2) time.sleep(2) #IR(Empty Slot)