0
votes

I have seen this question pop up several places, but the only time I have seen it answered is through Visual Studio using cpp or on a Linux OS.

I am trying to add contribution modules to OpenCV and for use with Python-Anaconda in Spyder. Specifically, I am looking to add the bgsegm module. I have tried several different ways but with no success.

I have downloaded the current master branches of OpenCV and Opencv_contrib. I put them in a new folder I named opencv-3.0. In opencv I create a new folder named build. I ran command prompt in that folder and used the command:

cmake -D OPENCV_EXTRA_MODULES_PATH= ..\..\opencv_contrib\modules

which returns

the source directory "C:/opencv-3.0/opencv_contrib/modules" does not appear to contain CMakeLists.txt

What am I missing on the command line? make -j5? I dont even get the option to run it because of the error.

Alternatively when running from the cmake GUI, I'm not sure what to use as my generator. I do not have Visual Studio and that is what everyone seems to use. Even if I had VS I want to be able to use this in python and Sypder. Suggestions?

1
Space between OPENCV_EXTRA_MODULES_PATH and ..\..\opencv_contrib\modules means that you assign empty value for variable and attempt to use given path as source. Correct call: cmake -D OPENCV_EXTRA_MODULES_PATH=..\..\opencv_contrib\modules ..Tsyvarev
Thank you for responding. I added the space because I was receiving other errors when I did not have it. I see now the error in having it there. When I run the corrected code with .. at the end it returns "--building for: NMake MAkefiles" and then I get the error "cmake must be run from a shell that can use the compiler cl from the command line." and that my compiler identification is unknown. the full output is multiple lines but this is the jist. I get the feeling I am missing a major part of what is necessary for cmake...like a compiler.atjenk
The error message cmake must be run ... looks selfexplanatory. You may also google it. If you will failed to resolve your problem, formulate it in the question post itself, not in the comments: On Stack Overflow comments are used only for clarifiing posts(questions, answers) or for request for clarification.Tsyvarev
My apologies, will fix that. Thanks for the clarification.atjenk

1 Answers

0
votes

Even though you want to use Python, you will have to compile the OpenCV Contrib Modules yourself before you will be able to use it with Python.

CMake generates Makefiles for your compiler (so get one if you don't have one), after that you can compile the Makefile/Visual Studio solution.

The error you're receiving from CMake is because you did not specify the OpenCV source directory as the last argument. Follow the instructions here precisely.

So something like:

cd "C:/opencv-3.0/build"
cmake -DOPENCV_EXTRA_MODULES_PATH="C:/opencv-3.0/opencv_contrib/modules" "C:/opencv-3.0"