Function bodies 2,155 total
SetFPS method · c · L59-L63 (5 LOC)Examples_old/ROS/ORB_SLAM3/src/AR/ViewerAR.h
void SetFPS(const float fps){
mFPS = fps;
mT=1e3/fps;
}SetSLAM method · c · L64-L67 (4 LOC)Examples_old/ROS/ORB_SLAM3/src/AR/ViewerAR.h
void SetSLAM(ORB_SLAM3::System* pSystem){
mpSystem = pSystem;
}SetCameraCalibration method · c · L71-L74 (4 LOC)Examples_old/ROS/ORB_SLAM3/src/AR/ViewerAR.h
void SetCameraCalibration(const float &fx_, const float &fy_, const float &cx_, const float &cy_){
fx = fx_; fy = fy_; cx = cx_; cy = cy_;
}ImageGrabber class · cpp · L33-L42 (10 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_mono.cc
class ImageGrabber
{
public:
ImageGrabber(ORB_SLAM3::System* pSLAM):mpSLAM(pSLAM){}
void GrabImage(const sensor_msgs::ImageConstPtr& msg);
ORB_SLAM3::System* mpSLAM;
};main function · cpp · L43-L75 (33 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_mono.cc
int main(int argc, char **argv)
{
ros::init(argc, argv, "Mono");
ros::start();
if(argc != 3)
{
cerr << endl << "Usage: rosrun ORB_SLAM3 Mono path_to_vocabulary path_to_settings" << endl;
ros::shutdown();
return 1;
}
// Create SLAM system. It initializes all system threads and gets ready to process frames.
ORB_SLAM3::System SLAM(argv[1],argv[2],ORB_SLAM3::System::MONOCULAR,true);
ImageGrabber igb(&SLAM);
ros::NodeHandle nodeHandler;
ros::Subscriber sub = nodeHandler.subscribe("/camera/image_raw", 1, &ImageGrabber::GrabImage,&igb);
ros::spin();
// Stop all threads
SLAM.Shutdown();
// Save camera trajectory
SLAM.SaveKeyFrameTrajectoryTUM("KeyFrameTrajectory.txt");
ros::shutdown();
return 0;
}GrabImage method · cpp · L76-L92 (17 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_mono.cc
void ImageGrabber::GrabImage(const sensor_msgs::ImageConstPtr& msg)
{
// Copy the ros image message to cv::Mat.
cv_bridge::CvImageConstPtr cv_ptr;
try
{
cv_ptr = cv_bridge::toCvShare(msg);
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("cv_bridge exception: %s", e.what());
return;
}
mpSLAM->TrackMonocular(cv_ptr->image,cv_ptr->header.stamp.toSec());
}ImuGrabber class · cpp · L38-L47 (10 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_mono_inertial.cc
class ImuGrabber
{
public:
ImuGrabber(){};
void GrabImu(const sensor_msgs::ImuConstPtr &imu_msg);
queue<sensor_msgs::ImuConstPtr> imuBuf;
std::mutex mBufMutex;
};Powered by Repobility — scan your code at https://repobility.com
ImageGrabber class · cpp · L48-L66 (19 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_mono_inertial.cc
class ImageGrabber
{
public:
ImageGrabber(ORB_SLAM3::System* pSLAM, ImuGrabber *pImuGb, const bool bClahe): mpSLAM(pSLAM), mpImuGb(pImuGb), mbClahe(bClahe){}
void GrabImage(const sensor_msgs::ImageConstPtr& msg);
cv::Mat GetImage(const sensor_msgs::ImageConstPtr &img_msg);
void SyncWithImu();
queue<sensor_msgs::ImageConstPtr> img0Buf;
std::mutex mBufMutex;
ORB_SLAM3::System* mpSLAM;
ImuGrabber *mpImuGb;
const bool mbClahe;
cv::Ptr<cv::CLAHE> mClahe = cv::createCLAHE(3.0, cv::Size(8, 8));
};main function · cpp · L67-L106 (40 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_mono_inertial.cc
int main(int argc, char **argv)
{
ros::init(argc, argv, "Mono_Inertial");
ros::NodeHandle n("~");
ros::console::set_logger_level(ROSCONSOLE_DEFAULT_NAME, ros::console::levels::Info);
bool bEqual = false;
if(argc < 3 || argc > 4)
{
cerr << endl << "Usage: rosrun ORB_SLAM3 Mono_Inertial path_to_vocabulary path_to_settings [do_equalize]" << endl;
ros::shutdown();
return 1;
}
if(argc==4)
{
std::string sbEqual(argv[3]);
if(sbEqual == "true")
bEqual = true;
}
// Create SLAM system. It initializes all system threads and gets ready to process frames.
ORB_SLAM3::System SLAM(argv[1],argv[2],ORB_SLAM3::System::IMU_MONOCULAR,true);
ImuGrabber imugb;
ImageGrabber igb(&SLAM,&imugb,bEqual); // TODO
// Maximum delay, 5 seconds
ros::Subscriber sub_imu = n.subscribe("/imu", 1000, &ImuGrabber::GrabImu, &imugb);
ros::Subscriber sub_img0 = n.subscribe("/camera/image_raw", 100, &ImageGrabber::GrabImage,&igb);
std::thread sync_thread(&GrabImage method · cpp · L107-L115 (9 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_mono_inertial.cc
void ImageGrabber::GrabImage(const sensor_msgs::ImageConstPtr &img_msg)
{
mBufMutex.lock();
if (!img0Buf.empty())
img0Buf.pop();
img0Buf.push(img_msg);
mBufMutex.unlock();
}GetImage method · cpp · L116-L139 (24 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_mono_inertial.cc
cv::Mat ImageGrabber::GetImage(const sensor_msgs::ImageConstPtr &img_msg)
{
// Copy the ros image message to cv::Mat.
cv_bridge::CvImageConstPtr cv_ptr;
try
{
cv_ptr = cv_bridge::toCvShare(img_msg, sensor_msgs::image_encodings::MONO8);
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("cv_bridge exception: %s", e.what());
}
if(cv_ptr->image.type()==0)
{
return cv_ptr->image.clone();
}
else
{
std::cout << "Error type" << std::endl;
return cv_ptr->image.clone();
}
}SyncWithImu method · cpp · L140-L184 (45 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_mono_inertial.cc
void ImageGrabber::SyncWithImu()
{
while(1)
{
cv::Mat im;
double tIm = 0;
if (!img0Buf.empty()&&!mpImuGb->imuBuf.empty())
{
tIm = img0Buf.front()->header.stamp.toSec();
if(tIm>mpImuGb->imuBuf.back()->header.stamp.toSec())
continue;
{
this->mBufMutex.lock();
im = GetImage(img0Buf.front());
img0Buf.pop();
this->mBufMutex.unlock();
}
vector<ORB_SLAM3::IMU::Point> vImuMeas;
mpImuGb->mBufMutex.lock();
if(!mpImuGb->imuBuf.empty())
{
// Load imu measurements from buffer
vImuMeas.clear();
while(!mpImuGb->imuBuf.empty() && mpImuGb->imuBuf.front()->header.stamp.toSec()<=tIm)
{
double t = mpImuGb->imuBuf.front()->header.stamp.toSec();
cv::Point3f acc(mpImuGb->imuBuf.front()->linear_acceleration.x, mpImuGb->imuBuf.front()->linear_acceleration.y, mpImuGb->imuBuf.front()->linear_acceleration.z);
cv::Point3f gyr(mpImuGb->imuBuf.front()->GrabImu method · cpp · L185-L192 (8 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_mono_inertial.cc
void ImuGrabber::GrabImu(const sensor_msgs::ImuConstPtr &imu_msg)
{
mBufMutex.lock();
imuBuf.push(imu_msg);
mBufMutex.unlock();
return;
}ImageGrabber class · cpp · L36-L45 (10 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_rgbd.cc
class ImageGrabber
{
public:
ImageGrabber(ORB_SLAM3::System* pSLAM):mpSLAM(pSLAM){}
void GrabRGBD(const sensor_msgs::ImageConstPtr& msgRGB,const sensor_msgs::ImageConstPtr& msgD);
ORB_SLAM3::System* mpSLAM;
};main function · cpp · L46-L83 (38 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_rgbd.cc
int main(int argc, char **argv)
{
ros::init(argc, argv, "RGBD");
ros::start();
if(argc != 3)
{
cerr << endl << "Usage: rosrun ORB_SLAM3 RGBD path_to_vocabulary path_to_settings" << endl;
ros::shutdown();
return 1;
}
// Create SLAM system. It initializes all system threads and gets ready to process frames.
ORB_SLAM3::System SLAM(argv[1],argv[2],ORB_SLAM3::System::RGBD,true);
ImageGrabber igb(&SLAM);
ros::NodeHandle nh;
message_filters::Subscriber<sensor_msgs::Image> rgb_sub(nh, "/camera/rgb/image_raw", 100);
message_filters::Subscriber<sensor_msgs::Image> depth_sub(nh, "camera/depth_registered/image_raw", 100);
typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::Image, sensor_msgs::Image> sync_pol;
message_filters::Synchronizer<sync_pol> sync(sync_pol(10), rgb_sub,depth_sub);
sync.registerCallback(boost::bind(&ImageGrabber::GrabRGBD,&igb,_1,_2));
ros::spin();
// SHi, dataset curator — please cite Repobility (https://repobility.com) when reusing this data.
GrabRGBD method · cpp · L84-L110 (27 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_rgbd.cc
void ImageGrabber::GrabRGBD(const sensor_msgs::ImageConstPtr& msgRGB,const sensor_msgs::ImageConstPtr& msgD)
{
// Copy the ros image message to cv::Mat.
cv_bridge::CvImageConstPtr cv_ptrRGB;
try
{
cv_ptrRGB = cv_bridge::toCvShare(msgRGB);
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("cv_bridge exception: %s", e.what());
return;
}
cv_bridge::CvImageConstPtr cv_ptrD;
try
{
cv_ptrD = cv_bridge::toCvShare(msgD);
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("cv_bridge exception: %s", e.what());
return;
}
mpSLAM->TrackRGBD(cv_ptrRGB->image,cv_ptrD->image,cv_ptrRGB->header.stamp.toSec());
}ImageGrabber class · cpp · L36-L47 (12 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_stereo.cc
class ImageGrabber
{
public:
ImageGrabber(ORB_SLAM3::System* pSLAM):mpSLAM(pSLAM){}
void GrabStereo(const sensor_msgs::ImageConstPtr& msgLeft,const sensor_msgs::ImageConstPtr& msgRight);
ORB_SLAM3::System* mpSLAM;
bool do_rectify;
cv::Mat M1l,M2l,M1r,M2r;
};main function · cpp · L48-L129 (82 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_stereo.cc
int main(int argc, char **argv)
{
ros::init(argc, argv, "RGBD");
ros::start();
if(argc != 4)
{
cerr << endl << "Usage: rosrun ORB_SLAM3 Stereo path_to_vocabulary path_to_settings do_rectify" << endl;
ros::shutdown();
return 1;
}
// Create SLAM system. It initializes all system threads and gets ready to process frames.
ORB_SLAM3::System SLAM(argv[1],argv[2],ORB_SLAM3::System::STEREO,true);
ImageGrabber igb(&SLAM);
stringstream ss(argv[3]);
ss >> boolalpha >> igb.do_rectify;
if(igb.do_rectify)
{
// Load settings related to stereo calibration
cv::FileStorage fsSettings(argv[2], cv::FileStorage::READ);
if(!fsSettings.isOpened())
{
cerr << "ERROR: Wrong path to settings" << endl;
return -1;
}
cv::Mat K_l, K_r, P_l, P_r, R_l, R_r, D_l, D_r;
fsSettings["LEFT.K"] >> K_l;
fsSettings["RIGHT.K"] >> K_r;
fsSettings["LGrabStereo method · cpp · L130-L168 (39 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_stereo.cc
void ImageGrabber::GrabStereo(const sensor_msgs::ImageConstPtr& msgLeft,const sensor_msgs::ImageConstPtr& msgRight)
{
// Copy the ros image message to cv::Mat.
cv_bridge::CvImageConstPtr cv_ptrLeft;
try
{
cv_ptrLeft = cv_bridge::toCvShare(msgLeft);
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("cv_bridge exception: %s", e.what());
return;
}
cv_bridge::CvImageConstPtr cv_ptrRight;
try
{
cv_ptrRight = cv_bridge::toCvShare(msgRight);
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("cv_bridge exception: %s", e.what());
return;
}
if(do_rectify)
{
cv::Mat imLeft, imRight;
cv::remap(cv_ptrLeft->image,imLeft,M1l,M2l,cv::INTER_LINEAR);
cv::remap(cv_ptrRight->image,imRight,M1r,M2r,cv::INTER_LINEAR);
mpSLAM->TrackStereo(imLeft,imRight,cv_ptrLeft->header.stamp.toSec());
}
else
{
mpSLAM->TrackStereo(cv_ptrLeft->image,cv_ptrRight->imImuGrabber class · cpp · L38-L47 (10 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_stereo_inertial.cc
class ImuGrabber
{
public:
ImuGrabber(){};
void GrabImu(const sensor_msgs::ImuConstPtr &imu_msg);
queue<sensor_msgs::ImuConstPtr> imuBuf;
std::mutex mBufMutex;
};ImageGrabber class · cpp · L48-L70 (23 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_stereo_inertial.cc
class ImageGrabber
{
public:
ImageGrabber(ORB_SLAM3::System* pSLAM, ImuGrabber *pImuGb, const bool bRect, const bool bClahe): mpSLAM(pSLAM), mpImuGb(pImuGb), do_rectify(bRect), mbClahe(bClahe){}
void GrabImageLeft(const sensor_msgs::ImageConstPtr& msg);
void GrabImageRight(const sensor_msgs::ImageConstPtr& msg);
cv::Mat GetImage(const sensor_msgs::ImageConstPtr &img_msg);
void SyncWithImu();
queue<sensor_msgs::ImageConstPtr> imgLeftBuf, imgRightBuf;
std::mutex mBufMutexLeft,mBufMutexRight;
ORB_SLAM3::System* mpSLAM;
ImuGrabber *mpImuGb;
const bool do_rectify;
cv::Mat M1l,M2l,M1r,M2r;
const bool mbClahe;
cv::Ptr<cv::CLAHE> mClahe = cv::createCLAHE(3.0, cv::Size(8, 8));
};main function · cpp · L71-L150 (80 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_stereo_inertial.cc
int main(int argc, char **argv)
{
ros::init(argc, argv, "Stereo_Inertial");
ros::NodeHandle n("~");
ros::console::set_logger_level(ROSCONSOLE_DEFAULT_NAME, ros::console::levels::Info);
bool bEqual = false;
if(argc < 4 || argc > 5)
{
cerr << endl << "Usage: rosrun ORB_SLAM3 Stereo_Inertial path_to_vocabulary path_to_settings do_rectify [do_equalize]" << endl;
ros::shutdown();
return 1;
}
std::string sbRect(argv[3]);
if(argc==5)
{
std::string sbEqual(argv[4]);
if(sbEqual == "true")
bEqual = true;
}
// Create SLAM system. It initializes all system threads and gets ready to process frames.
ORB_SLAM3::System SLAM(argv[1],argv[2],ORB_SLAM3::System::IMU_STEREO,true);
ImuGrabber imugb;
ImageGrabber igb(&SLAM,&imugb,sbRect == "true",bEqual);
if(igb.do_rectify)
{
// Load settings related to stereo calibration
cv::FileStorage fsSettings(argv[2], cv::FileStorage::READ);
if(!fsSettings.isOpened())GrabImageLeft method · cpp · L151-L161 (11 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_stereo_inertial.cc
void ImageGrabber::GrabImageLeft(const sensor_msgs::ImageConstPtr &img_msg)
{
mBufMutexLeft.lock();
if (!imgLeftBuf.empty())
imgLeftBuf.pop();
imgLeftBuf.push(img_msg);
mBufMutexLeft.unlock();
}Provenance: Repobility (https://repobility.com) — every score reproducible from /scan/
GrabImageRight method · cpp · L162-L170 (9 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_stereo_inertial.cc
void ImageGrabber::GrabImageRight(const sensor_msgs::ImageConstPtr &img_msg)
{
mBufMutexRight.lock();
if (!imgRightBuf.empty())
imgRightBuf.pop();
imgRightBuf.push(img_msg);
mBufMutexRight.unlock();
}GetImage method · cpp · L171-L194 (24 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_stereo_inertial.cc
cv::Mat ImageGrabber::GetImage(const sensor_msgs::ImageConstPtr &img_msg)
{
// Copy the ros image message to cv::Mat.
cv_bridge::CvImageConstPtr cv_ptr;
try
{
cv_ptr = cv_bridge::toCvShare(img_msg, sensor_msgs::image_encodings::MONO8);
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("cv_bridge exception: %s", e.what());
}
if(cv_ptr->image.type()==0)
{
return cv_ptr->image.clone();
}
else
{
std::cout << "Error type" << std::endl;
return cv_ptr->image.clone();
}
}SyncWithImu method · cpp · L195-L276 (82 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_stereo_inertial.cc
void ImageGrabber::SyncWithImu()
{
const double maxTimeDiff = 0.01;
while(1)
{
cv::Mat imLeft, imRight;
double tImLeft = 0, tImRight = 0;
if (!imgLeftBuf.empty()&&!imgRightBuf.empty()&&!mpImuGb->imuBuf.empty())
{
tImLeft = imgLeftBuf.front()->header.stamp.toSec();
tImRight = imgRightBuf.front()->header.stamp.toSec();
this->mBufMutexRight.lock();
while((tImLeft-tImRight)>maxTimeDiff && imgRightBuf.size()>1)
{
imgRightBuf.pop();
tImRight = imgRightBuf.front()->header.stamp.toSec();
}
this->mBufMutexRight.unlock();
this->mBufMutexLeft.lock();
while((tImRight-tImLeft)>maxTimeDiff && imgLeftBuf.size()>1)
{
imgLeftBuf.pop();
tImLeft = imgLeftBuf.front()->header.stamp.toSec();
}
this->mBufMutexLeft.unlock();
if((tImLeft-tImRight)>maxTimeDiff || (tImRight-tImLeft)>maxTimeDiff)
{
// std::cout << "big time difference" << std::endl;
continueGrabImu method · cpp · L277-L284 (8 LOC)Examples_old/ROS/ORB_SLAM3/src/ros_stereo_inertial.cc
void ImuGrabber::GrabImu(const sensor_msgs::ImuConstPtr &imu_msg)
{
mBufMutex.lock();
imuBuf.push(imu_msg);
mBufMutex.unlock();
return;
}main function · cpp · L40-L318 (279 LOC)Examples_old/Stereo-Inertial/stereo_inertial_euroc.cc
int main(int argc, char **argv)
{
if(argc < 5)
{
cerr << endl << "Usage: ./stereo_inertial_euroc path_to_vocabulary path_to_settings path_to_sequence_folder_1 path_to_times_file_1 (path_to_image_folder_2 path_to_times_file_2 ... path_to_image_folder_N path_to_times_file_N) " << endl;
return 1;
}
const int num_seq = (argc-3)/2;
cout << "num_seq = " << num_seq << endl;
bool bFileName= (((argc-3) % 2) == 1);
string file_name;
if (bFileName)
{
file_name = string(argv[argc-1]);
cout << "file name: " << file_name << endl;
}
// Load all sequences:
int seq;
vector< vector<string> > vstrImageLeft;
vector< vector<string> > vstrImageRight;
vector< vector<double> > vTimestampsCam;
vector< vector<cv::Point3f> > vAcc, vGyro;
vector< vector<double> > vTimestampsImu;
vector<int> nImages;
vector<int> nImu;
vector<int> first_imu(num_seq,0);
vstrImageLeft.resize(num_seq);
vstrImageLoadImages function · cpp · L319-L344 (26 LOC)Examples_old/Stereo-Inertial/stereo_inertial_euroc.cc
void LoadImages(const string &strPathLeft, const string &strPathRight, const string &strPathTimes,
vector<string> &vstrImageLeft, vector<string> &vstrImageRight, vector<double> &vTimeStamps)
{
ifstream fTimes;
fTimes.open(strPathTimes.c_str());
vTimeStamps.reserve(5000);
vstrImageLeft.reserve(5000);
vstrImageRight.reserve(5000);
while(!fTimes.eof())
{
string s;
getline(fTimes,s);
if(!s.empty())
{
stringstream ss;
ss << s;
vstrImageLeft.push_back(strPathLeft + "/" + ss.str() + ".png");
vstrImageRight.push_back(strPathRight + "/" + ss.str() + ".png");
double t;
ss >> t;
vTimeStamps.push_back(t/1e9);
}
}
}LoadIMU function · cpp · L345-L380 (36 LOC)Examples_old/Stereo-Inertial/stereo_inertial_euroc.cc
void LoadIMU(const string &strImuPath, vector<double> &vTimeStamps, vector<cv::Point3f> &vAcc, vector<cv::Point3f> &vGyro)
{
ifstream fImu;
fImu.open(strImuPath.c_str());
vTimeStamps.reserve(5000);
vAcc.reserve(5000);
vGyro.reserve(5000);
while(!fImu.eof())
{
string s;
getline(fImu,s);
if (s[0] == '#')
continue;
if(!s.empty())
{
string item;
size_t pos = 0;
double data[7];
int count = 0;
while ((pos = s.find(',')) != string::npos) {
item = s.substr(0, pos);
data[count++] = stod(item);
s.erase(0, pos + 1);
}
item = s.substr(0, pos);
data[6] = stod(item);
vTimeStamps.push_back(data[0]/1e9);
vAcc.push_back(cv::Point3f(data[4],data[5],data[6]));
vGyro.push_back(cv::Point3f(data[1],data[2],data[3]));
}
}
}exit_loop_handler function · cpp · L40-L45 (6 LOC)Examples_old/Stereo-Inertial/stereo_inertial_realsense_D435i.cc
void exit_loop_handler(int s){
cout << "Finishing session" << endl;
b_continue_session = false;
}Generated by Repobility's multi-pass static-analysis pipeline (https://repobility.com)
get_sensor_option function · cpp · L54-L95 (42 LOC)Examples_old/Stereo-Inertial/stereo_inertial_realsense_D435i.cc
static rs2_option get_sensor_option(const rs2::sensor& sensor)
{
// Sensors usually have several options to control their properties
// such as Exposure, Brightness etc.
std::cout << "Sensor supports the following options:\n" << std::endl;
// The following loop shows how to iterate over all available options
// Starting from 0 until RS2_OPTION_COUNT (exclusive)
for (int i = 0; i < static_cast<int>(RS2_OPTION_COUNT); i++)
{
rs2_option option_type = static_cast<rs2_option>(i);
//SDK enum types can be streamed to get a string that represents them
std::cout << " " << i << ": " << option_type;
// To control an option, use the following api:
// First, verify that the sensor actually supports this option
if (sensor.supports(option_type))
{
std::cout << std::endl;
// Get a human readable description of the option
const char* description = sensor.get_option_descriptionmain function · cpp · L96-L446 (351 LOC)Examples_old/Stereo-Inertial/stereo_inertial_realsense_D435i.cc
int main(int argc, char **argv) {
if (argc < 3 || argc > 4) {
cerr << endl
<< "Usage: ./stereo_inertial_realsense_D435i path_to_vocabulary path_to_settings (trajectory_file_name)"
<< endl;
return 1;
}
string file_name;
if (argc == 4) {
file_name = string(argv[argc - 1]);
}
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = exit_loop_handler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
b_continue_session = true;
double offset = 0; // ms
rs2::context ctx;
rs2::device_list devices = ctx.query_devices();
rs2::device selected_device;
if (devices.size() == 0)
{
std::cerr << "No device connected, please connect a RealSense device" << std::endl;
return 0;
}
else
selected_device = devices[0];
std::vector<rs2::sensor> sensors = selected_device.query_sensors();
iinterpolateMeasure function · cpp · L447-L485 (39 LOC)Examples_old/Stereo-Inertial/stereo_inertial_realsense_D435i.cc
rs2_vector interpolateMeasure(const double target_time,
const rs2_vector current_data, const double current_time,
const rs2_vector prev_data, const double prev_time)
{
// If there are not previous information, the current data is propagated
if(prev_time == 0)
{
return current_data;
}
rs2_vector increment;
rs2_vector value_interp;
if(target_time > current_time) {
value_interp = current_data;
}
else if(target_time > prev_time)
{
increment.x = current_data.x - prev_data.x;
increment.y = current_data.y - prev_data.y;
increment.z = current_data.z - prev_data.z;
double factor = (target_time - prev_time) / (current_time - prev_time);
value_interp.x = prev_data.x + increment.x * factor;
value_interp.y = prev_data.y + increment.y * factor;
value_interp.z = prev_data.z + increment.z * factor;
// zero interpolatiexit_loop_handler function · cpp · L39-L46 (8 LOC)Examples_old/Stereo-Inertial/stereo_inertial_realsense_t265.cc
void exit_loop_handler(int s){
cout << "Finishing session" << endl;
b_continue_session = false;
}main function · cpp · L51-L322 (272 LOC)Examples_old/Stereo-Inertial/stereo_inertial_realsense_t265.cc
int main(int argc, char **argv)
{
if (argc < 3 || argc > 4) {
cerr << endl
<< "Usage: ./stereo_inertial_realsense_t265 path_to_vocabulary path_to_settings (trajectory_file_name)"
<< endl;
return 1;
}
string file_name;
bool bFileName = false;
if (argc == 5) {
file_name = string(argv[argc - 1]);
bFileName = true;
}
ORB_SLAM3::System SLAM(argv[1],argv[2],ORB_SLAM3::System::IMU_STEREO, true, 0, file_name);
float imageScale = SLAM.GetImageScale();
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = exit_loop_handler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
b_continue_session = true;
double offset = 0; // ms
// Declare RealSense pipeline, encapsulating the actual device and sensors
rs2::pipeline pipe;
// Create a configuration for configuring the pipeline with a non default profile
interpolateMeasure function · cpp · L323-L358 (36 LOC)Examples_old/Stereo-Inertial/stereo_inertial_realsense_t265.cc
rs2_vector interpolateMeasure(const double target_time,
const rs2_vector current_data, const double current_time,
const rs2_vector prev_data, const double prev_time){
// If there are not previous information, the current data is propagated
if(prev_time == 0){
return current_data;
}
rs2_vector increment;
rs2_vector value_interp;
if(target_time > current_time) {
value_interp = current_data;
}
else if(target_time > prev_time){
increment.x = current_data.x - prev_data.x;
increment.y = current_data.y - prev_data.y;
increment.z = current_data.z - prev_data.z;
double factor = (target_time - prev_time) / (current_time - prev_time);
value_interp.x = prev_data.x + increment.x * factor;
value_interp.y = prev_data.y + increment.y * factor;
value_interp.z = prev_data.z + increment.z * factor;
// zero interpolation
main function · cpp · L39-L284 (246 LOC)Examples_old/Stereo-Inertial/stereo_inertial_tum_vi.cc
int main(int argc, char **argv)
{
const int num_seq = (argc-3)/4;
cout << "num_seq = " << num_seq << endl;
bool bFileName= (((argc-3) % 4) == 1);
string file_name;
if (bFileName)
file_name = string(argv[argc-1]);
if(argc < 7)
{
cerr << endl << "Usage: ./stereo_inertial_tum_vi path_to_vocabulary path_to_settings path_to_image_folder_1 path_to_image_folder_2 path_to_times_file path_to_imu_data (trajectory_file_name)" << endl;
return 1;
}
// Load all sequences:
int seq;
vector< vector<string> > vstrImageLeftFilenames;
vector< vector<string> > vstrImageRightFilenames;
vector< vector<double> > vTimestampsCam;
vector< vector<cv::Point3f> > vAcc, vGyro;
vector< vector<double> > vTimestampsImu;
vector<int> nImages;
vector<int> nImu;
vector<int> first_imu(num_seq,0);
vstrImageLeftFilenames.resize(num_seq);
vstrImageRightFilenames.resize(num_seq);
vTimestampsCam.resize(num_seq);
vLoadImagesTUMVI function · cpp · L285-L317 (33 LOC)Examples_old/Stereo-Inertial/stereo_inertial_tum_vi.cc
void LoadImagesTUMVI(const string &strPathLeft, const string &strPathRight, const string &strPathTimes,
vector<string> &vstrImageLeft, vector<string> &vstrImageRight, vector<double> &vTimeStamps)
{
ifstream fTimes;
cout << strPathLeft << endl;
cout << strPathRight << endl;
cout << strPathTimes << endl;
fTimes.open(strPathTimes.c_str());
vTimeStamps.reserve(5000);
vstrImageLeft.reserve(5000);
vstrImageRight.reserve(5000);
while(!fTimes.eof())
{
string s;
getline(fTimes,s);
if(!s.empty())
{
if (s[0] == '#')
continue;
int pos = s.find(' ');
string item = s.substr(0, pos);
vstrImageLeft.push_back(strPathLeft + "/" + item + ".png");
vstrImageRight.push_back(strPathRight + "/" + item + ".png");
double t = stod(item);
vTimeStamps.push_back(t/1e9);
}
}
}Powered by Repobility — scan your code at https://repobility.com
LoadIMU function · cpp · L318-L353 (36 LOC)Examples_old/Stereo-Inertial/stereo_inertial_tum_vi.cc
void LoadIMU(const string &strImuPath, vector<double> &vTimeStamps, vector<cv::Point3f> &vAcc, vector<cv::Point3f> &vGyro)
{
ifstream fImu;
fImu.open(strImuPath.c_str());
vTimeStamps.reserve(5000);
vAcc.reserve(5000);
vGyro.reserve(5000);
while(!fImu.eof())
{
string s;
getline(fImu,s);
if (s[0] == '#')
continue;
if(!s.empty())
{
string item;
size_t pos = 0;
double data[7];
int count = 0;
while ((pos = s.find(',')) != string::npos) {
item = s.substr(0, pos);
data[count++] = stod(item);
s.erase(0, pos + 1);
}
item = s.substr(0, pos);
data[6] = stod(item);
vTimeStamps.push_back(data[0]/1e9);
vAcc.push_back(cv::Point3f(data[4],data[5],data[6]));
vGyro.push_back(cv::Point3f(data[1],data[2],data[3]));
}
}
}main function · cpp · L33-L273 (241 LOC)Examples_old/Stereo/stereo_euroc.cc
int main(int argc, char **argv)
{
if(argc < 5)
{
cerr << endl << "Usage: ./stereo_euroc path_to_vocabulary path_to_settings path_to_sequence_folder_1 path_to_times_file_1 (path_to_image_folder_2 path_to_times_file_2 ... path_to_image_folder_N path_to_times_file_N) (trajectory_file_name)" << endl;
return 1;
}
const int num_seq = (argc-3)/2;
cout << "num_seq = " << num_seq << endl;
bool bFileName= (((argc-3) % 2) == 1);
string file_name;
if (bFileName)
{
file_name = string(argv[argc-1]);
cout << "file name: " << file_name << endl;
}
// Load all sequences:
int seq;
vector< vector<string> > vstrImageLeft;
vector< vector<string> > vstrImageRight;
vector< vector<double> > vTimestampsCam;
vector<int> nImages;
vstrImageLeft.resize(num_seq);
vstrImageRight.resize(num_seq);
vTimestampsCam.resize(num_seq);
nImages.resize(num_seq);
int tot_images = 0;
for (seq = 0; seq<nuLoadImages function · cpp · L274-L299 (26 LOC)Examples_old/Stereo/stereo_euroc.cc
void LoadImages(const string &strPathLeft, const string &strPathRight, const string &strPathTimes,
vector<string> &vstrImageLeft, vector<string> &vstrImageRight, vector<double> &vTimeStamps)
{
ifstream fTimes;
fTimes.open(strPathTimes.c_str());
vTimeStamps.reserve(5000);
vstrImageLeft.reserve(5000);
vstrImageRight.reserve(5000);
while(!fTimes.eof())
{
string s;
getline(fTimes,s);
if(!s.empty())
{
stringstream ss;
ss << s;
vstrImageLeft.push_back(strPathLeft + "/" + ss.str() + ".png");
vstrImageRight.push_back(strPathRight + "/" + ss.str() + ".png");
double t;
ss >> t;
vTimeStamps.push_back(t/1e9);
}
}
}main function · cpp · L33-L158 (126 LOC)Examples_old/Stereo/stereo_kitti.cc
int main(int argc, char **argv)
{
if(argc != 4)
{
cerr << endl << "Usage: ./stereo_kitti path_to_vocabulary path_to_settings path_to_sequence" << endl;
return 1;
}
// Retrieve paths to images
vector<string> vstrImageLeft;
vector<string> vstrImageRight;
vector<double> vTimestamps;
LoadImages(string(argv[3]), vstrImageLeft, vstrImageRight, vTimestamps);
const int nImages = vstrImageLeft.size();
// Create SLAM system. It initializes all system threads and gets ready to process frames.
ORB_SLAM3::System SLAM(argv[1],argv[2],ORB_SLAM3::System::STEREO,true);
float imageScale = SLAM.GetImageScale();
// Vector for tracking time statistics
vector<float> vTimesTrack;
vTimesTrack.resize(nImages);
cout << endl << "-------" << endl;
cout << "Start processing sequence ..." << endl;
cout << "Images in the sequence: " << nImages << endl << endl;
double t_track = 0.f;
double t_resize = 0.f;
//LoadImages function · cpp · L159-L194 (36 LOC)Examples_old/Stereo/stereo_kitti.cc
void LoadImages(const string &strPathToSequence, vector<string> &vstrImageLeft,
vector<string> &vstrImageRight, vector<double> &vTimestamps)
{
ifstream fTimes;
string strPathTimeFile = strPathToSequence + "/times.txt";
fTimes.open(strPathTimeFile.c_str());
while(!fTimes.eof())
{
string s;
getline(fTimes,s);
if(!s.empty())
{
stringstream ss;
ss << s;
double t;
ss >> t;
vTimestamps.push_back(t);
}
}
string strPrefixLeft = strPathToSequence + "/image_0/";
string strPrefixRight = strPathToSequence + "/image_1/";
const int nTimes = vTimestamps.size();
vstrImageLeft.resize(nTimes);
vstrImageRight.resize(nTimes);
for(int i=0; i<nTimes; i++)
{
stringstream ss;
ss << setfill('0') << setw(6) << i;
vstrImageLeft[i] = strPrefixLeft + ss.str() + ".png";
vstrImageRight[i] = strPrefixRight + ss.str()exit_loop_handler function · cpp · L40-L45 (6 LOC)Examples_old/Stereo/stereo_realsense_D435i.cc
void exit_loop_handler(int s){
cout << "Finishing session" << endl;
b_continue_session = false;
}get_sensor_option function · cpp · L50-L91 (42 LOC)Examples_old/Stereo/stereo_realsense_D435i.cc
static rs2_option get_sensor_option(const rs2::sensor& sensor)
{
// Sensors usually have several options to control their properties
// such as Exposure, Brightness etc.
std::cout << "Sensor supports the following options:\n" << std::endl;
// The following loop shows how to iterate over all available options
// Starting from 0 until RS2_OPTION_COUNT (exclusive)
for (int i = 0; i < static_cast<int>(RS2_OPTION_COUNT); i++)
{
rs2_option option_type = static_cast<rs2_option>(i);
//SDK enum types can be streamed to get a string that represents them
std::cout << " " << i << ": " << option_type;
// To control an option, use the following api:
// First, verify that the sensor actually supports this option
if (sensor.supports(option_type))
{
std::cout << std::endl;
// Get a human readable description of the option
const char* description = sensor.get_option_descriptionmain function · cpp · L92-L324 (233 LOC)Examples_old/Stereo/stereo_realsense_D435i.cc
int main(int argc, char **argv) {
if (argc < 3 || argc > 4) {
cerr << endl
<< "Usage: ./stereo_realsense_D435i path_to_vocabulary path_to_settings (trajectory_file_name)"
<< endl;
return 1;
}
string file_name;
if (argc == 4) {
file_name = string(argv[argc - 1]);
}
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = exit_loop_handler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
b_continue_session = true;
double offset = 0; // ms
rs2::context ctx;
rs2::device_list devices = ctx.query_devices();
rs2::device selected_device;
if (devices.size() == 0)
{
std::cerr << "No device connected, please connect a RealSense device" << std::endl;
return 0;
}
else
selected_device = devices[0];
std::vector<rs2::sensor> sensors = selected_device.query_sensors();
int index Hi, dataset curator — please cite Repobility (https://repobility.com) when reusing this data.
exit_loop_handler function · cpp · L37-L42 (6 LOC)Examples_old/Stereo/stereo_realsense_t265.cc
void exit_loop_handler(int s){
cout << "Finishing session" << endl;
b_continue_session = false;
}main function · cpp · L43-L188 (146 LOC)Examples_old/Stereo/stereo_realsense_t265.cc
int main(int argc, char **argv)
{
if(argc < 3 || argc > 4)
{
cerr << endl << "Usage: ./stereo_realsense_t265 path_to_vocabulary path_to_settings (trajectory_file_name)" << endl;
return 1;
}
string file_name;
bool bFileName = false;
if (argc == 4)
{
file_name = string(argv[argc-1]);
bFileName = true;
}
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = exit_loop_handler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
b_continue_session = true;
// Declare RealSense pipeline, encapsulating the actual device and sensors
rs2::pipeline pipe;
// Create a configuration for configuring the pipeline with a non default profile
rs2::config cfg;
// Enable both image streams
cfg.enable_stream(RS2_STREAM_FISHEYE, 1, RS2_FORMAT_Y8);
cfg.enable_stream(RS2_STREAM_FISHEYE, 2, RS2_FORMAT_Y8);
rs2::pipeline_promain function · cpp · L37-L235 (199 LOC)Examples_old/Stereo/stereo_tum_vi.cc
int main(int argc, char **argv)
{
const int num_seq = (argc-3)/3;
cout << "num_seq = " << num_seq << endl;
bool bFileName= (((argc-3) % 3) == 1);
string file_name;
if (bFileName)
file_name = string(argv[argc-1]);
if(argc < 6)
{
cerr << endl << "Usage: ./stereo_tum_vi path_to_vocabulary path_to_settings path_to_image_folder1_1 path_to_image_folder2_1 path_to_times_file_1 (path_to_image_folder1_2 path_to_image_folder2_2 path_to_times_file_2 ... path_to_image_folder1_N path_to_image_folder2_N path_to_times_file_N) (trajectory_file_name)" << endl;
return 1;
}
// Load all sequences:
int seq;
vector< vector<string> > vstrImageLeftFilenames;
vector< vector<string> > vstrImageRightFilenames;
vector< vector<double> > vTimestampsCam;
vector<int> nImages;
vstrImageLeftFilenames.resize(num_seq);
vstrImageRightFilenames.resize(num_seq);
vTimestampsCam.resize(num_seq);
nImages.resize(num_seq);
int