Post

Building an Autonomous License Plate Reading Robot

Building an Autonomous License Plate Reading Robot

The source code for CNN training pipeline is hosted on GitHub, found here.

As part of our ENPH 353 course at UBC, my team and I tackled an exciting challenge: creating an autonomous robot capable of navigating a simulated environment, identifying license plates, and avoiding obstacles. This project combined computer vision, machine learning, and robotics to create a system that could “see” and interact with its surroundings. Here’s how we did it.

simulation environment
Gazebo Simulation World for competition

The Challenge

Our task was to build an agent that could:

  1. Navigate a predefined course
  2. Identify characters on parked cars’ license plates
  3. Avoid NPC (non-player character) obstacles

We aimed for a simple yet robust approach, focusing on reliability and performance.

License Plate Recognition: A Three-Step Process

Step 1: Perspective Transform

perspective transform
SIFT homography

Initially, we tried using SIFT (Scale-Invariant Feature Transform) for homography, but it didn’t work well with our simplified images. Instead, we developed a custom approach:

  1. Apply an HSV mask to isolate blue car pixels
  2. Determine the corners of the white backing for the parking ID and license plate
  3. Use a 4-point transform to “flatten” the off-angle image

This method allowed us to consistently extract the license plate region, regardless of the car’s position or angle.

Step 2: Character Segmentation

character segmentation
Character segmentation

Once we had a flattened image of the license plate, we segmented it into individual characters. We converted these to binary images to simplify the input for our neural network.

Step 3: Convolutional Neural Network (CNN)

We trained a CNN to recognize individual characters. Some key points of our approach:

  • Used synthetic data generation to create a large training dataset
  • Augmented the data to introduce artifacts similar to those in the simulation
  • Fine-tuned the CNN architecture and training parameters

After several iterations, we achieved a 97.6% accuracy on our validation set.

train/val loss
Training/Validation loss

Robot Control: Navigating the Course

For controlling the robot, we used a combination of PID (Proportional-Integral-Derivative) control and hard coding. We implemented a finite-state machine to manage different behaviors:

  1. Line Following: Used PID control to follow lines on the course
  2. Obstacle Detection: Detected pedestrians and vehicles using color thresholding
  3. Parked Car Detection: Identified parked cars to read their license plates

Challenges and Learnings

  1. Data Quality: We found that the quality and diversity of our training data significantly impacted our model’s performance. Synthetic data generation and augmentation were crucial.

  2. Robustness: Our initial approaches often worked well in ideal conditions but failed in edge cases. We had to continuously refine our methods to handle various scenarios.

  3. Integration: Combining computer vision, machine learning, and robotics required careful integration and testing. Each component had to work seamlessly with the others.

  4. Performance Tuning: We spent considerable time fine-tuning our CNN and control algorithms to achieve the desired accuracy and reliability.

Results and Reflections

Our final system performed well, successfully navigating the course and reading license plates with high accuracy. The project gave us hands-on experience with:

  • Computer vision techniques
  • Machine learning model development and training
  • Robotics control systems
  • System integration and testing

Conclusion

This project was a fantastic opportunity to apply theoretical knowledge to a practical, multidisciplinary challenge. It highlighted the importance of robust design, iterative improvement, and the power of combining different technologies to solve complex problems.

The skills and experience gained from this project have broad applications, from autonomous vehicles to industrial automation. As AI and robotics continue to advance, projects like these provide valuable insights into the challenges and possibilities of creating intelligent, autonomous systems.

This post is licensed under CC BY 4.0 by the author.