Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
869 views
in Technique[技术] by (71.8m points)

Failed to use cv2.TrackerMOSSE_create() and other methods in openCV [Python]

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-pythonand 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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...