# lower_yellow = np.array([12, 230, 230]) # 黄色阈值下界
lower_yellow = np.array([12, 43, 43]) # 黄色阈值下界
higher_yellow = np.array([35, 255, 255]) # 黄色阈值上界
lower_red = np.array([0, 127, 128]) # 红色阈值下界
higher_red = np.array([10, 255, 255])
# lower_blue = np.array([85,240,140]) # 蓝色
lower_blue = np.array([110,43,43]) # 蓝色
higher_blue = np.array([125,255,255])
img_path = os.path.join(person_path,each_img_name) cv_img = cv_imread(img_path) img_hsv = cv2.cvtColor(cv_img, cv2.COLOR_BGR2HSV) mask_yellow = cv2.inRange(img_hsv, lower_yellow, higher_yellow) mask_yellow = cv2.medianBlur(mask_yellow, 7) # 中值滤波 mask_red = cv2.inRange(img_hsv, lower_red, higher_red) mask_red = cv2.medianBlur(mask_red, 7) mask_blue = cv2.inRange(img_hsv, lower_blue, higher_blue) mask_blue = cv2.medianBlur(mask_blue, 7) # 中值滤波
hsv颜色值分布 https://blog.csdn.net/qq_39507748/article/details/105184428
代码转自 https://blog.csdn.net/RayChiu757374816/article/details/119142826