Welcome to USB Industrial Grade AI Vision Camera repository
Tracking color line
Tracking color line
Tracking color line1. Introduction1.1 Introduction to HSV1.2 HSV hexagonal pyramid2. Operation steps2.1 Start2.2 Identify
Code path:~/yahboomcar_ws/src/yahboomcar_linefollw
1. Introduction
The Yahboom robot has tracking color line, which can recognize multiple colors at any time and autonomously store the currently recognized colors. It follows the detected colors and can also achieve real-time obstacle avoidance during the tracking process.
The Yahboom mobile robot can also achieve real-time control of HSV. By adjusting the high and low thresholds of HSV, interference colors can be filtered out, so that the tracking route can be recognized very ideal in complex environments. If the effect in color picking is not ideal, the car needs to be moved to different environments for calibration to achieve the ability to recognize the desired color in complex environments.
1.1 Introduction to HSV
HSV (Hue, Saturation, Value) is determined by A R. A color space created by Smith in 1978, also known as the Hexacone Model. The parameters of colors in this model are: hue (H), saturation (S), and brightness (V). H: 0-180 S: 0-255 V: 0-255 Here, part of the red color is classified as the purple range:

1.2 HSV hexagonal pyramid
Color tone H Represents color information, that is, the position of the spectral color in which it is located. This parameter is represented by an angular quantity, with a value range of 0 ° to 360 °. It is calculated counterclockwise starting from red, with red indicating 0 °, green indicating 120 °, and blue indicating 240 °. Their complementary colors are: yellow at 60 °, cyan at 180 °, and purple at 300 °. Saturation S The saturation S is expressed as the ratio between the purity of the selected color and the maximum purity of that color. When S=0, only grayscale is available. 120 degrees apart. The complementary colors differ by 180 degrees. A color can be seen as the result of mixing a certain spectral color with white. The larger the proportion of spectral colors, the closer the color is to spectral colors, and the higher the saturation of the color. High saturation results in deep and vibrant colors. The white light component of the spectral color is 0, and the saturation reaches its highest level. The usual range of values is 0% to 100%, and the larger the value, the more saturated the color. Brightness V Brightness represents the degree of brightness of a color, and for a light source color, the brightness value is related to the brightness of the emitting body; For object color, this value is related to the transmittance or reflectance of the object. The usual range of values is from 0% (black) to 100% (white). One thing to note is that there is no direct connection between it and light intensity. The three-dimensional representation of the HSV model evolved from the RGB cube. Imagine observing the hexagonal shape of a cube from the white vertices along the diagonal of the RGB to the black vertices. The hexagonal boundary represents color, the horizontal axis represents purity, and brightness is measured along the vertical axis.

2. Operation steps
2.1 Start
Open two terminals and run the following content separately:
Terminals-1:
roscore
Terminals-2:
xxxxxxxxxxcd ~/yahboomcar_ws/src/yahboomcar_linefollw/scriptspython3 follow_line.py
2.2 Identify
After startup, the system defaults to [Object Detection Mode], as shown in the following image on the left:

Keyboard key control: 【r】 Color selection mode, where the mouse can be used to select the area of the color to be recognized (within the range of the area). 【i】 Object detection mode. Color image on the left and Binary image on the right. 【q】 : Exit the program.
xIn the color selection mode, you can use the mouse to select the area of the color you want to recognize (not exceeding the area range), as shown in the following figure. Release to start recognition.