[英]OpenCV AttributeError module 'cv2.cv2' has no attribute 'TrackerBoosting_create'
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 版本:- opencv 版本 = 4.4.0
opencv-contrib-python = 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'
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.我在 jupyter notebook 中运行上面的代码,当我使用 anaconda 提示符运行这个 notebook 时,它显示了上面的错误,但是当我用 cmd 运行 notebook 时,它运行成功。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.