1 year ago

#316394

test-img

erik7854

EmguCV: What is the right variable to use for detector descriptors? Error:"OpenCV: > type=0"

I'm trying to detect the keypoints and descriptors to match a template with another image.

I started to follow this OpenCV tutorial, switched to ORB detector (as SURF algorithm is patented) but it's throwing an exception when I perform the KnnMatch().

Here's my code:

Mat template = new Mat(templatePath, ImreadModes.Grayscale);
ORB orbDetector = new ORB(1000);
VectorOfKeyPoint keyPointTemplate = new VectorOfKeyPoint();
VectorOfKeyPoint keyPointImg = new VectorOfKeyPoint();
var descTemplate = new Mat();
var descImg = new Mat();
orbDetector.DetectAndCompute(template, new Mat(), keyPointTemplate, descTemplate, false);
orbDetector.DetectAndCompute(und, new Mat(), keyPointImg, descImg, false);
KdTreeIndexParams ip = new KdTreeIndexParams();
SearchParams sp = new SearchParams();
FlannBasedMatcher matcher = new FlannBasedMatcher(ip, sp);
VectorOfVectorOfDMatch knnMatches = new VectorOfVectorOfDMatch();
matcher.KnnMatch(descTemplate, descImg, knnMatches, 2); // exception: OpenCV: > type=0

The only example code I could find is this official documentation that uses FAST but, as it was published 9 years ago, the code is outdated and when I tried to adapt to current EmguCV version gave only more issues.

I already tried changing descTemplate and descImg to VectorOf* but I had no luck with it.

c#

opencv

emgucv

0 Answers

Your Answer

Accepted video resources