C++常用库

 

获取文件名和去掉后缀的文件名

std::string path = relocal_frame.img_path_.substr(relocal_frame.img_path_.find_last_of("/") + 1);
std::string name = path.substr(0, path.find_last_of(".")); //图片名称
std::cout<<"path:"<<path<<" name: "<<name<<std::endl;

 

 

#include <chrono>
    /// nanoseconds
    typedef duration<_GLIBCXX_CHRONO_INT64_T, nano>         nanoseconds;

    /// microseconds
    typedef duration<_GLIBCXX_CHRONO_INT64_T, micro>         microseconds;

    /// milliseconds
    typedef duration<_GLIBCXX_CHRONO_INT64_T, milli>         milliseconds;

    /// seconds
    typedef duration<_GLIBCXX_CHRONO_INT64_T>             seconds;

    /// minutes
    typedef duration<_GLIBCXX_CHRONO_INT64_T, ratio< 60>>   minutes;

    /// hours
    typedef duration<_GLIBCXX_CHRONO_INT64_T, ratio<3600>>  hours;

计时

const auto tp_1 = std::chrono::steady_clock::now();
matcher->match(desc_1, desc_2, matches);
const auto tp_2 = std::chrono::steady_clock::now();

const auto track_time = std::chrono::duration_cast<std::chrono::milliseconds>(tp_2 - tp_1).count();
td::cout<<"match_time: "<<track_time<<"ms" <<std::endl;

 

 

 

posted @ 2021-05-11 22:14  小小灰迪  阅读(115)  评论(0编辑  收藏  举报