特定区域的opencv颜色检测

时间:2016-05-18 10:06:18

标签: python opencv colors image-recognition

我希望视频中的特定区域具有颜色检测。 例如,我的程序会检测到人并用一个矩形框绑定他。

image = cv2.imread(imagePath)
(rects, weights) = hog.detectMultiScale(image, winStride=(4, 4),
    padding=(8, 8), scale=1.05)

# draw the original bounding boxes
for (x, y, w, h) in rects:
    cv2.rectangle(orig, (x, y), (x + w, y + h), (0, 0, 255), 2)

之后,我想检查框内的棕色是否大于阈值。如果是,则程序打印"检测到"。

我怎样才能检测指定区域内的颜色?

1 个答案:

答案 0 :(得分:0)

使用Rect对象。我没有用Python编写OpenCV,但我认为它看起来像这样:

rect = cv2.Rect(x, y, width, height)
region = image(rect)

现在代替图像传递区域到您的算法中。