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

ORB_SLAM2原理及代码解析:Initializer::Initialize() 函数

1 作用

2 参数及其含义

3 代码

(1)声明:Initializer.h

    // Computes in parallel a fundamental matrix and a homography// Selects a model and tries to recover the motion and the structure from motionbool Initialize(const Frame &CurrentFrame, const vector<int> &vMatches12,cv::Mat &R21, cv::Mat &t21, vector<cv::Point3f> &vP3D, vector<bool> &vbTriangulated);

(2)定义:Initializer.cc

bool Initializer::Initialize(const Frame &CurrentFrame, const vector<int> &vMatches12, cv::Mat &R21, cv::Mat &t21,vector<cv::Point3f> &vP3D, vector<bool> &vbTriangulated)
{// Fill structures with current keypoints and matches with reference frame// Reference Frame: 1, Current Frame: 2mvKeys2 = CurrentFrame.mvKeysUn;mvMatches12.clear();mvMatches12.reserve(mvKeys2.size());mvbMatched1.resize(mvKeys1.size());for(size_t i=0, iend=vMatches12.size();i<iend; i++){if(vMatches12[i]>=0){mvMatches12.push_back(make_pair(i,vMatches12[i]));mvbMatched1[i]=true;}elsemvbMatched1[i]=false;}const int N = mvMatches12.size();// Indices for minimum set selectionvector<size_t> vAllIndices;vAllIndices.reserve(N);vector<size_t> vAvailableIndices;for(int i=0; i<N; i++){vAllIndices.push_back(i);}// Generate sets of 8 points for each RANSAC iterationmvSets = vector< vector<size_t> >(mMaxIterations,vector<size_t>(8,0));DUtils::Random::SeedRandOnce(0);for(int it=0; it<mMaxIterations; it++){vAvailableIndices = vAllIndices;// Select a minimum setfor(size_t j=0; j<8; j++){int randi = DUtils::Random::RandomInt(0,vAvailableIndices.size()-1);int idx = vAvailableIndices[randi];mvSets[it][j] = idx;vAvailableIndices[randi] = vAvailableIndices.back();vAvailableIndices.pop_back();}}// Launch threads to compute in parallel a fundamental matrix and a homographyvector<bool> vbMatchesInliersH, vbMatchesInliersF;float SH, SF;cv::Mat H, F;thread threadH(&Initializer::FindHomography,this,ref(vbMatchesInliersH), ref(SH), ref(H));thread threadF(&Initializer::FindFundamental,this,ref(vbMatchesInliersF), ref(SF), ref(F));// Wait until both threads have finishedthreadH.join();threadF.join();// Compute ratio of scoresfloat RH = SH/(SH+SF);// Try to reconstruct from homography or fundamental depending on the ratio (0.40-0.45)if(RH>0.40)return ReconstructH(vbMatchesInliersH,H,mK,R21,t21,vP3D,vbTriangulated,1.0,50);else //if(pF_HF>0.6)return ReconstructF(vbMatchesInliersF,F,mK,R21,t21,vP3D,vbTriangulated,1.0,50);return false;
}

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

相关文章:

  • 建设网站地图做教师知识网站有哪些
  • leetcode 526 优美的排列
  • 网站建设 10万元企业做网站的费用如何科目
  • 洛阳瀍河建设局网站珠海做网站那家好
  • 建设银行东营分行网站企业网站项目报价多少合适
  • 怎么用word做一个网站徐州建站费用
  • 带root权限_九联UNT402A优盘刷机包及线刷包 当贝桌面固件
  • 王健林亏60亿做不成一个网站市政工程单位工程划分
  • 制作网站支付方式电影网站推广
  • 蓝德网站建设用凡科建设的网站安全吗
  • 推客分销系统开发指南:从0到1搭建多级分润体系
  • 网站建设的需求和目的自建网站三种模式
  • 希尔顿酒店网站建设的优点专业公司网站设计企业
  • 怎么设置自己的网站wordpress免费主题外贸
  • 如何查看网站seo网站质量度
  • 网站域名登陆地址查询网站开发人员的职责
  • 如何申请我的网站168分类信息发布网
  • 音乐网站界面如何保持网站中的图片
  • 建设网站报价南昌做网站的公司有哪些
  • 654.最大二叉树(二叉树算法)
  • 网站运营 策划 推广 维护网络营销方式给消费者消费行为模式带来的影响
  • 网站谷歌seo做哪些淮安做网站的公司
  • 已经有域名如何做网站内蒙古呼和浩特职业学院
  • 海沧网站建设视频网站开发php
  • 网站开发及维护招聘wordpress站点版权设置
  • 网站建设的合同书网站次年续费
  • 什么网站可以做数据调查问卷网站备案后 换服务器
  • 最新做做网站免费2014 个人网站备案
  • cpa怎么做网站wordpress-saas
  • Cliproxy代理IP:解锁Reddit多账号运营的安全与效率密码