gpt4 book ai didi

c# - 使用KnnMatch返回2张图像之间的相似度

转载 作者:行者123 更新时间:2023-12-02 16:47:24 24 4
gpt4 key购买 nike

我有来自emgu opencv包装器的以下示例

HomographyMatrix homography = null;
SURFDetector surfCPU = new SURFDetector(500,true);
VectorOfKeyPoint modelKeyPoints;
VectorOfKeyPoint observedKeyPoints;
Matrix<int> indices;

Matrix<byte> mask;
int k = 2;
double uniquenessThreshold = 0.9; //0.8

//extract features from the object image
modelKeyPoints = surfCPU.DetectKeyPointsRaw(modelImage, null);
Matrix<float> modelDescriptors = surfCPU.ComputeDescriptorsRaw(modelImage, null, modelKeyPoints);
modelImage.Dispose();


// extract features from the observed image
observedKeyPoints = surfCPU.DetectKeyPointsRaw(observedImage, null);
Matrix<float> observedDescriptors = surfCPU.ComputeDescriptorsRaw(observedImage, null, observedKeyPoints);
observedImage.Dispose();
BruteForceMatcher<float> matcher = new BruteForceMatcher<float>(DistanceType.L2);
matcher.Add(modelDescriptors);

indices = new Matrix<int>(observedDescriptors.Rows, k);
using (Matrix<float> dist = new Matrix<float>(observedDescriptors.Rows, k))
{
matcher.KnnMatch(observedDescriptors, indices, dist, k, null);
mask = new Matrix<byte>(dist.Rows, 1);
mask.SetValue(255);
Features2DToolbox.VoteForUniqueness(dist, uniquenessThreshold, mask);
}
//...

应用KnnMatch后,如何获取匹配的关键点数量,以及非零像素计数与获取2张图像之间的相似性有什么关系?

最佳答案

  • 指的是opencv doc http://www.opencv.org.cn/opencvdoc/2.3.2/html/modules/features2d/doc/common_interfaces_of_descriptor_matchers.html

    void DescriptorMatcher::knnMatch(const Mat&queryDescriptors,vector>&match,int k,const vector&masks = vector(),bool compactResult = false)

    匹配项(在您的代码中为dist)–匹配项。对于同一查询描述符,每个matchs [i]是k个或更少的匹配项。
    k –每个查询描述符找到的最佳匹配计数,如果查询描述符的总数少于k,则更少。
  • 关于相似性(我不清楚这个问题),代码使用的是L2距离。

    BruteForceMatcher匹配器=新的BruteForceMatcher(DistanceType.L2);
  • 关于c# - 使用KnnMatch返回2张图像之间的相似度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21665809/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com