我在一组图像的yml文件中有一个词汇表(簇的质心)。现在我从图像中获取了一个新的SURF描述符。现在我想检查这个新的关键点描述符到词汇表的距离或附近有一些门槛,并保存好的和坏的匹配。一旦我有好的和坏的描述我怎么能在图像上标记为关键点。我是新的opencv.I已经通过knnMatch但它只通过指定提供良好的匹配k。有人可以通过建议或示例代码帮助我。
这是我的示例代码
Mat dictionary;
FileStorage fs("../bin/dictionary1.yml", FileStorage::READ);
fs["vocabulary"] >> dictionary;
fs.release();
std::vector<KeyPoint> keypoints_1;
detector.detect( img_1, keypoints_1 );
SurfDescriptorExtractor surfDesc;
Mat descriptors1;
surfDesc.compute(img_1, keypoints_1, descriptors1);
我想像这样做一些事情
for all image descriptor
for all vacabulary
if(dist is less)
goodmatch
cvcolor=blue
else
badmatch
cvcolor=red
答案 0 :(得分:1)
你可以使用欧几里德距离d = sqrt(a1 ^ 2 + a2 ^ 2 + ... an ^ 2),但在这种情况下使用Mahalanobis距离会更好,因为它考虑了分布参数(协方差)。但是你需要计算每个集群的协方差,你可以在列车阶段得到它。您拥有集群中心,每个集群都有针对协方差评估的分数。