本文主要是介绍接上篇博文:视觉检测过程中特征匹配结果容器类DMatch判断,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
紧接上篇博文,顺势将特征匹配的结果进行筛选,并把代码做了实现。
思路是用matches[i].distance判断是否满足条件,由于网上能够查阅到的资料仅仅是将计算得到的匹配特征点用drawMatch()绘制两幅图像的匹配结果,我这里是自己进行了匹配筛选,编译是能够成功的。
double averagematch_dist =0;for(int i = 0; i < ptsPairs; i++){averagematch_dist = averagematch_dist + good_matches[i].distance / ptsPairs;}//averagematch = 0.5 * (good_matches[0].distance + good_matches[ptsPairs].distance);if(!(good_matches[0].distance < 1.0 &&good_matches[ptsPairs].distance < 1.0 &&(good_matches[0].distance - averagematch_dist < 0.5 ) &&good_matches[ptsPairs].distance - averagematch_dist < 0.5 ))continue;/*double max_dist = 0;double min_dist = 100;for(int i = 0; i < descriptor1.rows; i++){double dist = matches[i].distance;if(dist < min_dist)min_dist = dist;if(dist > max_dist)max_dist = dist;}//得到匹配结果中的最小距离和最大距离//处理匹配结果:判断当前匹配的对象是否为目标,仅根据最大最小匹配距离,能否进行判断?if(!(min_dist < 1.0 || (max_dist - min_dist) < 2.0))// matching failed{//tracking_frame = tracking_frame;//body_track_rect = body_track_rect;continue;}*/
这篇关于接上篇博文:视觉检测过程中特征匹配结果容器类DMatch判断的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!