I want to have a color detection for a particular region in a video. For example, my program will detect people and bound him with a rectangular box.
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)
Afterwards, I want to check whether the brown color within the box is greater than threshold. If yes, the program print "detected".
How can I only detect the color within a specified region?
Use Rect object. I'm not coding OpenCV in Python but I think it'll be look like this:
rect = cv2.Rect(x, y, width, height)
region = image(rect)
Now instead of image pass region into your algorithms.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.