OpenCV 3.0 xfeatures2d.lib not Being Compiled

asked 2015-06-13 01:26:11 -0500

jpistorino gravatar image

updated 2015-06-13 10:44:33 -0500

I am trying to transition from OpenCV 2.4.9 to 3.0 but I am having trouble getting xfeatures2d to compile as a lib. I am using VS2012 c++/cli on a Win8.1 64 bit machine using CMake 3.0.1.

I do not have any problem just making OpenCV 3.0 itself but need to add xfeatures2d so I can use SURF, etc.

I downloaded the xfeatures2d, etc. code from and installed it on my hard drive at the root, so the files are stored in opencv_contrib-master. I added c:/opencv_contrib-master/modules to the OPENCV_EXTRA_MODULES_PATH setting but changed nothing else. CMake config and master report no problems.

When I now select the ALL_BUILD project, I compile for quite a period of time. The first project I fail at says:

94>Time Elapsed 00:00:05.27
98>------ Build started: Project: (sample) simpleflow_demo, Configuration: Debug x64 ------
98>Build started 6/12/2015 10:42:43 PM.
98>  Touching "example_optflow_simpleflow_demo.dir\Debug\(sample) simpleflow_demo.unsuccessfulbuild".
98>  Building Custom Rule C:/opencv_contrib-master/modules/optflow/CMakeLists.txt
98>  CMake does not need to re-run because C:\opencv\build\modules\optflow\CMakeFiles\generate.stamp is up-to-date.
97>C:\opencv_contrib-master\modules\optflow\samples\optical_flow_evaluation.cpp(43): error C2065: 'NAN' : undeclared identifier

97>C:\opencv_contrib-master\modules\optflow\samples\optical_flow_evaluation.cpp(64): error C2065: 'NAN' : undeclared identifier 98>ClCompile: 98> simpleflow_demo.cpp 97> 97>Build FAILED.

Next, I fail at:

118>Time Elapsed 00:00:16.65
126>------ Build started: Project: opencv_line_descriptor, Configuration: Debug x64 ------
126>Build started 6/12/2015 10:43:48 PM.
126>  Touching "opencv_line_descriptor.dir\Debug\opencv_line_descriptor.unsuccessfulbuild".
126>  Building Custom Rule C:/opencv_contrib-master/modules/line_descriptor/CMakeLists.txt
126>  CMake does not need to re-run because C:\opencv\build\modules\line_descriptor\CMakeFiles\generate.stamp is up-to-date.
126>  opencv_line_descriptor_pch.cpp
124>  depth_cleaner.cpp
124>  depth_to_3d.cpp
124>  linemod.cpp
124>  normal.cpp
124>  odometry.cpp
124>  plane.cpp
124>  utils.cpp
77>C:\opencv\sources\modules\core\include\opencv2/core/base.hpp(342): warning : function declared with "noreturn" does return
123>C:\opencv\sources\modules\core\include\opencv2/core/base.hpp(342): warning : function declared with "noreturn" does return
126>c:\opencv_contrib-master\modules\line_descriptor\src\bitops.hpp(104): error C2059: syntax error : 'bad suffix on number'
126>c:\opencv_contrib-master\modules\line_descriptor\src\bitops.hpp(104): error C2146: syntax error : missing ',' before identifier 'U'
126>c:\opencv_contrib-master\modules\line_descriptor\src\bitops.hpp(104): error C2065: 'U' : undeclared identifier
124>     Creating library C:/opencv/build/lib/Debug/opencv_rgbd300d.lib and object C:/opencv/build/lib/Debug/opencv_rgbd300d.exp
126>Build FAILED.

Ultimately, VS reports: ========== Build: 181 succeeded, 186 failed, 0 up-to-date, 55 skipped ==========

I have tried only specifying the top level of the contrib download (i.e., c:/opencv_contrib-master) in CMake and while that reports fewer failures, it still does not build xfeatures2d.

I disabled line_descriptor without much effect. It only ... (more)

edit retag flag offensive close merge delete



Source file is not compatible with VS 2012. There is less problem with VS 2013. You have to modify source file yourself. Ihave done it and I think it is correct (I m' not sure)

LBerger gravatar imageLBerger ( 2015-06-13 02:06:08 -0500 )edit

i have not met a single person, who compiled the linedescriptor module on win successfully ;(

try to disable it: cmake -DWITH_opencv_line_descriptor=OFF

in a similar way , just disable anything that comes in your way.

but you say, that xfeatures2d was also not built. what were the problems with that ?

berak gravatar imageberak ( 2015-06-13 03:53:39 -0500 )edit

You mean with vs2012 because with vs2013 it's ok. with vs2012 you have to change :

opencv_contrib\modules\line_descriptor\src\bitops.hpp(104) 0xFFFFFFFFFFFFFFFFLLU in 0xFFFFFFFFFFFFFFFFULL

and add in file binary_descriptor.cpp line 59

static int round(double d)
    return cvRound(d );

After I don't know if it works. Which example is using this module?

LBerger gravatar imageLBerger ( 2015-06-13 05:04:57 -0500 )edit

Thanks berak and LBerger. I edited my question to reflect the changes I made but still no success. Any help appreciated. Also, would moving to VS2013 or higher be advisable? I am guessing that VS2012 is the most widely used VS version and don't want to move the platform unless I have to.

jpistorino gravatar imagejpistorino ( 2015-06-13 10:46:31 -0500 )edit

For NAN you can use

#define NAN        ((float)(INFINITY * 0.0F))

For bitops line 104 must be

UINT64 mask = b == 64 ? 0xFFFFFFFFFFFFFFFFULL: ( ( UINT64_1 << b ) - UINT64_1 );

like @berak said you can disable this module CMake. Do you need Line decritptor?

You can use many things of C++11 in VS 2013

LBerger gravatar imageLBerger ( 2015-06-13 11:16:25 -0500 )edit

berak - could I trouble you for help on this? I reposted this as a more clear question as As I am just doing what I think anyone trying to compile things would, I hope my questions have some broader application. Thanks

jpistorino gravatar imagejpistorino ( 2015-06-15 20:44:44 -0500 )edit