A Python OpenCV and Python Lego NXT implementation of an object tracking webcam that is mounted on a Lego pan-tilt device.
Using OpenCV 3.4.0 with an HSV color space transform for object color detection.
The program requires a connected webcam and an NXT pan-tilt mechanical setup and has three operating modes:
A Python OpenCV and Python Lego NXT implementation of an object tracking webcam that is mounted on a Lego pan-tilt device.
The program uses OpenCV 3.4.0 with a KCF (Kernelized Correlation Filters) tracker [https://www.learnopencv.com/object-tracking-using-opencv-cpp-python/].
The program requires a connected webcam and an NXT pan-tilt mechanical setup and has three operating modes:
Mechanical setup is slightly different than the original setup. I added worm gears to the drive train that enabled the PID to run the motors at a higher power setting (RPM). This provides smoother and a more responsive pan-tilt movement.
A few options exist for a Pan-Tilt mechanical setup. There is a nice Differential Pan & Tilt: [https://www.youtube.com/watch?v=NSRRrAH-9cA] that I built first, but, being made out of Lego, it proved not to be robust enough. The backlash from the motors and the gears, especially the horizontal one, was excessive. The vertical axis was too 'wobbly' to hold a webcam.
I opted for this arrangement [https://www.youtube.com/watch?v=ei3JFqVvChU]. The tilt movement, when panning, was not an issue because the tilt PID took care of any error. The mechanical arrangement was much 'tighter' and backlash was minimal due to better gearing. There are many other arrangements to be found, but these were the most elegant ones to prototype quickly with Lego Mindstorms parts and NXT.
Available on GitHub [https://github.com/eyalabraham/computer-vision]