EMGU 2.4.0 BruteForceMatcher KNNMATCH not working?

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 in KnnMatch ()

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

I tried so hard to get rid of this exception and do not hope :(

+4
source share
2 answers

I finally found the cause of this problem

he was one of modelKeyPoints or noticedKeyPoints null :)

+2
source

Very similar to Zaher's answer: my KeyPoints model was not null, but it was empty (modelKeyPoints.Size == 0).

Using a different model image helped.

+1
source

Source: https://habr.com/ru/post/1446016/


All Articles