OPENCV跟踪器未识别(AttributeError:Module' CV2;没有属性' trackerkcf_create;)

发布于 2025-02-10 01:28:03 字数 656 浏览 1 评论 0原文

import cv2

if __name__ == "__main__":
    major_v, minor_v, subminor_v = (cv2.__version__).split('.')
    # >>> 4.6.0
    tracker = cv2.TrackerKCF_create()
    # >>> AttributeError: module 'cv2' has no attribute 'TrackerKCF_create'

如上所述,运行时,这些是我得到的结果(我已经与CV2中的其他跟踪器一起尝试过,除trackermil_create外,所有应该包括的跟踪器都给我带来了这个错误。我用过 pip安装opencv-pythonpip install opencv-contrib-pythonpip安装opencv-contrib-python-headless 在我的终端上尝试安装OpenCV。我没有遇到CV2属性的任何其他问题(例如imreadimshowresize),但是跟踪器给我带来了困难时间,我想知道我从一开始就做错了什么。谢谢。

import cv2

if __name__ == "__main__":
    major_v, minor_v, subminor_v = (cv2.__version__).split('.')
    # >>> 4.6.0
    tracker = cv2.TrackerKCF_create()
    # >>> AttributeError: module 'cv2' has no attribute 'TrackerKCF_create'

As the code above shows, when running this these are the results I get (I have tried this with other trackers in cv2 and other than TrackerMIL_create all trackers that are supposed to be included are giving me this error. I used
pip install opencv-python,
pip install opencv-contrib-python, and
pip install opencv-contrib-python-headless
on my terminal to try and install opencv. I haven't run into any other issues with cv2 attributes (such as imread, imshow, resize) but the trackers are giving me a hard time and I was wondering if there is anything I am doing wrong from the start. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

少女情怀诗 2025-02-17 01:28:03

删除所有内容,然后重新安装opencv-contrib-python。这些软件包可能会相互冲突。 pip卸载opencv-contrib-python opencv-python opencv-contrib-python-headless& PIP安装opencv-contrib-python

Remove everything and then reinstall opencv-contrib-python. The packages can conflict with one another. pip uninstall opencv-contrib-python opencv-python opencv-contrib-python-headless && pip install opencv-contrib-python

梦幻之岛 2025-02-17 01:28:03

与@ddelarue的答案一样,您要确保您已安装了opencv-contrib-python(或opencv-contrib-python-headless),而不是非contrib版本。

此外,在某个时候,API已更改。现在是cv2.trackerkcf.create()(在4.9.0.80中,也可能是更早的版本)

As with @ddelarue answer, you neeed to make sure that you have opencv-contrib-python (or opencv-contrib-python-headless) installed and not the non-contrib versions.

In addition, at some point the API was changed. It is now cv2.TrackerKCF.create() (in 4.9.0.80, and potentially earlier versions too)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文