opencv_contrib icon indicating copy to clipboard operation
opencv_contrib copied to clipboard

[Feature Request]: remove() method in MultiTracker()

Open bitcurian opened this issue 5 years ago • 5 comments

The MultiTracker class in tracker.hpp is great for a quick demo of multi-object tracking using different trackers and objects.

I understand that it's a naive implementation and has not been optimized. However there is atleast one critical function that it requires, namely a method to remove objects that are not in the frame

Currently, the only way to do this is to use clear() and then reinitialize the MultiTracker() class with the new set of (tracker,bbox) pairs.

Multi-object tracking is certainly not an easy problem, especially with occlusion. However there needs to be , at the very least, a method to manually remove (tracker,object) pairs that are not being tracked.

I'd also suggest adding an experimental method to remove objects that are not in the frame. If the object has a fixed size and is lost, it could be removed from the tracker if the bounding box area increases beyond a certain threshold or the regressor's prediction is below a specific threshold. It could be invoked by specific flags in the argument. This would certainly be preferable to the alternative of having the tracker track another similar object.

Other Issue which addressed this: https://github.com/opencv/opencv_contrib/issues/2368

Class reference docs : https://docs.opencv.org/master/d8/d77/classcv_1_1MultiTracker.html

OpenCV Q&A : https://answers.opencv.org/question/140415/how-to-delete-an-object-from-multitracker/

Thanking you in advance, Sincerely, Vj

bitcurian avatar Dec 05 '19 17:12 bitcurian

Plus one for this feature, it would be very useful to have!

dkout avatar May 08 '20 16:05 dkout

I also met the same problem. Have you solved it?

Damon2019 avatar Dec 13 '20 06:12 Damon2019

found a hacky solution that could work on some problems

(tracking_ok, boxes) = trackers.update(frame)

if tracking_ok:
         # some code
else:
        trackers_arr = np.array(trackers.getObjects())
        idx = np.where(trackers_arr.sum(axis=1)!=0)[0]
        trackers_arr=trackers_arr[idx]
        ID_array = ID_array[idx] 
        trackers = cv2.legacy.MultiTracker_create()
        for i in trackers_arr:
            tracker = cv2.legacy.TrackerCSRT_create()
            trackers.add(tracker, frame, tuple(i))

kokoteen avatar Feb 18 '21 06:02 kokoteen

@kokoteen OMG Thank you!!!!!

HelenTsvetkova avatar Jun 09 '22 12:06 HelenTsvetkova

@kokoteen

Thanks a lot !

zain18jan2000 avatar Jul 05 '22 18:07 zain18jan2000

remove() and then a way set of a new bounding box too for a specific tracker and way to find which specific tracker failed. The current multi tracker is some kind of a demo at best.

TByte007 avatar Nov 27 '22 23:11 TByte007