issue on compiling package using opencv
I am trying the HOG based human detection algorithm under ros, and following the source file of opencv/samples/cpp/peopledetect.cpp (This source file can be compiled using g++ without issue on my computer,
g++ -o output peopledetect.cpp pkg-config opencv --cflags --libs
).
But after putting into an ros package, I can't get the similar codes to compile successfully. I did follow the instructions at www.ros.org/wiki/opencv2 to set CMakeLists.txt and manifest.xml. But I still keep getting the following compile error,
/home/ros/spyrobot/human_detect/src/human_detect.cpp:27:1: error: ‘hog’ does not name a type make[2]: * [CMakeFiles/human_detect.dir/src/human_detect.o] Error 1 make[1]: * [CMakeFiles/human_detect.dir/all] Error 2 make:* [all] Error 2
The error refers to the following two lines which are copied from the peopledetect.cpp source file,
HOGDescriptor hog;
hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());
My current environment, ubuntu 12.04, ROS fuerte, ros-fuerte-opencv2 2.4.0, ros-fuerte-vision-opencv 1.8.2
thanks for your advice in advance
clark
EDIT:
The tricky thing is that I can manually compile the sample peopledetect.cpp file (which also use HOGDescriptor) using,
g++ -o test peopledetect.cpp -lopencv_objdetect -lopencv_core -lopencv_highgui -lopencv_imgproc
or simply
g++ -o test peopledetect.cpp pkg-config opencv --cflags --libs
but why ROS can't compile the package with the similar function call?
PS: Some further info on my pc,
pkg-config --cflags --libs opencv
-I/opt/ros/fuerte/include/opencv -I/opt/ros/fuerte/include -L/opt/ros/fuerte/lib -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_ts -lopencv_video -lopencv_videostab
Any further suggestions are welcome.
EDIT 2:
My mistake! I originally wanted to decleare hog as a global variable but put not only its declaration but also the function call
hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector())
right after the #include (s)... and it is this silly mistake that caused the compile error.
Anyway, thank Kevin again for the help.
clark