流程框图

StereoRealTime.cc

#include<iostream>
#include<algorithm>
#include<fstream>
#include<iomanip>
#include<chrono>
#include<opencv2/opencv.hpp>

#include "../include/System.h"
#include "./include/StereoCamera.hpp"



int main(int argc, char **argv){
    if(argc != 2){
        std::cout<<"Usage ./stereo_realtime <numberOfcamera>" <<std::endl;
        return -1;
    }

    // Create SLAM system. It initializes all system threads and gets ready to process frames.
    ORB_SLAM2::System SLAM("../Vocabulary/ORBvoc.txt","./config.yaml",ORB_SLAM2::System::STEREO,true);

    cout << endl << "-------" << endl;
    cout << "Start processing sequence ..." << endl;

    StereoCamera sc(3);
    sc.getFramStart();

    double framTpInterval;    // ms time between two fram;
    std::chrono::system_clock::time_point initialTp = sc.firstTp();

    int counter = 3000;

    while (counter--)
    {
        std::pair<cv::Mat, cv::Mat> farms = sc.firstFrams();
        auto framsTp = sc.firstTp();

        framTpInterval = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - framsTp).count();
        
        double framTpSecendFromBegin = std::chrono::duration_cast<std::chrono::microseconds>(framsTp - initialTp).count()/1e6;
        
        std::cout<< "Fram Interval: " <<framTpInterval<<std::endl 
            << "Time passed from begein: " << framTpSecendFromBegin <<std::endl
            << "----------------" <<std::endl;
        
        if (framTpInterval > TimeoutThreshold)
            std::cout<< framTpInterval <<" 延迟!丢弃帧!"<<std::endl;
        else
            // Pass the images to the SLAM system
            SLAM.TrackStereo(farms.first,farms.second,framTpSecendFromBegin);
        
        sc.pop();

    }

    std::cout<<"程序正常退出!"<<std::endl;
    SLAM.Shutdown();
    
	


}

山和山不相遇,人与人要相逢