肺炎期间的科研实验之--0301 词袋模型DBoW3跳坑!!!!

#include "DBoW3/DBoW3.h" //使用了BOW这个库
#include
#include
#include
#include
#include
#include

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
    // read the image
    cout<<"reading images... "<     vector images;
    for ( int i=0; i<10; i++ )//这里选取了10张图片
    {
        string path = "/home/hansry/Slam_Book/src/Feature_traning/data/"+to_string(i+1)+".png";
        images.push_back( imread(path) );
    }
    // detect ORB features
    cout<<"detecting ORB features ... "<    Ptr< Feature2D > detector = ORB::create("FAST");//由于这里用的是opencv2,所以略有不同
    vector descriptors; 
    for ( Mat& image:images )
    {
        vector keypoints;
        Mat descriptor;
        ORB orb;
        orb( image, Mat(), keypoints, descriptor );

        descriptors.push_back( descriptor );
    }

    // create vocabulary
    cout<<"creating vocabulary ... "<     DBoW3::Vocabulary vocab;
    vocab.create( descriptors );
    cout<<"vocabulary info: "<     vocab.save( "vocabulary.yml.gz" );
    cout<<"done"<

    return 0;
}

cmake_minimum_required(VERSION 2.8.3)
project(Feature_traning)

set(CMAKE_CXX_FLAGS "-std=c++11 -O3")
find_package(OpenCV  REQUIRED ) //这里有点不同,把原版的cmakelist代码里的opencv 3.1改为 2.4(我用的2.4,高博用的3.1.。。。)
set( DBoW3_INCLUDE_DIRS "/usr/local/include" )
set( DBoW3_LIBS "/usr/local/lib/libDBoW3.so" ) //这里,还有个问题,就是在编译DBoW库的时候,cmake ..后需要“sudo make install”   切记!!!
catkin_package(
#  INCLUDE_DIRS include
#  LIBRARIES test
#  CATKIN_DEPENDS opencv roscpp
#  DEPENDS system_lib
)

include_directories(include)
include_directories(
  ${catkin_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
)
add_executable(Feature_traning src/Feature_traning.cpp)

target_link_libraries(Feature_traning
  ${catkin_LIBRARIES}
  ${OpenCV_LIBRARIES}
   ${DBoW3_LIBS}
)

多说一句,建议换用原版cmakelist  这个感觉是网友自己写的额#、#

其余的就没啥了。无错误,流下感动热泪!

附上我遇到的坑

1.

肺炎期间的科研实验之--0301 词袋模型DBoW3跳坑!!!!_第1张图片

2.

肺炎期间的科研实验之--0301 词袋模型DBoW3跳坑!!!!_第2张图片

3.

肺炎期间的科研实验之--0301 词袋模型DBoW3跳坑!!!!_第3张图片

然后,新世界 ...

肺炎期间的科研实验之--0301 词袋模型DBoW3跳坑!!!!_第4张图片

就是接么豪横  接么局气!

你可能感兴趣的:(SLAM笔记,ROS,机器学习,自动驾驶)