Skip to case study
SG/sasan.ghasaei All projects

ENPH 353 · Fall 2023 · Software & machine learning

A robot detective.
Powered by vision.

Read the clues. Navigate the course. React to traffic.

A software-only autonomous robot in a ROS simulation, combining CNN character recognition with image processing, PID navigation, and a competition state machine.

Simulated robot camera view with a green contour around a blue clue board Full size
The robot’s camera feed: find the clue board, correct its perspective, and recognize its characters.
My focus
CNN training, clue perception, state machine
Team
Sasan Ghasaei & Mahdi Shakouri
Environment
UBC ENPH 353 · Simulated competition
PythonTensorFlow / KerasCNNsOpenCVROSDataset designState machines
8 / 8
Clues read correctly in competition
50 / 57
Final competition score
37
Character classes: A–Z, 0–9, space
01

Software architecture & ownership

A camera feed becomes useful information.

The course combined paved roads, off-road terrain, moving hazards, and eight clue boards. Our task was to navigate autonomously and submit the topic and value from each board. We separated character recognition from the modules that moved the robot and tracked its progress.

I built the learning pipeline

Generated and collected training data, trained the character CNN, and used failure cases to refine it.

I built clue perception

Implemented ClueFinder for banner detection and perspective correction, and ClueGuesser for character-by-character recognition.

I integrated the controller

Implemented the competition state machine. Mahdi developed the driver, road perception, score keeper, confidence safeguard, and state-transition improvements.

That split gave us clear interfaces: camera images into perception, recognized clues into the score keeper, and state-dependent commands into the driver.

02

OpenCV · Contours · Perspective transforms

Read the board before reading the letters.

The CNN needs a consistent view of each character. ClueFinder first isolates the blue board, locates a four-corner contour, and rectifies its perspective. A second crop removes the border. A Laplacian-variance check rejects blurry frames before the letters reach the network.

Binary mask isolating the blue clue banner in the robot camera view Full size
01 · LocateColor filtering isolates the board; contour size helps reject distant candidates.
Clue board after a perspective transform, displaying SIZE and ZEPTILLION Full size
02 · RectifyA four-corner perspective transform aligns the banner for consistent cropping.
Thresholded clue text and inner contour used to remove the banner border Full size
03 · IsolateRemove the border, check sharpness, then crop individual characters.

ClueGuesser turns each crop into a 37-class probability vector and selects the most likely character. It checks the topic against the eight possible topics before processing the value, avoiding unnecessary work.

03

CNNs · Dataset design · Error analysis

Good validation scores were only the beginning.

Our first model performed well on generated characters, but struggled with images from the simulated robot’s camera. The important work was closing that data gap: collecting representative examples, identifying confusing characters, and fine-tuning without introducing new bias.

  1. Start with synthetic characters

    Generated A–Z, digits, and spaces on clue banners, with blur and horizontal shifts. Initial training used 50 epochs, batch size 16, and a learning rate of 0.0001.

  2. Collect the camera’s actual view

    Captured nearly 200 banner images across all eight locations in the simulation. Cropped their characters and fine-tuned for 15 epochs; validation exposed remaining weaknesses.

  3. Target the confusing cases

    Collected examples of O/Q/0, I/1, S/5, and P/R. A short five-epoch training round raised reported validation accuracy above 95%.

  4. Refine from complete runs

    Tracked the remaining character errors during runs and applied focused one-to-three-epoch updates. Short updates helped limit bias toward the new examples.

The character classifier

784,613 trainable parameters

A Keras sequential CNN, trained using Google Colab. Convolutional layers extract visual features; dense layers classify the character.

Network architecture · report Appendix A
LayerOutput shape
Conv2D · 32 filters98 × 43 × 32
Max pooling49 × 21 × 32
Conv2D · 64 filters47 × 19 × 64
Max pooling23 × 9 × 64
Conv2D · 128 filters21 × 7 × 128
Max pooling10 × 3 × 128
Conv2D · 128 filters8 × 1 × 128
Flatten + dropout1,024
Dense512
Character output37
Explore the training examples and original learning curves
Examples of clue banners captured at different positions in the simulated environment Full size
Camera-derived training examples from the simulation, including different viewpoints and backgrounds. Report figure 6.
First-round training and validation loss decreasing and accuracy increasing over 50 epochs Full size
Initial synthetic-data training curves. Strong performance here did not translate directly to the simulated camera images. Original raster figure extracted from the report; raw training logs were not supplied.
05

Evaluation & engineering trade-offs

Eight correct clues. Clear lessons from the misses.

In competition, the robot read all eight clues correctly and finished with 50 out of 57 points. It received 52 clue points and a two-point respawn deduction. We used a deliberate respawn to skip the tunnel/Yoda segment; the result does not represent a fully continuous traversal of every obstacle.

Character confidence across a complete run, with a red threshold at 0.9 and lower confidence near the final clue Full size
Character confidence during one complete run. The system rejects a whole reading if any character falls below 90% confidence, then waits for a clearer image. Confidence is the model’s score, not a measured accuracy guarantee. Report figure 23.
View the final character confusion matrix
Final confusion matrix dominated by diagonal predictions with a small number of off-diagonal errors Full size
Final character confusion matrix from Appendix D. The report’s eight-of-eight result refers to competition clues, not a claim that every possible character image is classified perfectly.

What I took forward

Building this system connected neural-network training to the behavior of a complete autonomous agent. I learned to curate datasets around failure cases, inspect confusion matrices, correct image geometry, and create modular perception software that works with a state machine.

The next improvement would be faster clue inference so navigation can continue smoothly without slowing down to read. Completing the skipped course segment would also remove reliance on the respawn strategy.

Technical details, contribution attribution, figures, and results are drawn from our Fall 2023 final report.