在所有conda环境中安装OpenCV [英] Installing OpenCV for all conda environments
问题描述
我有一个安装有Anaconda的Ubuntu 16.04系统.我想编译并安装OpenCV 3.3,并且还使用Python绑定.我使用了以下CMake命令:
I have an Ubuntu 16.04 system with an Anaconda installation. I want to compile and install OpenCV 3.3 and use also the Python bindings. I used the following CMake command:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D D WITH_FFMPEG=1 -D WITH_CUBLAS=ON -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.3.0/modules -D BUILD_EXAMPLES=ON -D BUILD_TIFF=ON -D PYTHON_EXECUTABLE=/home/guel/anaconda2/envs/py27/bin/python -D PYTHON2_LIBRARIES=/home/guel/anaconda2/envs/py27/lib/libpython2.7.so -D PYTHON2_PACKAGES_PATH=/home/guel/anaconda2/envs/py27/lib/python2.7/site-packages -DWITH_EIGEN=OFF -D BUILD_opencv_cudalegacy=OFF ..
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D D WITH_FFMPEG=1 -D WITH_CUBLAS=ON -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.3.0/modules -D BUILD_EXAMPLES=ON -D BUILD_TIFF=ON -D PYTHON_EXECUTABLE=/home/guel/anaconda2/envs/py27/bin/python -D PYTHON2_LIBRARIES=/home/guel/anaconda2/envs/py27/lib/libpython2.7.so -D PYTHON2_PACKAGES_PATH=/home/guel/anaconda2/envs/py27/lib/python2.7/site-packages -DWITH_EIGEN=OFF -D BUILD_opencv_cudalegacy=OFF ..
该命令完成了工作,但是,当然,仅为我创建的特定conda环境安装了OpenCV.但是,我希望能够在不同的环境中使用它,而不必对每个环境都进行编译.有没有一种简单的方法可以实现这一目标?由于OpenCv库实际上是安装在/usr/local
中的,因此我可以想象必须有一种简单的方法将这些库链接到每个新的conda环境,但是我不知道具体如何.
The command does the job but then, of course, OpenCV is installed only for a specific conda environment that I created. However, I want to be able to use it also from different environments without having to go through the compilation for each and every environment. Is there a way to achieve that in a simple way? Since the OpenCv libraries are actually installed in /usr/local
, I can imagine that there must be a simple way to link the libraries to each new conda enviroment but I couldn't figure out exactly how.
推荐答案
OpenCV 3.3
.您可能不需要编译自己.只需使用conda command
将其安装到您的环境中即可.
OpenCV 3.3
for python 2.7 and 3.6
on linux
are available from conda repository
. You may not need to compile yourself. Just use conda command
to install it to your environement.
查看此
- https://anaconda.org/conda-forge/opencv 获取命令.
-
conda install -c conda-forge -n env opencv
或 -
conda install -c conda-forge/label/broken -n env opencv
- 其中
env
是您的conda virtual environment name
-
- https://anaconda.org/conda-forge/opencv for the commands.
conda install -c conda-forge -n env opencv
orconda install -c conda-forge/label/broken -n env opencv
- where
env
is yourconda virtual environment name
希望获得帮助.
这篇关于在所有conda环境中安装OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!