马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
媒介
设置文件的相干的构造函数
1.函数声明
settings的构造函数- Settings::Settings(const std::string &configFile, const int &sensor)
- : bNeedToUndistort_(false), bNeedToRectify_(false), bNeedToResize1_(false), bNeedToResize2_(false)
复制代码 这个构造函数继续两个参数:
1.configFile:设置文件的路径。
2.sensor:传感器范例。
列表初始化成员变量bNeedToUndistort_、bNeedToRectify_、bNeedToResize1_ 和bNeedToResize2_,它们表现在设置过程中是否须要举行去畸变、校正、缩放等使用。
2.函数界说
1.打开设置文件
- // Open settings file
- cv::FileStorage fSettings(configFile, cv::FileStorage::READ);
- if (!fSettings.isOpened())
- {
- cerr << "[ERROR]: could not open configuration file at: " << configFile << endl;
- cerr << "Aborting..." << endl;
- exit(-1);
- }
- else
- {
- cout << "Loading settings from " << configFile << endl;
- }
复制代码 使用 OpenCV 的 cv::FileStorage 打开传入的设置文件。假如文件打开失败,打印错误信息并停止步调。假如文件乐成打开,输出 "Loading settings from" 设置文件路径。
2.读取相机参数
1.读取相机1参数
调用settings文件中界说的readCamera1函数来提取设置文件中的相机参数。- // Read first camera
- readCamera1(fSettings);
- cout << "\t-Loaded camera 1" << endl;
复制代码 2.读取相机2参数
假如是双目模式则还须要读取第二个相机的参数。- // Read second camera if stereo (not rectified)
- if (sensor_ == System::STEREO || sensor_ == System::IMU_STEREO)
- {
- readCamera2(fSettings);
- cout << "\t-Loaded camera 2" << endl;
- }
复制代码 3.读取图像信息
- // Read first camera
- readCamera1(fSettings);
- cout << "\t-Loaded camera 1" << endl;
复制代码 4.读取IMU参数
假如是imu模式就须要读取相干参数- if (sensor_ == System::IMU_MONOCULAR || sensor_ == System::IMU_STEREO || sensor_ == System::IMU_RGBD)
- {
- readIMU(fSettings);
- cout << "\t-Loaded IMU calibration" << endl;
- }
复制代码 5.读取RGBD参数
假如是RGBD模式就需读取相干参数- if (sensor_ == System::RGBD || sensor_ == System::IMU_RGBD)
- {
- readRGBD(fSettings);
- cout << "\t-Loaded RGB-D calibration" << endl;
- }
复制代码 6.读取设置文件中的别的参数
- readORB(fSettings);
- cout << "\t-Loaded ORB settings" << endl;
- readViewer(fSettings);
- cout << "\t-Loaded viewer settings" << endl;
- readLoadAndSave(fSettings);
- cout << "\t-Loaded Atlas settings" << endl;
- readOtherParameters(fSettings);
- cout << "\t-Loaded misc parameters" << endl;
复制代码 7 .查抄是否须要改正使用
假如须要举行图像的校正(比方,去畸变),调用 precomputeRectificationMaps() 预盘算校正舆图。- if (bNeedToRectify_)
- {
- precomputeRectificationMaps();
- cout << "\t-Computed rectification maps" << endl;
- }
复制代码 完备的代码
- Settings::Settings(const std::string &configFile, const int &sensor)
- : bNeedToUndistort_(false), bNeedToRectify_(false), bNeedToResize1_(false), bNeedToResize2_(false){ sensor_ = sensor;
- // Open settings file
- cv::FileStorage fSettings(configFile, cv::FileStorage::READ);
- if (!fSettings.isOpened())
- {
- cerr << "[ERROR]: could not open configuration file at: " << configFile << endl;
- cerr << "Aborting..." << endl;
- exit(-1);
- }
- else
- {
- cout << "Loading settings from " << configFile << endl;
- }
- // Read first camera
- readCamera1(fSettings);
- cout << "\t-Loaded camera 1" << endl;
- // Read second camera if stereo (not rectified)
- if (sensor_ == System::STEREO || sensor_ == System::IMU_STEREO)
- {
- readCamera2(fSettings);
- cout << "\t-Loaded camera 2" << endl;
- } // Read image info readImageInfo(fSettings); cout << "\t-Loaded image info" << endl;
- if (sensor_ == System::IMU_MONOCULAR || sensor_ == System::IMU_STEREO || sensor_ == System::IMU_RGBD)
- {
- readIMU(fSettings);
- cout << "\t-Loaded IMU calibration" << endl;
- }
- if (sensor_ == System::RGBD || sensor_ == System::IMU_RGBD)
- {
- readRGBD(fSettings);
- cout << "\t-Loaded RGB-D calibration" << endl;
- }
- readORB(fSettings);
- cout << "\t-Loaded ORB settings" << endl;
- readViewer(fSettings);
- cout << "\t-Loaded viewer settings" << endl;
- readLoadAndSave(fSettings);
- cout << "\t-Loaded Atlas settings" << endl;
- readOtherParameters(fSettings);
- cout << "\t-Loaded misc parameters" << endl;
- if (bNeedToRectify_)
- {
- precomputeRectificationMaps();
- cout << "\t-Computed rectification maps" << endl;
- } cout << "----------------------------------" << endl;}
复制代码 竣事语
以上就是我学习到的内容,假如对您有资助请多多支持我,假如那里有标题欢迎各人在品评区积极讨论,我看到会实时复兴。
|