Ask Your Question
1

Opencv contrib modules on VS15

asked 2016-11-07 13:30:29 -0600

ThorbjornSomod gravatar image

updated 2016-11-08 03:49:30 -0600

Hi!

I have been trying to build the opencv_contrib module for OpenCV 3.1 on Visual Studio 15. These are the steps I've done so far:

1) Downloaded the OpenCV 3.1 from http://opencv.org/downloads.html and extracted the content to my chosen directory (C:\opencv).

2) Cloned the opencv_contrib repository from here https://github.com/opencv/opencv_contrib and chosen a directory for it (C:\opencv_contrib)

3) I tried running the Cmake GUI from standard command line using admin rights. I chose the VS15 as generator for this.

image description

It got me this error:

image description

Here it seems to me that Cmake is unable to find the VS C++ compiler, and thus is unable to generate the build. To fix this i tried running the cmake-gui from the developer command line for VS15.

image description

This seemed to have done the trick.

image description

I wrote in the path for the OPENCV_EXTRA_MODULES_PATH:

image description

I also ticked OFF the opencv_aruco module as I know it causes problems with my current project.

image description

After this i hit "configure" and let Cmake run. It does this with no error. I then hit "generate" and let it finish. All still good.

image description

4) I then opened the created OpenCV.sln project in the C:\opencv\build folder in VS.

5) I then tried to build the ALL_BUILD and INSTALL project files and get this error output for the building the debug solution of ALL_BUILD:

image description

It seems here to me that the problem lies in Cmake trying to generate a 32bit solution, while VS15 expects a 64bit solution. I have no idea how this happens! Any help would be appreciated!

edit retag flag offensive close merge delete

Comments

I don't do like this. I use cmake gui and select vs 14 2015 win 64 and press configure. then in name "OPENCV" I fill OPENCV_EXTRA_MODULES_PATH with my path to opencvçcontrib : f:/lib/opencv_contrib/modules press generate and open sln project with VS 2015

LBerger gravatar imageLBerger ( 2016-11-07 14:42:43 -0600 )edit

I have tried exactly what you say as well, but if I try to use the win64 compiler it just results in hundreds of errors when I try to build ALL_BUILD and INSTALL in OpenCV.sln...

ThorbjornSomod gravatar imageThorbjornSomod ( 2016-11-07 14:56:21 -0600 )edit

can you post errors? Do you succeed to build opencv with cmake and vs2015?

LBerger gravatar imageLBerger ( 2016-11-07 15:09:22 -0600 )edit

