Line Follower with Computer Vision
I sought an ambitious personal project -- a robot that would follow a line using computer vision. I entered it in the fair and won the Superior Award at the Illinois State Fair. After finding the current computer vision algorithms overly complex and poorly accurate, I sought to develop a simpler algorithm built for line following.
I only had a few weeks to complete this project. Thus, technologies such as Lego Mindstorms, Raspberry Pi, Python, OpenCV, and GIT allowed for rapid development.
I also created a poster board explaining with simple illustrations how the computer vision algorithm worked.
Challenges
The hardest challenge was coding an appropriate response to the line. This was solved by tuning PID Loop parameters. If the parameters were too low, the robot would not steer hard enough to track a sharp turn. If the parameters were too high, the robot might veer off course when it sees a slight deviation.
Project Analysis
Since the resulting code was simple, visualizing how it worked to the public was an easy task.
The algorithm was robust. The robot was able to track very sharp turns. There was perfect consistency with line tracking. This meant I could leave the robot running by itself and be confident it was following the line.
Considering I was new to computer vision and PID Loop tuning, the project development went very fast. The use of small, clearly defined functions resulted in clean, readable code.
Skills Gained
This was my first project utilizing computer vision. As a result, I learned about algorithm development and how OpenCV worked.
Future Changes
When lighting conditions changed, manual calibration was required. I would like to add auto-calibration. Ultimately the robot should be able to handle light changes dynamically.
The algorithm could track very sharp turns. If there was an extremely sharp U-turn, the camera saw both sides of the U. The algorithm was not designed for two lines. Thus the robot lost the line. If I were to continue the project, I would either modify the existing algorithm or create a new one to handle extreme turns.
Having experimented with classic algorithmic computer vision, I would like to see how the robot performs with neural networks. Specifically, I’d like to see if the robot could teach itself how to follow the line using reinforced learning.
Finally, the code ran fast enough for slow speeds. In the future, I would like to speed up the robot. This would require substantially faster processing framerates.
This could be done by:
-
Using more optimal data structures
-
Using Cython (A Python implementation that compiles to C to run faster)
-
Utilizing multiple cores for processing