I am using OpenCV 3.1.0 , Python 2.7.11 and Windows 10. I want to build the extra modules (opencv_contrib) into OpenCV.
I follow the step in this GitHub.
$ cd <opencv_build_directory>
$ cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules <opencv_source_directory>
$ make -j5
When I type cmake _DOPENCV_EXTRA_MODULES_PATH=C:\opencv_contrib\opencv_contrib/modules C:\opencv\sources
, there is an error.
I am looking for help how can I solve it. Thank you.
Update 29-5-2017: This also works with OpenCV 3.2.0-dev. Now using Visual Studio 2015 or 2017 gives no errors.
The cv2.pyd is now automatically moved to site-packages. You just only need to copy the DLLs.
As mentioned by @AleksandrUsarov in the comments section, this method still works for OpenCV 4.1.2, but you need to check
OPENCV_ENABLE_NONFREE
parameter as well.
I have made a tutorial on how to compile and build your own OpenCV 3.1.0-dev from scratch. It is simple and organized and works with me very well. If you have time to recompile OpenCV check out the tutorial.
The steps to follow are:
opencv-3.1.0-dev
and in this directory create other two directories one called build
and the other called sources
. The paths
will be opencv-3.1.0-dev\build
and opencv-3.1.0-dev\sources
.opencv-master.zip
and opencv_contrib-master.zip
opencv
and opencv_contrib
directoriesgenerating is done
before continuing.OpenCV.sln
. Right click on this .sln file and open it with the visual studio 2013 used in CMake.Be patient as this step and the next will take a lot of time.
Release
. These step take about 10 to 15 minutes..dll
files [present at opencv-3.1.0-dev\build\bin\Release
] and the cv2.pyd
and paste them in the site-packages
directory in Pyhton27\Lib\site-packages
.import cv2
. If no errors, execute cv2.__version__
, and you should get 3.1.0-dev
.If anything is not clear please watch the tutorial provided at the beginning of this answer.