Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attribute Error: MultiTracker_create() Not Found in cv2 on Raspberry Pi

I am currently trying to set up the opencv trackers on a Raspberry Pi. However, when I use the MultiTracker_create() function, it gives me an Attribution Error:

multiTracker = cv2.MultiTracker_create()

AttributeError: module 'cv2.cv2' has no attribute 'MultiTracker_create'

The same code works on my computer, but when I try it on the Pi, it experiences the above error. I am currently using Python 3.5 on the Raspi with OpenCV 3.4.4. My computer uses Python 3.7 with OpenCV 3.4.1.

Thank you in advance for your help.

I have made sure that I am using the correct package: pip3 install opencv_contrib_python

I have also tried to look through the help(cv2) and could not find anything specific about the MultiTracker.

like image 379
David Ma Avatar asked Jan 02 '19 21:01

David Ma


1 Answers

Just stumbled upon this myself. It appears that MultiTracker is no longer part of OpenCV 4.5.1, but you should be able to get it from the legacy package like this:

multiTracker = cv2.legacy.MultiTracker_create()

See https://docs.opencv.org/4.5.1/df/d4a/classcv_1_1legacy_1_1MultiTracker.html

Note that if you subsequently call multiTracker.add(...), you'll need to add the legacy version(s) of the trackers as well.

like image 145
fearless_fool Avatar answered Oct 04 '22 03:10

fearless_fool