Segnet Slam 代码学习

运行reading_frame

这里写图片描述
由于/src文件夹下的源码被编译成lib

add_library( rgbd_tutor_lib SHARED    
    rgbdframe.cpp parameter_reader.cpp orb.cpp pnp.cpp track.cpp looper.cpp pose_graph.cpp 
    mapper.cpp stereo.cpp segnet.cpp 
    quadmatcher.cpp vo.cpp vo_stereo.cpp matrix_.cpp
)

所以每次修改代码都会容易重新编译比较繁琐;
首先:ParameterReader para; 会进入parameter_reader.h

namespace rgbd_tutor
{
struct CAMERA_INTRINSIC_PARAMETERS;
class ParameterReader
{
public:
    ParameterReader( string filename="../parameters.txt" )
    {
        ifstream fin( filename.c_str() );
        //....此处打开parameters.txt文档,部分代码已省略....//
        while(!fin.eof())
        {
            cerr<<"打开parameter.txt文件"<<endl;
            string str;
            getline( fin, str );
            if (str[0] == '#')
            {// 以‘#’开头的是注释
                continue;
            }
            int pos = str.find('#');
            if (pos != -1)
            {//从井号到末尾的都是注释
                str = str.substr(0, pos);
            }
            pos = str.find("=");
            if (pos == -1)
                continue;
            string key = str.substr( 0, pos );
            string value = str.substr( pos+1, str.length() );
            data[key] = value;

            if ( !fin.good() )
                break;
        }
    }

    template< class T >
    T getData( const string& key ) const
    {
        auto iter = data.find(key);
        if (iter == data.end())
        {
            cerr<<"Parameter name "<<key<<" not found!"<<endl;
        }
        return boost::lexical_cast<T>( iter->second );
    }

    rgbd_tutor::CAMERA_INTRINSIC_PARAMETERS getCamera() const;

public:
    map<string, string> data;
    /*此处的map是一个C++中的标准容器*/
};

};
//此处是GDB调试窗口演示变量 
this = {rgbd_tutor::ParameterReader * const | 0x7fffffffe100} 0x7fffffffe100
 data = {std::map<std::basic_string, std::basic_string, std::less, std::allocator>} 
  [0] = {std::pair<const std::basic_string, std::basic_string>} 
   first = {const std::basic_string<char, std::char_traits, std::allocator>} "camera.baseline"
   second = {std::basic_string<char, std::char_traits, std::allocator>} "0.537904488"
  [1] = {std::pair<const std::basic_string, std::basic_string>} 
   first = {const std::basic_string<char, std::char_traits, std::allocator>} "camera.cx"
   second = {std::basic_string<char, std::char_traits, std::allocator>} "601.8873"

C++语法熟记

菜鸟教程:C++ 类构造函数 & 析构函数
c++中冒号(:)、双冒号(::)、初始化列表详解
C++中的STL中map用法详解
C++多线程-第三篇-Thread(线程)
C++使用thread类多线程编程
C++中的类和对象(一)

/*此处是Line.h头文件*/
#ifndef LINE_H
#define LINE_H
#include <iostream>
using namespace std;
namespace mu_line
{
    class Line
    {
    public:
        int len;
        int length;
        int getlength(void);
        void setlen(int th);
        int getlen(void);
        Line();
    };
    Line::Line():length(999)
    {
        cerr<<"类的构造函数是:\nLine::Line():length(999)\n冒号初始化列表"<<endl;
    }
    void Line::setlen(int th)
    {
        len = th;
    }
    int Line::getlength()
    {
        return length;
    }
    int Line::getlen(void)
    {
        return len;
    }
};
/*此处是main.c*/
#include <iostream>
//#include <Line.h> 引用编译器的类库路径里面的头文件
#include "Line.h" //引用程序目录的相对路径中的头文件
using namespace mu_line;
int main()
{
    Line line;
    line.setlen(6);
    cerr<<"长度是:line.getlen()\n"<<line.getlen()<<endl;
    cerr<<"长度length是:\n"<<line.getlength()<<endl;
    return 0;
}
/* Run 运行结果
类的构造函数是:
Line::Line():length(999)
冒号初始化列表
长度是:line.getlen()
6
长度length是:
999
*/
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值