Color block tracking

This tutorial is an advanced gameplay for color block positioning experiments, with the addition of a robotic arm following function.

Overview: Target tracking includes two gameplay modes: color tracking and color picking tracking (learning tracking). The principle is to process the image through a camera, recognize the target in a specific way, obtain the coordinate position of the target under the camera, calculate the deviation value between the center point of the target and the center point of the image, and drive the robotic arm to move through PID algorithm debugging. Make the target center point coincide with the image center point.

Code path:~/jetcobot_ws/src/jetcobot_color_follow/color_tracking.ipynb

1. Control Design

 

2. Run program

Click the program run button on the jupyterlab toolbar, run the entire program, and then drag it to the bottom.

202309010001

 

By default, no color blocks are tracked, and we need to select the corresponding function button.

Start the code block and click the 【 colorfollow 】 button to enable color tracking. You can switch colors below the image by placing the color block in front of the camera. Once the camera recognizes it, the robotic arm will move along with the block and face the center of the block.

Click the 【follow_cancel】 button to cancel tracking.

Click the 【Exit】 button to exit the program

Start the code block, click the 【 leraning_color 】 button, and a box will appear in the center of the screen, as shown in the left figure

Place objects inside the box and print the high and low thresholds of HSV in real-time. When the word 【OK!!!】appears below the box, it indicates successful recognition

Click the 【leraning_follow】 button, and as long as the contour of the learned color can be detected, it can be tracked in real time

Click the 【follow_cancel】 button to cancel tracking.

Click the 【Exit】 button to exit the program.