1. 程式人生 > >機器人視覺專案:視覺檢測識別+機器人跟隨(4)

機器人視覺專案:視覺檢測識別+機器人跟隨(4)

1. 將手動畫框給小強機器人行人跟蹤的程式碼用opencv行人檢測的demo替換,實現自動檢測。在網上下載了一個XML訓練模型,並修改了程式碼, 在catkin_make這個工作空間時出現問題,一直報錯: [email protected]:~/catkin_tra $ catkin_make Base path: /home/xiaoqiang/catkin_tra Source space: /home/xiaoqiang/catkin_tra/src Build space: /home/xiaoqiang/catkin_tra/build Devel space: /home/xiaoqiang/catkin_tra/devel Install space: /home/xiaoqiang/catkin_tra/install #### #### Running command: "make cmake_check_build_system" in "/home/xiaoqiang/catkin_tra/build" #### #### #### Running command: "make -j4 -l4" in "/home/xiaoqiang/catkin_tra/build" #### [ 25%] Building CXX object track_pkg_new/CMakeFiles/kcf_node.dir/src/runtracker.cpp.o In file included from /opt/ros/kinetic/include/ros/ros.h:40:0,                  from /home/xiaoqiang/catkin_tra/src/track_pkg_new/src/runtracker.cpp:13: /opt/ros/kinetic/include/ros/console.h:158:82: warning: extra ‘;’ [-Wpedantic]      const char* function, const char* fmt, ...) ROSCONSOLE_PRINTF_ATTRIBUTE(7, 8);                                                                                   ^ /home/xiaoqiang/catkin_tra/src/track_pkg_new/src/runtracker.cpp:191:27: error: expected class-name before ‘{’ token  class MySVM : public CvSVM{                            ^ /home/xiaoqiang/catkin_tra/src/track_pkg_new/src/runtracker.cpp: In member function ‘double* MySVM::get_alpha_vector()’: /home/xiaoqiang/catkin_tra/src/track_pkg_new/src/runtracker.cpp:200:22: error: ‘class MySVM’ has no member named ‘decision_func’          return this->decision_func->alpha;                       ^ /home/xiaoqiang/catkin_tra/src/track_pkg_new/src/runtracker.cpp: In member function ‘float MySVM::get_rho()’: /home/xiaoqiang/catkin_tra/src/track_pkg_new/src/runtracker.cpp:211:22: error: ‘class MySVM’ has no member named ‘decision_func’          return this->decision_func->rho;                       ^ /home/xiaoqiang/catkin_tra/src/track_pkg_new/src/runtracker.cpp: In member function ‘void ImageConverter::preparePeopleDetect()’: /home/xiaoqiang/catkin_tra/src/track_pkg_new/src/runtracker.cpp:392:13: error: ‘class MySVM’ has no member named ‘load’          svm.load(path.c_str());              ^ /home/xiaoqiang/catkin_tra/src/track_pkg_new/src/runtracker.cpp:394:29: error: ‘class MySVM’ has no member named ‘get_var_count’          DescriptorDim = svm.get_var_count();                              ^ /home/xiaoqiang/catkin_tra/src/track_pkg_new/src/runtracker.cpp:396:36: error: ‘class MySVM’ has no member named ‘get_support_vector_count’          int supportVectorNum = svm.get_support_vector_count();                                     ^ /home/xiaoqiang/catkin_tra/src/track_pkg_new/src/runtracker.cpp:416:41: error: ‘class MySVM’ has no member named ‘get_support_vector’              const float * pSVData = svm.get_support_vector(i);                                          ^ /home/xiaoqiang/catkin_tra/src/track_pkg_new/src/runtracker.cpp:476:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]          for(int i=0; i<myDetector.size(); i++)                        ^ /home/xiaoqiang/catkin_tra/src/track_pkg_new/src/runtracker.cpp: In member function ‘void ImageConverter::peopleDetect()’: /home/xiaoqiang/catkin_tra/src/track_pkg_new/src/runtracker.cpp:512:45: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::vector<cv::Rect_<int> >::size_type {aka long unsigned int}’ [-Wformat=]          printf("found.size==%d",found.size());                                              ^ track_pkg_new/CMakeFiles/kcf_node.dir/build.make:110: recipe for target 'track_pkg_new/CMakeFiles/kcf_node.dir/src/runtracker.cpp.o' failed make[2]: *** [track_pkg_new/CMakeFiles/kcf_node.dir/src/runtracker.cpp.o] Error 1 CMakeFiles/Makefile2:437: recipe for target 'track_pkg_new/CMakeFiles/kcf_node.dir/all' failed make[1]: *** [track_pkg_new/CMakeFiles/kcf_node.dir/all] Error 2 Makefile:138: recipe for target 'all' failed make: *** [all] Error 2

分析原因主要是提示找不到MySVM類,MySVM類是繼承於CvSVM類,這個類是opencv中的一個庫中的類: C++: CvSVM::CvSVM(const Mat& trainData, const Mat& responses, const Mat& varIdx=Mat(), const Mat& sampleIdx=Mat(), CvSVMParams params=CvSVMParams() )

在小強機器人主機中查詢opencv,只有opencv最常用的幾個包在,很多opencv包都沒有找到,猜想需要將opencv在小強主機中下載編譯安裝,看是否可以catkin_make成功

修改的程式碼和網上付費下載的預訓練模型同時傳上來。