[已解决]Aborted at 1614944422 (unix time) try “date -d @1614944422“ if you are using GNU date ***

记录一次奇怪的错误
报错部分代码

void readFile(std::string path, std::vector<cv::Point2d>& points){//载入二维点
    std::cout<<"point.size(): "<<points.size()<<std::endl;
    ifstream in(path);
    string line;
    while (getline(in, line)) { //按行处理
        stringstream ss(line);
        string token;
        cv::Point2d pt;
        vector<string> tmp;
        while (ss >> token){ //处理行中每一个小节
            tmp.push_back(token);
        }
        pt.x = stoi(tmp[1].c_str());
        pt.y = stoi(tmp[2].c_str());
        std::cout<<"给出的二维坐标为: "<< pt.x <<" "<< pt.y <<std::endl;
        points.push_back(pt);
    }
    
    std::cout<<"point.size(): "<<points.size()<<std::endl;
    std::cout<<"point: "<<points[0]<<" "<<points[1]<<std::endl;
    std::cout<<"point: "<<points[0].x<<" "<<points[0].y<<std::endl;
    std::cout<<"point: "<<points[1].x<<" "<<points[1].y<<std::endl;
    in.close();
}

输出

point.size():0
给出的二维坐标为: 100 100
给出的二维坐标为: 200 200
给出的二维坐标为: 300 300
*** Aborted at 1614944422 (unix time) try "date -d @1614944422" if you are using GNU date ***
PC: @     0x7f51eefab39c readFile()
*** SIGSEGV (@0x20) received by PID 27632 (TID 0x7f51ef347880) from PID 32; stack trace: ***
    @     0x7f51ee6cf390 (unknown)
    @     0x7f51eefab39c readFile()
    @     0x7f51eef90ba4 pangolin_viewer::viewer::judgeTri_SaveResult()
    @     0x7f51eef95489 pangolin_viewer::viewer::draw_landmarks()
    @     0x7f51eef9611a pangolin_viewer::viewer::run()
    @           0x41d3f7 mono_localization()
    @           0x41b674 main
    @     0x7f51ebefd840 __libc_start_main
    @           0x41c049 _start
    @                0x0 (unknown)
Segmentation fault (core dumped)

问题原因:
该函数读取的txt文档内容多啦一行空格

1   100   100
2   200   200
3   300   300//删除下一行空格后,问题解决
 //原本这里多了一行空格导致出错
上一篇:pdf.js插件的使用


下一篇:IsoAlgo3d - Pipeline WebGL 3d viewer