在光照不严的环境下通过衣服颜色认人的问题

issue of the recognize people by their clothes color with not severe illumination environments

我对使用真实机器人的人类跟随很感兴趣。 我想使用衣服的颜色作为关键特征来识别机器人前面的目标人以跟随他/她,但我很痛苦,因为它是一个非常简单的照明变化的弱特征。因此,我需要将此算法更改为另一种算法或实时在线更新值(RGB),但我没有足够的图像处理经验。

这是我的颜色检测的完整代码:

import cv2
import numpy as np
from imutils.video import FPS
# capturing video through webcam
import time

cap = cv2.VideoCapture(0)

width = cap.get(3)  # float
height = cap.get(4)  # float
print width, height
time.sleep(2.0)
fps = FPS().start()
while (1):
    _, img = cap.read()

    if _ is True:
        hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
    else:
        continue
    # blue color

    blue_lower = np.array([99, 115, 150], np.uint8)
    blue_upper = np.array([110, 255, 255], np.uint8)
    blue = cv2.inRange(hsv, blue_lower, blue_upper)
    kernal = np.ones((5, 5), "uint8")
    blue = cv2.dilate(blue, kernal)
    res_blue = cv2.bitwise_and(img, img, mask=blue)

            # Tracking blue
    (_, contours, hierarchy) = cv2.findContours(blue, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
    for pic, contour in enumerate(contours):
        area = cv2.contourArea(contour)
        if (area > 300):
            x, y, w, h = cv2.boundingRect(contour)
            img = cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
            cv2.putText(img, "Blue Colour", (x, y), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (255, 0, 0))
    cv2.imshow("Color Tracking", img)
    if cv2.waitKey(10) & 0xFF == ord('q'):
        cap.release()
        cv2.destroyAllWindows()
        break
    fps.update()

    # stop the timer and display FPS information
    fps.stop()
#    print("[INFO] elapsed time: {:.2f}".format(fps.elapsed()))
#    print("[INFO] approx. FPS: {:.2f}".format(fps.fps()))

这些是输出:

1- 看衣服颜色认人

2-丢了,光照变化很简单不厉害

如有任何想法或建议,我们将不胜感激

看来您确实需要使用更高级的颜色相似度函数来处理复杂的情况。 Delta E 将是正确的起点。

适当的阈值或具有相关阈值的几种颜色将有助于获得相当准确的结果:

查看右侧的颜色列表

Complete example.