我试图通过Anaconda为Python安装OpenCV,但我似乎无法解决这个问题。

我试着

conda install opencv
conda install cv2

我也试着搜索

conda search cv

没有雪茄。我无意中看到这个列出了opencv作为一个包含包:

http://docs.continuum.io/anaconda/pkgs.html

在运行conda info后,我注意到我的版本是3.4.1,但我似乎在网上找不到任何关于这个版本的信息。我对此很困惑。

我是不是遗漏了一些很明显的东西?如果opencv可用于Anaconda的以前版本,那么为什么它不能用于新版本呢?为什么这个链接只显示版本1.9.2的文档?


当前回答

和其他人一样,我在OS X 10.11上使用Python 3.5.1/Anaconda 2.4.0时遇到了问题。

但我在这里找到了一个兼容的软件包:

https://anaconda.org/menpo/opencv3

它可以像这样通过命令行安装:

 conda install -c https://conda.anaconda.org/menpo opencv3

效果很好。这是我第一次在3.x上使用OpenCV !

其他回答

要在不降级的情况下安装opencv,只需在终端中点击这个 特别是linux mint或基于Ubuntu的发行版的用户

conda install -c conda-forge opencv

因此,我很确定这不会让你失望。

我只是想更新Atlas7的精彩答案。

如果你正在使用OpenCV 3,将测试代码更改为以下内容:

import cv2
cap=cv2.VideoCapture("input_video.mp4")
print cap.isOpened()   # True = read video successfully. False - fail to read video.

fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))
print out.isOpened()  # True = write out video successfully. False - fail to write out video.

cap.release()
out.release()

下面的命令也适用于我。我正在Anaconda中使用嵌入式IPython Notebook。

conda install -c https://conda.binstar.org/menpo opencv

我刚刚在两台Win32 Python 3.5电脑上试了试。起初,我能够conda安装opencv,但它不工作,也没有从menpp的版本,但这做到了:

conda install -c https://conda.binstar.org/conda-forge opencv

我有步骤在回购,将帮助您正确安装OpenCV。

如果链接断了,看这个。

对于要求和先决条件,请遵循以下说明:

你需要有WINDOWS操作系统来开始这个项目。

Windows 7到10

请仔细执行以下步骤

Install Anaconda2 32/64 python 2 or Install Anaconda3 32/64 python 3 It Depends on System Information Along the way you must check all the options ignore the red text Then wait till installation completed ... Open CMD admin when finish installed Make sure that the anaconda-python is configured in CMD admin Type: python This will come out: C:\WINDOWS\system32>python Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. Next is to install packages: Numpy OpenCV PyMySQL or pymysql Install and Import OpenCV conda install -c conda-forge opencv = (version optional) (click yes if there's updates) Install and Import Numpy pip install numpy (click yes if there's updates) Install and Import PyMySQL/pymysql pip install PyMySQL or pymysql When all the package is completely installed, then you must Reboot it. go to CMD admin again type "python" import cv2 (cv2 is OpenCV) import Numpy or numpy import pymysql import os from PIL from Image if all of then is ok.. your ready to run the code!! After you finish all the steps, you can now test the code in SPYDER python that I use