Saturday, 3 December 2016

How to install python opencv through Conda ?

I'm trying to install opencv for python through anaconda, but I can't seem to figure this out.
I tried
conda install opencv
conda install cv2
I also tried searching
conda search cv
No cigar. I ran across this which lists opencv as an included package:
After running conda info I noticed my version is 3.4.1 but I couldn't seem to find any information about this version online. I'm pretty confused about this.
Am I missing something pretty obvious here? If opencv was available for a previous version of anaconda, then why wouldn't it be available for the newer version? And why does that link only show me docs for version 1.9.2?

---------------------------------------------------------------------------------------------------------------------------

Answers;


You can install it using binstar:
conda install -c https://conda.binstar.org/menpo opencv

conda install opencv currently works for me on UNIX/python2. This is worth trying first before consulting other solutions.
------------------------------------------------------------------------------------------------------------------------

Answers;

Doesn't seem like the page you linked includes opencv anymore. (Funny, I do recall it being included at a previous point as well.)
In any case, installation of OpenCV into Anaconda, although unavailable through conda, is pretty trivial. You just need to download one file.
  1. Download OpenCV from http://opencv.org/downloads.html and extract
  2. From the extracted folder, copy the file from the extracted directory: opencv/build/python/2.7/(either x86 or x64, depending on your Anaconda version)/cv2.pyd to your Anaconda site-packages directory, e.g., C:\Anaconda\Lib\site-packages
  3. To get ffmpeg within opencv to work, you'll have to add the directory that ffmpeg is located in to the path (e.g., opencv/sources/3rdparty/ffmpeg). Then you'll have to find the dll in that folder (e.g., opencv_ffmpeg_64.dll) and copy or rename it to a filename that includes the opencv version you are installing, (e.g., opencv_ffmpeg249_64) for 2.4.9.
Now at the python prompt you should be able to type "import cv2"...to verify that it works, type "print cv2.__version__" and it should print out the OpenCV version you downloaded











No comments:

Post a Comment