I'm trying to perform a simple object detection using OpenCV in Python. My problem is that I cannot use TrackerMOSSE_create method as if it not exists.
I've only installed opencv-contrib-python package using pip install opencv-contrib-python
and I'm aware that it cannot coexist with the opencv-python in one virtual env so I dont have that one.
I'm working on MAC and Python 3.8. There is a code below.
import cv2
print(cv2.__version__)
cap = cv2.VideoCapture(0)
tracker = cv2.TrackerMOSSE_create()
while True:
timer = cv2.getTickCount()
success, img = cap.read()
fps = cv2.getTickFrequency() / (cv2.getTickCount() - timer)
cv2.putText(img, str(int(fps)), (75, 50), cv2.FONT_ITALIC, 0.7, (0, 0, 255), 2)
cv2.imshow("Tracking", img)
if cv2.waitKey(1) & 0xff == ord('q'):
break
The error I have:
Traceback (most recent call last):
File "/Users/marcin94/PycharmProjects/tracker_objects/main.py", line 8, in <module>
tracker = cv2.TrackerMOSSE_create()
AttributeError: module 'cv2.cv2' has no attribute 'TrackerMOSSE_create'
question from:
https://stackoverflow.com/questions/65645900/failed-to-use-cv2-trackermosse-create-and-other-methods-in-opencv-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…