please get github master, not the prebuild 3.1 binaries(they're too old)

berak gravatar imageberak ( 2016-11-07 16:58:34 -0600 )edit

Hi, i encountered the same problem as well. I received lots of errors when i try to "built" the OpenCV.sln. Are there any working solutions? I am using OpenCV3.1.0 (downloaded from the official website), using VS2015 update 3, latest CMake version

chingwai91 gravatar imagechingwai91 ( 2016-11-07 23:58:53 -0600 )edit

like berak said don't use precompiled binaries opencv. Opencv_contrib is build using opencv master from github not with opencv binaries. You must follow readme to build it

LBerger gravatar imageLBerger ( 2016-11-08 01:35:46 -0600 )edit

LBerger, I had tried using the Opencv_contrib using opencv master from Github, but when i try to built it in VS 2015, the results is

Build: 11 succeeded, 133 failed, 1 up-to-date, 0 skipped

Most of the errors are like this

LINK : fatal error LNK1104: cannot open file '....\lib\Debug\opencv_objdetect310d.lib'

All the lib are failed to be linked. Is there anything i did wrongly during the installation?

chingwai91 gravatar imagechingwai91 ( 2016-11-08 01:59:39 -0600 )edit

Dear all, my problem had been solved. Just by disable WITH_CUDA during the CMAKE configuration, then the OpenCV.sln can be built successfully without any errors. But just one question, if CUDA is disabled, how can i use GPU to run for my project if needed?

chingwai91 gravatar imagechingwai91 ( 2016-11-08 03:39:46 -0600 )edit

I have now updated the original post with screenshots and a more understandable project text. I'll try to do this with the opencv-master branch now and see if this gets any better results. I will also try ticking OFF the WITH_CUDA during Cmake config. Thanks for the answers guys, lets hope something works!

ThorbjornSomod gravatar imageThorbjornSomod ( 2016-11-08 03:52:07 -0600 )edit

@ThorbjornSomod don't use vs 2015 in cmake but visual studio 14 2015 win64. Don't forget to delete cache in cmake and Have you downloaded opencv from github?

LBerger gravatar imageLBerger ( 2016-11-08 04:11:25 -0600 )edit

@ThorbjornSomod I think u previously install the Visual Studio 2015 in "Typical" mode, please re-run the installer, click "modify" and then "custom", checked the C++ options. Because the "Typical" mode wouldn't include the C++ language during the installation. U have to choose "custom" during VS 2015 installation. Then only your CMAKE will identify the C++ compiler automatically.

chingwai91 gravatar imagechingwai91 ( 2016-11-08 04:37:30 -0600 )edit

Ok so I'm trying to do this with the opencv-master branch. But like, HOW do you use cmake without the binaries? I mean there is not even a sources folder in the OpenCV directory. I tried using cmake to make the opencv-master branch in the OpenCV directory, but that only builds the standard version of OpenCV!

ThorbjornSomod gravatar imageThorbjornSomod ( 2016-11-08 04:39:12 -0600 )edit

@chingwai91 the problem is that I am already working on a VS15 C++ project, and I'd like to not reinstall VS15 if its possible. Do you know if there is any way of setting this flag post-installation?

ThorbjornSomod gravatar imageThorbjornSomod ( 2016-11-08 04:41:03 -0600 )edit

@ThorbjornSomod (I suppose you run git clone in cmd file in folder f:/lib) git clone https://github.com/opencv/opencv.git

git clone https://github.com/opencv/opencv_cont...

run cmake

Where is the source code F:/lib/opencv

Where to build binaries F:/lib/opencv

configure

then modify OPENCV_EXTRA_MODULES_PATH to F:/lib/opencv_contrib/modules

generate and openproject and build (wait 10 minutes)

PS I prefer build opencv in another folder :Where to build binaries F:/lib/opencv/build..

LBerger gravatar imageLBerger ( 2016-11-08 04:44:17 -0600 )edit

@ThorbjornSomod I not really sure if there is another way to do that. In fact, you won't have to reinstall the whole VS2015, but instead u just need to add the C++ component by re-run the VS2015 installer (I downloaded the VS2015 update 3 ISO and run it), and choose the options as I mentioned in the comment before. This action will not uninstall the VS2015 but will add the C++ language pack to the VS2015. It required about 3GB to 4GB of hard drive storage. About the source file for opencv-master and opencv_contrib-master, u can download both of them directly from the Github. Click the green button "Clone or download", choose "Download zip". After that, u can follow LBerger's method to configure the CMAKE.

chingwai91 gravatar imagechingwai91 ( 2016-11-08 05:21:12 -0600 )edit

Update: I tried just running Cmake with the VS 14 2015 win64 generator, still no improvements. I am now downloading the VS2015 Update 3 ISO and going to try that next. Also @chingwai91: Yeah i know how to clone stuff from Git :) Thanks anyways!

ThorbjornSomod gravatar imageThorbjornSomod ( 2016-11-08 06:13:45 -0600 )edit

@chingwai91 I tried to install VS15 with C++ but it seems I already have it.

ThorbjornSomod gravatar imageThorbjornSomod ( 2016-11-08 06:44:09 -0600 )edit
LBerger gravatar imageLBerger ( 2016-11-08 14:10:12 -0600 )edit

@ThorbjornSomod Sorry for the late reply. Is your problem solved? If not, can u show us the latest errors u received?

If CMAKE having errors, then try to reinstall CMAKE and try it.

chingwai91 gravatar imagechingwai91 ( 2016-11-09 21:56:21 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2016-11-10 02:15:33 -0600

ThorbjornSomod gravatar image

Hi again!

I am happy to say that I have now found a fix that worked for me!

What I had to do was to first generate the solution using Cmake. As generator I had to choose Visual Studio 14 2015 Win64. After I generated the first solution I chose the correct OPENCV_EXTRA_MODULES_PATH and clicked "configure". I then chose ONLY the xfeatures2d module to be generated (as this was the only one I needed) and hit generate again. I then opened the OpenCV.sln project solution in the build folder and built the ALL_BUILD and INSTALL parts in both debug and release. After correct linking the xfeatures2d module worked fine!

The reason I chose only the xfeatures2d module to be generated is that I read that alot of the opencv_contrib modules are corrupted and do not work with VS15. Thanks to all of you for your help in all of this, and I hope this answer can be of help to everyone else aswell.

edit flag offensive delete link more

Comments

No that's wrong on my computer only sfm module is disabled (ceres solver is aproblem on windows) with VS2015 and windows 10. You can check build bot to see

LBerger gravatar imageLBerger ( 2016-11-10 04:26:18 -0600 )edit

I only said that I found a "fix that works for me". Seeing as I am only interested in the xfeature2d module this was the easiest way I could get it to work. I don't know the specifics of which modules it was that were corrupted, and I didnt bother going through them all to check it :)

ThorbjornSomod gravatar imageThorbjornSomod ( 2016-11-10 06:35:55 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2016-11-07 13:30:29 -0600

Seen: 1,859 times

Last updated: Nov 10 '16