目录
ORB-SLAM2 ---- ORBmatcher::SearchForInitialization函数_Courage2022的博客-CSDN博客
计算旋转直方图中分布前三的直方图索引。
- /**
- * @brief 筛选出在旋转角度差落在在直方图区间内数量最多的前三个bin的索引
- *
- * @param[in] histo 匹配特征点对旋转方向差直方图
- * @param[in] L 直方图尺寸
- * @param[in & out] ind1 bin值第一大对应的索引
- * @param[in & out] ind2 bin值第二大对应的索引
- * @param[in & out] ind3 bin值第三大对应的索引
- */
- void ORBmatcher::ComputeThreeMaxima(vector<int>* histo, const int L, int &ind1, int &ind2, int &ind3)
- {
- int max1=0;
- int max2=0;
- int max3=0;
-
- for(int i=0; i
- {
- const int s = histo[i].size();
- if(s>max1)
- {
- max3=max2;
- max2=max1;
- max1=s;
- ind3=ind2;
- ind2=ind1;
- ind1=i;
- }
- else if(s>max2)
- {
- max3=max2;
- max2=s;
- ind3=ind2;
- ind2=i;
- }
- else if(s>max3)
- {
- max3=s;
- ind3=i;
- }
- }
-
- // 如果差距太大了,说明次优的非常不好,这里就索性放弃了,都置为-1
- if(max2<0.1f*(float)max1)
- {
- ind2=-1;
- ind3=-1;
- }
- else if(max3<0.1f*(float)max1)
- {
- ind3=-1;
- }
- }
就是一个简单的选择排序....
另外需要注意如果最佳和次加差别太大,则放弃次加,同理次加和此次加。