使用SURF在OpenCVEmguCV中匹配图像
本文关键字:图像 OpenCVEmguCV SURF 使用 | 更新日期: 2023-09-27 17:53:44
我正在这里编写源代码。
看起来indices
变量存储了匹配信息,但是我不知道这些信息是如何存储的。
例如,你能告诉我找到多少对匹配的点吗?哪个点与哪个点匹配?
看一下这一行。
Image<Bgr, Byte> result = Features2DToolbox.DrawMatches(modelImage, modelKeyPoints, observedImage, observedKeyPoints,
indices, new Bgr(255, 255, 255), new Bgr(255, 255, 255), mask, Features2DToolbox.KeypointDrawType.DEFAULT);
最重要的变量是掩码。这个变量包含了所有需要的信息。它是数组。如果这个数组的value等于1那就意味着我们有一个公共对。你必须计算1在这个数组中出现了多少次。
public int CountHowManyPairsExist( Matrix<byte> mask)
{
var matched = mask.ManagedArray;
var list = matched.OfType<byte>().ToList();
var count = list.Count(a => a.Equals(1));
return count;
}