0

I'm trying to track multiple objects in a video using openCV (4.5.5.64) in python. I have the bounding boxes for every frame already.

Mainly, I need to keep track of which box belongs to which ID for each frame.

The cv2.MultiTracker_create() function is no longer in use and I'm having trouble reinstalling an older version of openCV that supports it. The function also takes in the bounding box only when you add a new tracker (once per object), and I'd like to utilize my bounding boxes for every frame if possible.

What recommendation do you have for the best way to go about this?

Current ideas:

  • I can try to use the legacy version of multitracker, but there's still the issue where I want to use my bounding boxes.
  • I can also try something with the centroid of each bounding box (ex: https://pyimagesearch.com/2018/07/23/simple-object-tracking-with-opencv/), but it requires more work on my end since I have to implement that (if there is a library that does this automatically, please let me know)

Sidenote: there are upwards of 50 objects for ~1200 frames, but the program doesn't necessarily need to be extremely fast (probably no more than 15 minutes to run).

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
Eli.helpmepls
  • 11
  • 1
  • 4
  • Please check if you can access `cv2.legacy.MultiTracker_create()` [from here](https://docs.opencv.org/4.5.1/df/d4a/classcv_1_1legacy_1_1MultiTracker.html) – Jeru Luke Jul 08 '22 at 21:17
  • When trying to add a new tracker using 'retval = cv.legacy_MultiTracker.add(newTracker, image, boundingBox)', I'm getting the error: AttributeError: 'cv2.legacy.MultiTracker' object has no attribute 'legacy_MultiTracker' – Eli.helpmepls Jul 08 '22 at 22:13
  • FYI I'm using opencv-contrib-python 4.6.0.66 – Eli.helpmepls Jul 08 '22 at 22:14
  • strange attribute error. the code you claim to run does not match the error. please present a [mre] – Christoph Rackwitz Jul 09 '22 at 09:44

0 Answers0