El módulo OpenCV AttributeError 'cv2.cv2' no tiene atributo 'TrackerBoosting_create'

Oct 11 2020

Intenté crear rastreadores, pero no se está creando un solo rastreador. Cualquier ayuda será muy apreciada.

Versión actual de opencv que instaló: - versión de opencv = 4.4.0

opencv-contrib-python = 4.4.0

Código que estoy usando para crear un rastreador: -

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() 

SALIDA


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'

Respuestas

KishanYadav Oct 12 2020 at 15:33

Mi código se ejecuta correctamente. Ejecuto el código anterior en el cuaderno jupyter y cuando ejecuto este cuaderno usando el indicador de anaconda, muestra el error anterior, pero cuando ejecuto el cuaderno con cmd, se ejecuta correctamente.