Welcome to DOGZILLA-Lite repository
2. Color recognition
2. Color recognition
1. Purpose of the experiment
Drive the robot dog to do color recognition
2. Experimental path source code
Enter the robot dog system, end the robot dog program, enter "ip (ip is the robot dog's ip): 8888" in the browser, enter the password "yahboom"
and log in. Enter the path of cd ~/DOGZILLA_Lite_class/5.AI Visual Recognition Course/02. Color recognition and run color_detection.ipynb .
3. Experimental Phenomenon
After running the source code, the robot dog can recognize four colors: red, yellow, blue and green at the same time.

4. Analysis of main source code parameters
xxxxxxxxxxdef TEST(): detected_colors = [] # 用于存储检测到的颜色名称 Used to store detected color names unique_colorstemp=None global color_hsv display(image_widget) while True: ret, frame = image.read() #usb摄像头 usb camera frame, binary,hsvname=update_hsv.get_contours(frame,color_hsv) unique_colors = list(dict.fromkeys(hsvname)) # 根据列表的长度来决定如何分割字符串 Determine how to split the string based on the length of the list num_colors = len(unique_colors) if(unique_colors!=unique_colorstemp): unique_colorstemp=unique_colors.copy() # 实时传回图像数据进行显示 Real-time image data transmission for display image_widget.value = bgr8_to_jpeg(frame) #显示在小车的lcd屏幕上 Display on the LCD screen of the car b,g,r = cv2.split(frame) img = cv2.merge((r,g,b)) imgok = Image.fromarray(img) mydisplay.ShowImage(imgok)From the code, we can see that: by turning on the camera of the robot dog, the corresponding color recognition is performed; and the results are displayed on the computer screen and the robot dog screen.