learnopencv icon indicating copy to clipboard operation
learnopencv copied to clipboard

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

Open job2003 opened this issue 3 years ago • 4 comments

when i run MultiObjectTracker, i use python example. The following error happens.

Cancel the selection process by pressing c button! Press q to quit selecting boxes and start tracking Press any other key to select next object Selected bounding boxes [(281, 174, 41, 59), (275, 275, 55, 79), (307, 282, 78, 64), (267, 274, 75, 104), (445, 234, 79, 96), (429, 179, 116, 122)] Traceback (most recent call last): File ".\multiTracker.py", line 94, in multiTracker = cv2.MultiTracker_create() AttributeError: module 'cv2.cv2' has no attribute 'MultiTracker_create'

I have installed
opencv-contrib-python 4.5.1.48 opencv-python 4.5.1.48

I try reinstall the above package, but same issues exist.

job2003 avatar Jan 24 '21 22:01 job2003

Can you provide a bit more information? Do you have multiple versions of Python installed? How have you installed them, under which operating-system? Have you installed a binary package or from source-code? How have you started the multi-object-tracker example? Started with "python multiTracker.py" or "python3 multiTracker.py"? From the OpenCV documentation it looks like "MultiTracker_create" is for OpenCV version 3.x only...?

brmarkus avatar Jan 25 '21 07:01 brmarkus

Can you provide a bit more information? Do you have multiple versions of Python installed? How have you installed them, under which operating-system? Have you installed a binary package or from source-code? I installed python3.8 through anaconda, under windows 10 system. How have you started the multi-object-tracker example? i enter the directory and run $python multiTracker.py Started with "python multiTracker.py" or "python3 multiTracker.py"? I use python multiTracker.py because I only installed python3.8 From the OpenCV documentation it looks like "MultiTracker_create" is for OpenCV version 3.x only...? "MultiTracker_create" is not available for OpenCV 4? I build opencv 4.5.1 from source

job2003 avatar Jan 25 '21 08:01 job2003

From the OpenCV documentation I can find e.g. "https://docs.opencv.org/3.4/d8/d77/classcv_1_1MultiTracker.html", but when changing the OpenCV version in the upper-left drop-down field to v4.5.1 the API documentation can't be resolved... It works up to version v4.5.0... https://docs.opencv.org/4.5.0/d8/d77/classcv_1_1MultiTracker.html

The documentation https://docs.opencv.org/4.5.1/d8/d77/classcv_1_1MultiTracker.html leads to

Not Found
The requested URL /4.5.1/d8/d77/classcv_1_1MultiTracker.html was not found on this server.

brmarkus avatar Jan 25 '21 08:01 brmarkus

firstly check all the installed packages if any package is missing then install them and if all packages are installed successfully then make sure that in C:\Python\Lib\site-packages\cv2 directory there is a file named cv2.cp37 type file with extension .pyd is present, if is not, then install it after installing in the same directory I hope your program 'MultiObjectTracker' will run successfully.

Utkarsh1504 avatar Jan 27 '21 15:01 Utkarsh1504