2.Color threshold adjustment/Color calibration

By adjusting the high and low thresholds of HSV, interfering colors are filtered out, so that the blocks can be ideally identified in complex environments. When using color-based gameplay for the first time, it is best to calibrate it. Each color-related AI gameplay has its own [HSV calibration.ipynb] file under the [scripts] folder.

Here the color calibration file in this path is used for calibration:

/dofbot_ws/src/dofbot_color_identify/scripts/HSV calibration.ipynb

1. HSV introduction

HSV (Hue, Saturation, Value) is a color space created by A. R. Smith in 1978 based on the intuitive characteristics of color, also known as the Hexcone Model. The parameters of color in this model are: hue (H), saturation (S), and lightness (V).

H: 0 — 180

S: 0 — 255

V: 0 — 255

 绿 
H_min000015611263578100125
H_max1801801801018025347799124155
S_min00043434343434343 
S_max2554330255255255255255255255 
V_min00046464646464646 
V_max46220255255255255255255255255 

2.Code design

The upper middle part of the screen displays which color is selected. The six slide bars on the upper right side correspond to the six HSV values. Slide the slide bars to adjust the HSV threshold of each color in real time.

3.Operation process

(1). After starting all code blocks, the interface as shown in the figure is displayed at the bottom of the code. The default color selection is empty, so no color is recognized.

(2). Click the [HSV_update_green] button to start identifying green objects (Note: This color recognition detects the outline, so the object can be recognized normally only when it is completely within the range of the camera). Slide the slide bar on the upper right to adjust the green HSV threshold. When adjusting, pay attention to multi-directional adjustments and adjust in different visual field environments until objects can be clearly identified in complex environments without being interfered by other objects.[Other colors are similar].

(3). The [Color/Binary] button switches between color images and binary images. It is only effective when the color is selected. After switching, only the selected color binary image is displayed, which makes it easier for us to debug.

(4). [HSV_write_file] button. After debugging the HSV values of all colors, click this button. Save all the debugged parameters in the format of [.txt] in the same path as the code.The parameters of the file will be automatically read next time it is started.

(5). [Exit] button, turn off the camera and exit the program.