0

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})
4
  • Are these 4 lines the only errors you get? If so, it seems to be a linking problem. Could you add the CMakeLists.txt? Commented Apr 15, 2015 at 21:22
  • I also tried to compile another code of mine with cmake, which was working before, and now is not anymore.... I guess, I messed up an enviroment variable. However, here is a snapshot from the CMakeLists.txt of the code, which was working with no error before: <!-- begin snippet: js hide: false --> <!-- language: lang-html --> cmake_minimum_required (VERSION 2.8.3) project (test) set (test_VERSION "1.3.0") find_package( OpenCV REQUIRED ) include_directories( ${OpenCV_INCLUDE_DIRS} ) target_link_libraries( test ${OpenCV_LIBS}) <!-- end snippet --> Commented Apr 15, 2015 at 23:19
  • It would be more readable if you edit your previous message and add the whole CMakeLists.txt there. Commented Apr 16, 2015 at 8:10
  • Yeah, sorry about that, I thought it would look differently. I put the CMakeLists.txt at the end of my question. Commented Apr 16, 2015 at 16:37

2 Answers 2

2

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!

Sign up to request clarification or add additional context in comments.

1 Comment

Hello @snow, I get the same problem in ROS jade. In /opt/ros/jade/include. I have opencv_apps, instead of opencv and opencv2. But I want to try your approach! So what does "chaning the names of the two folder..." mean? Do you change the folder names? Thank you for taking time on my question.
-1

Try to write just before including opencv2 :

#include <vector>
using namespace std;

1 Comment

That just gives me other errors in feature2d.hpp. Also why would I need to include vector before and also using the std namespace. I never saw that you have to do that in order to use the nonfree includes from opencv?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.