Improving the efficiency of Camshift

Asked

Viewed 19 times

1

I detect a previously trained object with the Haarcascade algorithm and pass the coordinates to Camshift at the beginning of the program to detect the region where the object in question is in the first frame. The problem is that although it works the accuracy is very bad. I would like to know techniques that can smooth and improve accuracy.

credit that is not the part of training by finding the region easily, in case faces.

Camshift receives the coordinates of the detected object

for (x, y, l, a) in deteccoes:
width = l
height = a
roi = imagem[y: y+l, x: x+l]

hsv_roi = cv2.cvtColor(roi, cv2.COLOR_BGR2HSV)
roi_hist = cv2.calcHist([hsv_roi], [0], None, [180], [0, 180])

cap = cv2.VideoCapture('video.mp4')
term_criteria = (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 100, 10)
while True:
    _, frame = cap.read()
    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
    mask = cv2.calcBackProject([hsv], [0], roi_hist, [0, 180], 1)
    ret, track_window = cv2.CamShift(mask, (x, y, width, height), term_criteria)
    pts = cv2.boxPoints(ret)
    pts = np.int0(pts)
    cv2.polylines(frame, [pts], True, (255, 0, 0), 2)
    cv2.imshow("mask", mask)
    cv2.imshow("Frame", frame)
    key = cv2.waitKey(1)
    if key == 27:
        break
cap.release()
cv2.destroyAllWindows()
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.