本文整理汇总了C++中KeyFrame::Distance方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyFrame::Distance方法的具体用法?C++ KeyFrame::Distance怎么用?C++ KeyFrame::Distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyFrame
的用法示例。
在下文中一共展示了KeyFrame::Distance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Finds N closest KeyFrames
std::vector<KeyFrame*> MapMakerBase::NClosestKeyFrames(KeyFrame& kfSrc, unsigned int N)
{
std::vector<std::pair<double, KeyFrame*>> vScoresAndKFs;
for (MultiKeyFramePtrList::iterator it = mMap.mlpMultiKeyFrames.begin(); it != mMap.mlpMultiKeyFrames.end(); ++it)
{
MultiKeyFrame& mkf = *(*it);
// Have to iterate through each MultiKeyFrame as well to get KeyFrames
for (KeyFramePtrMap::iterator jit = mkf.mmpKeyFrames.begin(); jit != mkf.mmpKeyFrames.end(); jit++)
{
KeyFrame& kf = *(jit->second);
if (&kf == &kfSrc)
continue;
double dDist = kfSrc.Distance(kf);
vScoresAndKFs.push_back(std::make_pair(dDist, &kf));
}
}
if (N > vScoresAndKFs.size()) // if we expect too many neighbors
N = vScoresAndKFs.size(); // reduce numbe that will be returned
// Sort the first N entries by score
std::partial_sort(vScoresAndKFs.begin(), vScoresAndKFs.begin() + N, vScoresAndKFs.end());
std::vector<KeyFrame*> vResult;
for (unsigned int i = 0; i < N; i++)
vResult.push_back(vScoresAndKFs[i].second);
return vResult;
}