2
votes

I am tried to create trackers but not a single tracker is creating. Any help would be greatly appreciated.

Current version of opencv that installed :- opencv version = 4.4.0

opencv-contrib-python = 4.4.0

Code that i am using to create tracker :-

import cv2
def ask_for_tracker():
    print("Welcome! What Tracker API would you like to use?")
    print("Enter 0 for BOOSTING: ")
    print("Enter 1 for MIL: ")
    print("Enter 2 for KCF: ")
    print("Enter 3 for TLD: ")
    print("Enter 4 for MEDIANFLOW: ")
    choice = input("Please select your tracker: ")
    
    if choice == '0':
        tracker = cv2.TrackerBoosting_create()
    if choice == '1':
        tracker = cv2.TrackerMIL_create()
    if choice == '2':
        tracker = cv2.TrackerKCF_create()
    if choice == '3':
        tracker = cv2.TrackerTLD_create()
    if choice == '4':
        tracker = cv2.TrackerMedianFlow_create()
    return tracker

tracker = ask_for_tracker() 

OUTPUT


Welcome! What Tracker API would you like to use?
Enter 0 for BOOSTING: 
Enter 1 for MIL: 
Enter 2 for KCF: 
Enter 3 for TLD: 
Enter 4 for MEDIANFLOW: 
Please select your tracker: 0
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-956dbed87488> in <module>
     23     return tracker
     24 
---> 25 tracker = ask_for_tracker()

<ipython-input-8-956dbed87488> in ask_for_tracker()
     10 
     11     if choice == '0':
---> 12         tracker = cv2.TrackerBoosting_create()
     13     if choice == '1':
     14         tracker = cv2.TrackerMIL_create()

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

1
Seems like a duplicate of this - yudhiesh
No there is not duplicate cv2 written anywhere. - Kishan Yadav

1 Answers

0
votes

My code run successfully. I run above code in jupyter notebook and when i run this notebook using anaconda prompt it shows above error, but when i run notebook with cmd then it run successfully.