Linking opencv_video for CamShift
From a ROS and CMake newbie.
I'm getting the following error which I believe to be a linking problem.
Built target follow_generate_messages_lisp
Built target follow_generate_messages_eus
Scanning dependencies of target follow_generate_messages
[100%] Built target follow_generate_messages
/home/eepp/catkin_ws/src/follow/src/cam_shift_tracker.cpp: In member function ‘void CamShaftTracker::imageCallback(const ImageConstPtr&)’:
/home/eepp/catkin_ws/src/follow/src/cam_shift_tracker.cpp:272:33: error: ‘CamShift’ is not a member of ‘cv’
cv::RotatedRect trackBox = cv::CamShift(my_backproject, trackWindow,
^
make[2]: *** [follow/CMakeFiles/cam_shift_tracker.dir/src/cam_shift_tracker.cpp.o] Error 1
make[1]: *** [follow/CMakeFiles/cam_shift_tracker.dir/all] Error 2
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
The source code is adapted from camshiftdemo.cpp which I found in the OpenCV version 2.4 samples. It compiles and executes fine stand alone. This is the code snippet as I've adapted it to my ROS follow application.
cv::calcBackProject( &my_hue, 1, 0, my_histogram, my_backproject, &phranges);
my_backproject &= my_mask;
cv::RotatedRect trackBox = cv::CamShift(my_backproject, trackWindow,
cv::TermCriteria (CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 10, 1 ));
In the stand alone demo code compiling it was a simple matter of linking libopencv_video.so. I can't figure out how to do that with catkin. (I'm currently porting some previous work in Electric to Jade). I've tried things like adding the following to package.xml:
<build_depend>opencv_video</build_depend>
and the following plus other things to CMakeLists.txt:
catkin_package(
# INCLUDE_DIRS include
LIBRARIES opencv_video
# CATKIN_DEPENDS roscpp rospy std_msgs
DEPENDS opencv_video
)
add_executable(cam_shift_tracker src/cam_shift_tracker.cpp)
target_link_libraries(cam_shift_tracker
${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
opencv_video
)
Your help with this endeavor to keep a retired engineer's mind agile by stretching it with new skills is appropriated. I learn by doing so I need to see the code before I can connect the dots with tutorials I've read. So I'm sure I've run across the solution but haven't recognized it.
I've also seen evidence of a camshift node which makes me believe that if I load the correct package I should be able to do what I'm doing without writing any code. This is something for me to investigate later.