Object detection rectangle doesn't cover whole object

asked 2016-12-26 06:04:55 -0500

Hello everyone,

I just started to work with openCV. I decided to use this library to detect an object on image and cut it from them. I trained cascade, unfortunately it doesn't work very well. I tried it on several images and every time rectangle doesn't cover a whole object. Here are examples: 1, 2, 3

import cv2

image = cv2.imread("data/test/4.jpg")
resized = image
#resized = cv2.resize(image, (500, 500))
gray = cv2.cvtColor(resized, cv2.COLOR_BGR2GRAY)

detector = cv2.CascadeClassifier("output/cascade/cascade.xml")
rects = detector.detectMultiScale(gray, scaleFactor=1.3, minNeighbors=10, minSize=(100, 100))

# loop over the cat faces and draw a rectangle surrounding each
for (i, (x, y, w, h)) in enumerate(rects):
    cv2.rectangle(resized, (x, y), (x + w, y + h), (0, 0, 255), 2)

# show the detected cat faces
cv2.imshow("Bags", resized)
cv2.waitKey(0)

Could anyone help me to understand what do I need to tune or fix. I used handbags images from ImageNet.

edit retag flag offensive close merge delete