run_vo.cpp
// -------------- test the visual odometry -------------
#include <fstream>
#include <boost/timer.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/viz.hpp>
#include "myslam/config.h"
#include "myslam/visual_odometry.h"
int main ( int argc, char** argv )
{
//terminal运行时需要添加参数文件命令行,这里加一步判断
if ( argc != 2 )
{
cout<<"usage: run_vo parameter_file"<<endl;
return 1;
}
//链接参数文件
myslam::Config::setParameterFile ( argv[1] );
//构造VO,类型就是在VisualOdometry类中定义的指向自身类型的指针,然后用New开辟内存
myslam::VisualOdometry::Ptr vo ( new myslam::VisualOdometry );
//读取数据文件夹地址
string dataset_dir = myslam::Config::get<string> ( "dataset_dir" );
cout<<"dataset: "<<dataset_dir<<endl;
//读取数据文件夹中的associate.txt文件
ifstream fin ( dataset_dir+"/associate.txt" );
//防呆,没读取成功的话输出错误
if ( !fin )
{
cout<<"please generate the associate file called associate.txt!"