问题:ros工程中添加头文件 #include"opencv2/gpu/gpu.hpp" ,catkin_make失败:
报错:[ 14%] Built target segnet_lib
[ 21%] Building CXX object pa_stitching/CMakeFiles/pa_stitching_node.dir/src/main.cpp.o
[ 78%] Built target densecrf
[ 92%] Built target stitching_node
In file included from /home/wds/catkin_ws/src/pa_stitching/include/Configure.h:12:0,
from /home/wds/catkin_ws/src/pa_stitching/src/main.cpp:2:
/usr/local/include/opencv2/gpu/gpu.hpp:432:29: error: ‘vector’ does not name a type
CV_EXPORTS void merge(const vector<GpuMat>& src, GpuMat& dst, Stream& stream =
^
/usr/local/include/opencv2/gpu/gpu.hpp:432:35: error: expected ‘,’ or ‘...’ before ‘<’ token
CV_EXPORTS void merge(const vector<GpuMat>& src, GpuMat& dst, Stream& stream =
^
/usr/local/include/opencv2/gpu/gpu.hpp:438:42: error: ‘vector’ has not been declared
CV_EXPORTS void split(const GpuMat& src, vector<GpuMat>& dst, Stream& stream =
^
/usr/local/include/opencv2/gpu/gpu.hpp:438:48: error: expected ‘,’ or ‘...’ before ‘<’ token
CV_EXPORTS void split(const GpuMat& src, vector<GpuMat>& dst, Stream& stream =
^
/usr/local/include/opencv2/gpu/gpu.hpp:1265:4: error: ‘vector’ does not name a type
vector<Point> locations;
^
/usr/local/include/opencv2/gpu/gpu.hpp:1266:4: error: ‘vector’ does not name a type
vector<double> confidences;
^
/usr/local/include/opencv2/gpu/gpu.hpp:1267:4: error: ‘vector’ does not name a type
vector<double> part_scores[4];
^
/usr/local/include/opencv2/gpu/gpu.hpp:1285:31: error: ‘vector’ does not name a type
void setSVMDetector(const vector<float>& detector);
^
/usr/local/include/opencv2/gpu/gpu.hpp:1285:37: error: expected ‘,’ or ‘...’ before ‘<’ token
void setSVMDetector(const vector<float>& detector);
^
/usr/local/include/opencv2/gpu/gpu.hpp:1287:12: error: ‘vector’ does not name a type
static vector<float> getDefaultPeopleDetector();
^
/usr/local/include/opencv2/gpu/gpu.hpp:1288:12: error: ‘vector’ does not name a type
static vector<float> getPeopleDetector48x96();
^
/usr/local/include/opencv2/gpu/gpu.hpp:1289:12: error: ‘vector’ does not name a type
static vector<float> getPeopleDetector64x128();
^
/usr/local/include/opencv2/gpu/gpu.hpp:1291:36: error: ‘vector’ has not been declared
void detect(const GpuMat& img, vector<Point>& found_locations,
^
/usr/local/include/opencv2/gpu/gpu.hpp:1291:42: error: expected ‘,’ or ‘...’ before ‘<’ token
void detect(const GpuMat& img, vector<Point>& found_locations,
^
/usr/local/include/opencv2/gpu/gpu.hpp:1295:46: error: ‘vector’ has not been declared
void detectMultiScale(const GpuMat& img, vector<Rect>& found_locations,
^
/usr/local/include/opencv2/gpu/gpu.hpp:1295:52: error: expected ‘,’ or ‘...’ before ‘<’ token
void detectMultiScale(const GpuMat& img, vector<Rect>& found_locations,
^
/usr/local/include/opencv2/gpu/gpu.hpp:1300:47: error: ‘vector’ has not been declared
void computeConfidence(const GpuMat& img, vector<Point>& hits, double hit_t
^
/usr/local/include/opencv2/gpu/gpu.hpp:1300:53: error: expected ‘,’ or ‘...’ before ‘<’ token
void computeConfidence(const GpuMat& img, vector<Point>& hits, double hit_t
^
/usr/local/include/opencv2/gpu/gpu.hpp:1303:57: error: ‘vector’ has not been declared
void computeConfidenceMultiScale(const GpuMat& img, vector<Rect>& found_loc
^
/usr/local/include/opencv2/gpu/gpu.hpp:1303:63: error: expected ‘,’ or ‘...’ before ‘<’ token
void computeConfidenceMultiScale(const GpuMat& img, vector<Rect>& found_loc
^
/usr/local/include/opencv2/gpu/gpu.hpp:1835:5: error: ‘vector’ does not name a type
vector<GpuMat> prevPyr_;
^
/usr/local/include/opencv2/gpu/gpu.hpp:1836:5: error: ‘vector’ does not name a type
vector<GpuMat> nextPyr_;
^
/usr/local/include/opencv2/gpu/gpu.hpp:1838:5: error: ‘vector’ does not name a type
vector<GpuMat> buf_;
^
/usr/local/include/opencv2/gpu/gpu.hpp:1839:5: error: ‘vector’ does not name a type
vector<GpuMat> unused;
^
pa_stitching/CMakeFiles/pa_stitching_node.dir/build.make:62: recipe for target 'pa_stitching/CMakeFiles/pa_stitching_node.dir/src/main.cpp.o' failed
make[2]: *** [pa_stitching/CMakeFiles/pa_stitching_node.dir/src/main.cpp.o] Error 1
CMakeFiles/Makefile2:353: recipe for target 'pa_stitching/CMakeFiles/pa_stitching_node.dir/all' failed
make[1]: *** [pa_stitching/CMakeFiles/pa_stitching_node.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j8 -l8" failed
解决方法:在#include"opencv2/gpu/gpu.hpp"上加入using namespace std;即可