OKVIS框架之前端
1. 数据流入
在okvis_app_sychronous.cpp内,把IMU和图像数据加入到各自的队列里。由ThreadedKFVio负责队列的各种操作。作者对队列加了特殊功能,保证队列是线程安全的。比如:在push时,当超过最大设定值,可以选择是阻塞还是丢掉最老的数据。在pop时也有互斥锁。
/// \brief Push to the queue if the size is less than max_queue_size, else block.
/// \param[in] value New entry in queue.
/// \param[in] max_queue_size Maximum queue size.
/// \return False if shutdown is requested.
bool PushBlockingIfFull(const QueueType& value, size_t max_queue_size) {
while (!shutdown_) {
pthread_mutex_lock(&mutex_);
size_t size = queue_.size();
if (size >= max_queue_size) {
pthread_cond_wait(&condition_full_, &mutex_);
}
if (size >= max_queue_size) {
pthread_mutex_unlock(&mutex_);
continue;
}
queue_.push(value);
pthread_cond_signal(&condition_empty_); // Signal that data is available.
pthread_mutex_unlock(&mutex_);
return true;
}
return false;
}
/// \brief Push to the queue. If full, drop the oldest entry.
/// \param[in] value New entry in queue.
/// \param[in] max_queue_size Maximum queue size.
/// \return True if oldest was dropped because queue was full.
bool PushNonBlockingDroppingIfFull(const QueueType& value,
size_t max_queue_size) {
pthread_mutex_lock(&mutex_);
bool result = false;
if (queue_.size() >= max_queue_size) {
queue_.pop();
result = true;
}
queue_.push(value);
pthread_cond_signal(&condition_empty_); // Signal that data is available.
pthread_mutex_unlock(&mutex_);
return result;
}
/**
* @brief Get the oldest entry still in the queue. Blocking if queue is empty.
* @param[out] value Oldest entry in queue.
* @return False if shutdown is requested.
*/
bool Pop(QueueType* value) {
return PopBlocking(value);
}
2. IMU数据处理线程---imuConsumerLoop()
此线程主要是进行IMU积分,获得最新的没有优化过的位姿,以及速度,偏置等信息。每当位姿优化过后,会使repropagationNeeded置为真,则在优化后的参数上进行积分处理。
if (parameters_.publishing.publishImuPropagatedState) {
if (!repropagationNeeded_ && imuMeasurements_.size() > 0) {
start = imuMeasurements_.back().timeStamp;
} else if (repropagationNeeded_) {
std::lock_guard<std::mutex> lastStateLock(lastState_mutex_);
start = lastOptimizedStateTimestamp_;
T_WS_propagated_ = lastOptimized_T_WS_;
speedAndBiases_propagated_ = lastOptimizedSpeedAndBiases_;
repropagationNeeded_ = false;
} else
start = okvis::Time(0, 0);
end = &data.timeStamp;
}
imuMeasurements_.push_back(data);
} // unlock _imuMeasurements_mutex
std::cout<<"IMU loop"<<data.timeStamp<<std::endl;
// notify other threads that imu data with timeStamp is here.
imuFrameSynchronizer_.gotImuData(data.timeStamp);
if (parameters_.publishing.publishImuPropagatedState) {
Eigen::Matrix<double, 15, 15> covariance;
Eigen::Matrix<double, 15, 15> jacobian;
frontend_.propagation(imuMeasurements_, imu_params_, T_WS_propagated_,
speedAndBiases_propagated_, start, *end, &covariance,
&jacobian);
OptimizationResults result;
result.stamp = *end;
result.T_WS = T_WS_propagated_;
result.speedAndBiases = speedAndBiases_propagated_;
result.omega_S = imuMeasurements_.back().measurement.gyroscopes
- speedAndBiases_propagated_.segment<3>(3);
for (size_t i = 0; i < parameters_.nCameraSystem.numCameras(); ++i) {
result.vector_of_T_SCi.push_back(
okvis::kinematics::Transformation(
*parameters_.nCameraSystem.T_SC(i)));
}
result.onlyPublishLandmarks = false;
optimizationResults_.PushNonBlockingDroppingIfFull(result,1);
}
3. 图像数据处理线程---frameConsumerLoop(size_t cameraIndex)
3.1 生成multiFrame类
每一个相机都会有一个线程处理图像,所以这里需要把两个相机的图像融合到一个数据结构里,也就是multiFrame。
multiFrame = frameSynchronizer_.addNewFrame(frame);
此函数内部,不做检测,仅仅是融合左右两个图像到一个multiFrame里。
3.2 IMU预积分
如果是第一帧图像对,则不进行预积分。这里预积分是为了获得TWS,然后的出相机位姿,因为对特征点进行描述时,需要方向信息。但是目前左右帧都会进行预积分,然后在后端优化时候,estimator类里也会进行预积分。不明白对于同一对图像为什么不能只进行一次预积分。
3.3 特征点检测以及描述子计算
frontend_.detectAndDescribe(frame->sensorId, multiFrame, T_WC, nullptr);
这里没有用什么特殊的方法,都是opencv内的特征提取方法。
for (size_t i = 0; i < numCameras_; ++i) {
featureDetectors_.push_back(
std::shared_ptr<cv::FeatureDetector>(
#ifdef __ARM_NEON__
new cv::GridAdaptedFeatureDetector(
new cv::FastFeatureDetector(briskDetectionThreshold_),
briskDetectionMaximumKeypoints_, 7, 4 ))); // from config file, except the 7x4...
#else
new brisk::ScaleSpaceFeatureDetector<brisk::HarrisScoreCalculator>(
briskDetectionThreshold_, briskDetectionOctaves_,
briskDetectionAbsoluteThreshold_,
briskDetectionMaximumKeypoints_)));
#endif
descriptorExtractors_.push_back(
std::shared_ptr<cv::DescriptorExtractor>(
new brisk::BriskDescriptorExtractor(
briskDescriptionRotationInvariance_,
briskDescriptionScaleInvariance_)));
}
4. 匹配线程---matchingLoop()
在判断左右两幅图像都检测完后,则把数据传给匹配线程。匹配过程略复杂,而且代码使用了很多模板,比较难看懂。在进行图像匹配前,作者先把状态参数,传递给后端,添加各种误差项。这里不太明白为什么要在匹配前进行。
if (estimator_.addStates(frame, imuData, asKeyframe))
{
lastAddedStateTimestamp_ = frame->timestamp();
addStateTimer.stop();
} else {
LOG(ERROR) << "Failed to add state! will drop multiframe.";
addStateTimer.stop();
continue;
}
// -- matching keypoints, initialising landmarks etc.
okvis::kinematics::Transformation T_WS;
estimator_.get_T_WS(frame->id(), T_WS);
matchingTimer.start();
frontend_.dataAssociationAndInitialization(estimator_, T_WS, parameters_, map_, frame, &asKeyframe);
matchingTimer.stop();
然后先让current frame 和以前所有的关键帧进行匹配。然后再和lastFrame进行匹配,最后进行左右立体匹配。每种匹配后都会在setBestMatch函数内增加每个点的投影误差。matchingLoop有点像前端和后端的桥梁,在这里准备后端优化所需要的数据。
OKVIS框架之前端的更多相关文章
- 刚写完的商城erp + 这个商城前台,新鲜出炉。自己1个人写, 包括php框架和前端html页面.
刚写完的商城erp + 这个商城前台,新鲜出炉.自己1个人写, 包括php框架和前端html页面. 刚写完的商城erp + 这个商城前台,新鲜出炉.自己1个人写, 包括php框架和前端html页面.
- MUI框架-11-MUI前端 +php后台接入百度文字识别API
MUI框架-11-MUI前端 +php后台接入百度文字识别API 这里后台不止一种,Python,Java,PHP,Node,C++,C# 都可以 这里使用的是 php 来介绍,已经解决所有问题,因为 ...
- 循序渐进VUE+Element 前端应用开发(12)--- 整合ABP框架的前端登录处理
VUE+Element 前端是一个纯粹的前端处理,前面介绍了很多都是Vue+Element开发的基础,从本章随笔开始,就需要进入深水区了,需要结合ABP框架使用(如果不知道,请自行补习一下我的随笔:A ...
- abp.zero 9.0框架的前端Angular使用说明
abp.zero 9.0框架的前端Angular使用说明 目录 abp.zero 9.0框架的前端Angular使用说明 摘要 1 部署及启动 1.1 依赖包安装 1.2 使用yarn安装依赖包 1. ...
- 在基于ABP框架的前端项目Vue&Element项目中采用电子签名的处理
在前面随笔介绍了<在基于ABP框架的前端项目Vue&Element项目中采用电子签章处理文件和打印处理>的处理,有的时候,我们在流程中或者一些文件签署的时候,需要签上自己的大名,一 ...
- 二十三、【开源】EFW框架Web前端开发之常用组件(FusionCharts图表、ReportAll报表等)
回<[开源]EFW框架系列文章索引> EFW框架源代码下载V1.2:http://pan.baidu.com/s/1hcnuA EFW框架实例源代码下载:http://pan ...
- 二十一、【.Net开源框架】EFW框架Web前端开发之目录结构和使用FireBug调试方法
回<[开源]EFW框架系列文章索引> EFW框架源代码下载V1.2:http://pan.baidu.com/s/1hcnuA EFW框架实例源代码下载:http://pan.baidu. ...
- 找到MVC框架中前端URL与后端同步的解决方案
基本思路: 先用URL标签生成完整的URL字符,前端动态参数的部分以适配符先填充,最后动态参数利用正则匹配进行替换. 这种方式,可以在各种MVC框架中适用,妙. 不废话,上码. var url = & ...
- 2017年 JavaScript 框架回顾 -- 前端框架
概述: 对于 JavaScript 社区来说,npm 的主要功能之一就是帮助开发者发掘所需的 npm Registry 中的库和框架.npm 强大的搜索功能能够帮助找到一组相关的软件包,同时其内置的的 ...
随机推荐
- Linux设置数据库自动备份
本文为转载,最末端为原地址 以CentOS 7.6系统与Oracle 11g为例: 一.先找到数据库的环境变量 如果是在root账户下,须先登录到数据库所在账户 su oraclecat ~/.bas ...
- 脚本_监控 HTTP 服务器的状态
#!bin/bash#功能:监控 HTTP 服务器的状态(测试返回码) #作者:liusingbon#设置变量,url 为你需要检测的目标网站的网址(IP 或域名)url=http://192.168 ...
- Kvm --01 虚拟化基础概念
目录 1. 虚拟化基础概念 01. 什么是虚拟化? 02. 为什么要用虚拟化? 03. 虚拟化在企业中的应用场景? 04. 虚拟化软件介绍 05. Kvm介绍 2. 安装部署Kvm 3. Kvm虚拟机 ...
- 转贴健康资讯:神奇的“XX水”,死了一茬又来一茬?
神奇的“XX水”,死了一茬又来一茬? 2014年7月20日 京虎子 http://www.scipark.net/archives/19816 最近看到两桩事,一是孕妇防辐射服,一是富氧水.这两桩事合 ...
- Sass-注释
注释对于一名程序员来说,是极其重要,良好的注释能帮助自己或者别人阅读源码.在 Sass 中注释有两种方式,我暂且将其命名为: 1.类似 CSS 的注释方式,使用 ”/* ”开头,结属使用 ”*/ ”2 ...
- umount device is busy 的处理方法
[root@web2-server yum.repos.d]# umount /mnt/cdrom/ umount: /mnt/cdrom: device is busy. (In some case ...
- 1、pip不是内部运行程序 解决方法
一.方式一 1.切换到pip所在路径: shit+ 右键. 再此处打开运行窗口 2.执行 pip install pytest 脚本即可. 二.方式二,添加环境变量 1.将pip所在的文件路径 添加到 ...
- springboot+jsp+mybatis项目实例(后台成功,但是无法跳转jsp页面,没有实体类的注解,看springboot+jsp第二弹相关配置,即可成功配置jsp)
SpringBoot是用来简化SpringMvc开发的项目,这里自然要整合mybatis等持久化框架! 先看看项目目录: 一.在pom.xml中配置依赖jar包:<project xmlns=& ...
- notepad++ 安装 hex_editor 十六进制查看插件
1.到 https://github.com/chcg/NPP_HexEdit/releases 去下载相应的文件,注意32位和64位的区别 2.点击notepad++的设置--->导入--&g ...
- HttpClient之HttpContext使用
Multiple request sequences that represent a logically related session should be executed with the sa ...