Cannot create tracker

Hello,
I have a working code. I developed it on my Win10 computer then ported it to a Ubuntu machine. Everything works on my computer but I cannot create any of the trackers on the Ubuntu computer. When I execute

tracker = cv2.TrackerBoosting_create()

I see this error message:

Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
AttributeError: module ‘cv2.cv2’ has no attribute ‘Tracker_create’

My computer:
Win10, Python3.8.5, Opencv4.0.1, Opencv-contrib-python4.4.0.46

Other computer:
Ubuntu16.04, Python3.6.9, Opencv-contrib-python 4.5.1.48

I have no idea about why I cannot create the tracker on the Ubuntu machine.

how did you install any of that ?

if it was via pip, make sure to install only opencv-contrib-python (NOT opencv-python) else the latter will “shadow” the former, and you cannot use the contrib extra functionality

I installed them with pip3. I work in a python3 virtual environment. I uninstalled both opencv and opencv contrib and installed again opencv-contrib-python with pip3. now

print(cv2._version_)

shows 4.5.1. But when I run

pip3 show opencv

I see this warning:

WARNING: Package(s) not found: opencv

I believe there is something wrong with my virtual environment but I see the correct opencv version when I print it in my python script. This confuses me. I have Opencv-contrib-python4.4.0.46 on my windows machine. But I have this problem on the Ubuntu machine. Everything works on the Windows machine.

EDIT: On my win10 computer I created a new conda environment and installed the latest opencv-contrib-python with pip. I see the same error message when I try to create the tracker in the new environment. There is no problem with opencv-contrib-python ver. 4.4.0.46.

Hi! I think your problems with the latest version of the opencv-contrib-python can be related to changes in tracking API:

I tried to use Win10, Python 3.8.5, opencv-contrib-python==4.4.0.46, and all works fine.
Please, use the 4.4.0.46 version for now and keep watching for changes in tracking API:

and changes of opencv-python:

:slight_smile:
Also, the pip show open-contrib-python command should work, instead of pip3 show opencv.

2 Likes

indeed, latest changes to the tracking api seem a bit messy.

while

        TrackerCSRT
        TrackerGOTURN
        TrackerKCF
        TrackerMIL

behave as expected (they were moved into the main opencv repo), we now have:

        legacy_MultiTracker
        legacy_Tracker
            legacy_TrackerBoosting
            legacy_TrackerCSRT
            legacy_TrackerKCF
            legacy_TrackerMIL
            legacy_TrackerMOSSE
            legacy_TrackerMedianFlow
            legacy_TrackerTLD

(from >>>help(cv2))

when using latest 4.5.1, please try:

tracker = cv2.legacy.TrackerBoosting_create()
2 Likes

Working for me with Win10, opencv-contrib-python last version and Python 3.8.5.