Automatic gateman: This is a very common sight. The gate is covered by boom barrier. The car slows down and passes below an IR scanner which reads the faint radiation of IR tag pasted on the car wind shield and the boom barrier opens if the tag is found in its database. The process is highly efficient and works unhindered. However, the only flip side is that the process can work unless there is tag or no damaged tag or no unidentified tag.
The modified gateman: The car approaches the boom barrier near the gate. The automatic speaker asks the driver to slow down and come closer not beyond 4 meter distance. A high fidelity camera reads the car registration plate, compares its database and if it finds there in its database, opens the boom barriers and asks the driver to proceed. If a new residence comes, his car registration number is updated in the car database and the process keeps running. No IR tag, no pasting or no big disk antenna like IR Scanner at the gate… the process can be automated without stopping of the car by incorporating better camera & computer.
A powerful Raspberry Pi 4 computer is deployed for this project. For measuring distance the same image analytic can be deployed but to make process simple we have deployed an HC-SR04 ultrasonic sensor. The moment a vehicle comes within 4 to 6 meter distance the moderately built camera takes a frontal picture of the vehicle and analyze its registration plate with its already available numbers in its database. HC-SR04 cannot measure beyond 4 meters. To make it 6 meters, it can be fitted on a long 2 meters lead pole with wires in front of the camera on the side of the passage such that when the barrier opens, it will go up with the barrier.
We have used voice synthesizer ‘espeak’ to issue voice instruction to guide the driver. Like it will speak up – come closer, slow down, go away, welcome etc etc.
To increase range of measurement from mere 6 meter to 12 meter a TFMini – S [3.4 degree aperture] can be used but a 4 to 6 meters distance is just right for this work. For IR Tag systems the distance is about 2 meters from the scanner.
If anyone thinks that by holding a registration plate in hand will allow it pass, is not possible at all. The car classifier model “haarcascade_russian_plate_number.xml” is used here to identify the car first and then the number plate is identified, scooped and read by the model.
The opensource software – python3, opencv2, espeak, PiCamera, gpiozero, pytesseract, tesseract-ocr ,numpy. While all these are all opensource software therefore, all can be installed very easily by the following commands on any Raspberry Pi computer.
# sudo apt-get update
# sudo apt-get upgrade
# sudo pip3 install pillow
# sudo pip3 install pytesseract
# sudo apt-get install tesseract-ocr
# sudo pip3 install opencv-python
# sudo pip3 install numpy
# sudo apt-get install espeak
# sudo apt install python3-gpiozero
# sudo pip3 install gpiozero
# sudo apt-get install python3-picamera
Operating Principle: First the HC-SR04 finds the car reaches within 4 or 6 Meter distance of the camera. If not, it will speak out to slow down and proceed further to bring the car within the measured distance. Then it takes a snap of the frontal view of the car. It then analyze it for being a car. If it finds it being a car, it zooms on its number plate and analyze the number plate. Removes the ‘-‘ and ‘ ‘ from the number and redisplays it. The database of known number plates are kept ready in a string array [carpool] separated by commas. Each number element of the database is compared against this number to find out the match.
You can say our database being a small one is managed in one string array called carpool which can hold 200 numbers comfortably.
carpool=[‘your number’,’UP16BYuoynum’,’MP10yournum’,’MH0your num’,’MHO3Ayournum’]
if a match is found, it will trigger the GPIO21 to open the gate or close it. There are many more GPIOs available which can be used for multiple triggering of the boom barrier or the gate mechanism – like green light, red light, gate open, gate close etc.
This is how this works.
- Raspberry Pi 3 or 4 computer with 4/8 GB RAM – INR 6000.00 / 8000.00
- Raspberry Pi camera – INR 1435.00
- Power supply for Raspberry Pi 4 – INR 625.00
- Camera extension cord INR 333.00
- HC – SR04 ultrasonic probe INR 150.00
- 7” Touch screen for Raspberry Pi [Optional] – INR 3695.00
Total: INR 14238.00 / USD 180$
Actual deployment: During actual deployment we found that for cheap quality camera, the lighting creates an issue. What becomes clear during day hours becomes unclear during night time. However, with good quality camera the problem was overcame. We have used a camera which has Infra Red light source attached which gives extra edge during night time detection. A 5 meter camera extension cord is used so that camera can be placed at the center of the boom barrier for proper detection. The TFT touch screen, the keyboard, mouse etc are all optional. Once the project is deployed at operation level, all these can be stripped off the computer.
Raspberry Pi 4 or 3 can be used for this project. The speaker is to be inserted in the earphone jack. An amplifier or Bluetooth Amplibox can be used for louder & clear voice reproduction.
The espeak synthesizer has many options – “espeak”,”-ven+f3″, “abcdefgh 1234567890” “- ven+f3” is for female voice reproduction. Search internet for more options.
Parts of prototype
Aftermath: The above car is one of the several cars with which we tested the prototype. Each car is allowed to slow down between 4 & 5 meter distance. The prototype is able to aptly identify the car & the number plate & compared with carpool array and triggers the GPIO-21 of the raspberry pi computer. Sometimes it misses 0 [zero] for O [O of onion]. This can be tackled in logical level such that the letters at 3,4,7,8,9,10 positions are numbers only. Rests are alphabets. So the model can rectify the missing number or alphabet accordingly. The main python script – automatic-numberplate-identification.py runs non stop.
Software: automatic-numperplate-identification.py and numberplate22.py is included here.
Download Source Code