snow
snow

Reputation: 71

OpenCV compiling error with nonfree/feature2d.hpp

I am trying to compile a C++ code in ROS indigo using catkin_make under Ubuntu 14.04. I am getting the following error:

/usr/local/include/opencv2/nonfree/features2d.hpp:73:21: error: ‘vector’ has not been declared
                     vector<KeyPoint>& keypoints) const;
                     ^
/usr/local/include/opencv2/nonfree/features2d.hpp:73:27: error: expected ‘,’ or ‘...’ before ‘<’ token
                     vector<KeyPoint>& keypoints) const;
                           ^
/usr/local/include/opencv2/nonfree/features2d.hpp:77:21: error: ‘vector’ has not been declared
                     vector<KeyPoint>& keypoints,
                     ^
/usr/local/include/opencv2/nonfree/features2d.hpp:77:27: error: expected ‘,’ or ‘...’ before ‘<’ token
                     vector<KeyPoint>& keypoints,

Does anyone has a clue, what the issue might be? Note that this error is occurring in the feature2d.hpp from OpenCV (so its not a file I made). I already tried to reinstall OpenCV and also ROS, but that did not fix the error.

I would be very thankful if anyone has any idea how to solve that.

Thanks,

snow

Edit: Here is the CMakeLists.txt:

cmake_minimum_required (VERSION 2.8.3)
project (test)
set (test_VERSION "1.0.0")

find_package( OpenCV REQUIRED )         

if ( NOT OpenCV_FOUND )
  message(FATAL_ERROR "Package OpenCV required, but not found!")
endif( NOT OpenCV_FOUND )

find_package( Eigen3 REQUIRED )         

include_directories(
  ${EIGEN3_INCLUDE_DIR}             
  ${CMAKE_CURRENT_SOURCE_DIR}/include
  ${OpenCV_INCLUDE_DIRS}
)

set (SOURCE
  src/test.cpp)

add_library (test ${SOURCE})
set_target_properties (test PROPERTIES
  COMPILE_FLAGS "-std=c++11")

target_link_libraries( test ${OpenCV_LIBS} ${EIGEN3_LIBRARY_DIRS})

Upvotes: 0

Views: 2315

Answers (2)

snow
snow

Reputation: 71

I kinda fixed it, but I guess its not the proper way of doing it:

ROS is already coming with an OpenCV Version. On my computer I also installed a separate newer OpenCV Version. I fixed it by changing the names of the two folder opencv and opencv2 in the directory /opt/ros/indigo/include. Now, the complier is not using ROS' OpenCV anymore, but the one I installed and that is fixing my issue.

Again, I think thats not how it should be done, so if somebody has any better idea, please let me know!

Upvotes: 2

dima125
dima125

Reputation: 19

Try to write just before including opencv2 :

#include <vector>
using namespace std;

Upvotes: -1

Related Questions