当前位置: 首页 > news >正文

ORB_SLAM2原理及代码解析:Tracking::CreateInitialMapMonocular() 函数

1 作用

创建初始化地图。

2 参数及含义

3 代码

void Tracking::CreateInitialMapMonocular()
{// Create KeyFramesKeyFrame* pKFini = new KeyFrame(mInitialFrame,mpMap,mpKeyFrameDB);KeyFrame* pKFcur = new KeyFrame(mCurrentFrame,mpMap,mpKeyFrameDB);pKFini->ComputeBoW();pKFcur->ComputeBoW();// Insert KFs in the mapmpMap->AddKeyFrame(pKFini);mpMap->AddKeyFrame(pKFcur);// Create MapPoints and asscoiate to keyframesfor(size_t i=0; i<mvIniMatches.size();i++){if(mvIniMatches[i]<0)continue;//Create MapPoint.cv::Mat worldPos(mvIniP3D[i]);MapPoint* pMP = new MapPoint(worldPos,pKFcur,mpMap);pKFini->AddMapPoint(pMP,i);pKFcur->AddMapPoint(pMP,mvIniMatches[i]);pMP->AddObservation(pKFini,i);pMP->AddObservation(pKFcur,mvIniMatches[i]);pMP->ComputeDistinctiveDescriptors();pMP->UpdateNormalAndDepth();//Fill Current Frame structuremCurrentFrame.mvpMapPoints[mvIniMatches[i]] = pMP;mCurrentFrame.mvbOutlier[mvIniMatches[i]] = false;//Add to MapmpMap->AddMapPoint(pMP);}// Update ConnectionspKFini->UpdateConnections();pKFcur->UpdateConnections();// Bundle Adjustmentcout << "New Map created with " << mpMap->MapPointsInMap() << " points" << endl;Optimizer::GlobalBundleAdjustemnt(mpMap,20);// Set median depth to 1float medianDepth = pKFini->ComputeSceneMedianDepth(2);float invMedianDepth = 1.0f/medianDepth;if(medianDepth<0 || pKFcur->TrackedMapPoints(1)<100){cout << "Wrong initialization, reseting..." << endl;Reset();return;}// Scale initial baselinecv::Mat Tc2w = pKFcur->GetPose();Tc2w.col(3).rowRange(0,3) = Tc2w.col(3).rowRange(0,3)*invMedianDepth;pKFcur->SetPose(Tc2w);// Scale pointsvector<MapPoint*> vpAllMapPoints = pKFini->GetMapPointMatches();for(size_t iMP=0; iMP<vpAllMapPoints.size(); iMP++){if(vpAllMapPoints[iMP]){MapPoint* pMP = vpAllMapPoints[iMP];pMP->SetWorldPos(pMP->GetWorldPos()*invMedianDepth);}}mpLocalMapper->InsertKeyFrame(pKFini);mpLocalMapper->InsertKeyFrame(pKFcur);mCurrentFrame.SetPose(pKFcur->GetPose());mnLastKeyFrameId=mCurrentFrame.mnId;mpLastKeyFrame = pKFcur;mvpLocalKeyFrames.push_back(pKFcur);mvpLocalKeyFrames.push_back(pKFini);mvpLocalMapPoints=mpMap->GetAllMapPoints();mpReferenceKF = pKFcur;mCurrentFrame.mpReferenceKF = pKFcur;mLastFrame = Frame(mCurrentFrame);mpMap->SetReferenceMapPoints(mvpLocalMapPoints);mpMapDrawer->SetCurrentCameraPose(pKFcur->GetPose());mpMap->mvpKeyFrameOrigins.push_back(pKFini);mState=OK;
}

4 解析

http://www.dtcms.com/a/441692.html

相关文章:

  • 【Linux】System V —— 基于建造者模式的信号量
  • VScode-ESP-IDF工程函数定义无法跳转且无注释提示
  • 最新的网站建设软件标书制作员工作内容
  • JAVA SE 基础语法 —— C / 运算符
  • SSM餐饮管理系统uto0o《开发全资源(程序 / 源码 / 数据库)+ 万言论文(文末)+ 系统界面》
  • 上饶市建设厅网站中国最新消息新冠疫苗最新消息
  • 安徽省建设银行网站关于网站建设的意见
  • 免费域名建站青岛网站有限公司
  • 广东泰通建设有限公司网站东莞人才网58
  • 什么是wap网站甘家口网站建设
  • 网站接电话中国关键词官网
  • 广州车陂网站建设公司wordpress如何修改博客模板
  • 沈阳谷歌网站建设金湖建设局网站
  • 淳化网站制作我自己的网站怎么做关键词优化
  • 深圳网站建设工作在线文字logo设计
  • 网站开发 聊天窗口镇平微网站开发
  • 网站平台延展性广州品牌网站设计价格
  • 网站开发合作意向书网站域名使用费用
  • 音乐网站的音乐怎么做音乐试听wordpress文章分页共多少页
  • 怎么选择做网站的公司专业建设情况
  • 申请网站空间是申请域名吗个人新闻类网站模板
  • 网站建设流程是什么意思解决方案网站设计
  • 网络公司 网站设计做衣服的教程网站
  • 网站内容创造深夜免费软件app下载
  • 广州网站建设亅新科送推广全国小微企业名录
  • 手机网站课程360优化大师历史版本
  • 网站都有什么类型的极简网站设计
  • 网站截图环境 php成品网站1688入口的功能介绍
  • 赶集网的二级域名网站怎么做分类信息网站建设模板
  • 郑州做网站华久科技开发一个电商网站