tracking with hsv?
New at this so please excuse me if this is something obvious but I dont get it..
I am playing around with tracking something in a video using python opencv. I started with a sample program and my own video and have been trying to learn how best to tune the tracking to my situation. I think I am close but the tracker still loses it at times. I was watching the output of several "frames" and I noticed that the maskhsv shows really clearly what I want to track. I tried to change this code:
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
maskhsv = cv2.inRange(hsv, lower_hsv, upper_hsv)
res = cv2.bitwise_and(frame,frame, mask= maskhsv)
ok = tracker.init(res, bbox)
To something like this:
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
maskhsv = cv2.inRange(hsv, lower_hsv, upper_hsv)
ok = tracker.init(maskhsv, bbox)
My issue is that this gives an error when I do the tracker.update (but not when I do the tracker.init) and I dont understand why..
OpenCV Error: Assertion failed (img.channels() == 3) in getSubWindow, file /root/opencv-build/opencv_contrib/modules/tracking/src/trackerKCF.cpp, line 686
Traceback (most recent call last):
File "tracker.py", line 128, in <module>
ok, bbox = tracker.update(maskhsv)
cv2.error: /root/opencv-build/opencv_contrib/modules/tracking/src/trackerKCF.cpp:686: error: (-215) img.channels() == 3 in function getSubWindow