4

Here is a snapshot of my code,

Matrix<byte> mask;
int k = 2;
VectorOfKeyPoint modelKeyPoints;
VectorOfKeyPoint observedKeyPoints;
SURFDetector surfCPU = new SURFDetector(500, false);
modelKeyPoints = surfCPU.DetectKeyPointsRaw(modelImage, null);
Matrix<float> modelDescriptors = surfCPU.ComputeDescriptorsRaw(modelImage, null, modelKeyPoints);
observedKeyPoints = surfCPU.DetectKeyPointsRaw(observedImage, null);
Matrix<float> observedDescriptors = surfCPU.ComputeDescriptorsRaw(observedImage, null, observedKeyPoints);
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);
}

I always get the following exception at KnnMatch()

Emgu.CV.Util.CvException occurred Message: OpenCV: queryDescriptors.type() == trainDescCollection[0].type()

I have tried so hard to get rid of this exception and no hope :(

4

2 回答 2

2

我终于找到了这个问题的原因

它是 modelKeyPoints 或observedKeyPoints null 之一:)

于 2012-12-05T12:47:21.313 回答
1

与 Zaher 的回答非常相似 - 我的 modelKeyPoints 不是空的,而是空的(modelKeyPoints.Size == 0)。

使用不同的模型图像会有所帮助。

于 2014-01-08T18:29:51.173 回答