Anaconda/OpenCV:安装跟踪功能

Anaconda/OpenCV: Installing with Tracking features

希望有人能在这里指出正确的方向。

我使用的是最新版本的 Anaconda (Python 2.7)。我想将它与具有跟踪功能的 OpenCV 一起使用。我已经尝试了各种版本的 cv2.pyd 文件,包括 3.0、3.1、3.2、3.3 和 3.4。但是,我发现的示例使用了模块中未找到的以下命令之一。

tracker = cv2.Tracker_create(tracker_type)

tracker = cv2.TrackerKCF_create()

其中任何一个的用法取决于所使用的 OpenCV 版本。但是,它们都不起作用,都出现以下错误。

'module' object has no attribute 'Tracker_create / or TrackerKCF_create'

OpenCV 中的所有其他功能似乎都可以正常工作。

我从 Windows OpenCV 安装中提取的 cv2.pyd 文件是否仅限于某些功能?

如果我在 Anaconda 提示中使用以下内容

conda install -c menpo opencv3

它安装了我需要的跟踪功能。但是,它安装了 OpenCV v3.1,已知该版本在跟踪功能方面存在缺陷。理想情况下,我不想使用 OpenCV v3.4。

如有任何帮助,我们将不胜感激。

如果您使用的是 Anaconda,那么最好使用它的 environment management 工具。使用以下内容创建 environment.yml 文件:

environment.yml 使用 conda-forge/opencv & python 3.6

name: opencv-env      # any name for the environment
channels:
- conda-forge
dependencies:         # everything under this, installed by conda
- python=3.6
- opencv=3.4
- pip:                # everything under this, installed by pip
  - future

environment.yml 使用 pip/opencv-python & python 3.6

name: opencv-env      # any name for the environment
channels:
- defaults
dependencies:         # everything under this, installed by conda
- python=3.6
- pip:                # everything under this, installed by pip
  - future
  - opencv-python>=3.4

如何安装环境?

conda create --force -f environment.yml

如何激活环境?

source activate opencv-env

激活环境后,您可以检查 opencv 的版本。