Here is the code
Bitmap model = new Bitmap("image1.png");
Bitmap observered = new Bitmap("image2.png");
SpeededUpRobustFeaturesDetector surf = new SpeededUpRobustFeaturesDetector();
List<SpeededUpRobustFeaturePoint> points = surf.ProcessImage(model);
List<SpeededUpRobustFeaturePoint> points1 = surf.ProcessImage(observered);
now i need to match the points using KNN. Can anyone help me out?
As well as, i planned to use the Ransac to reduce the incorrect matches. Any light on the same?
Thanks
Barath
SURFDetector surfCPU = new SURFDetector(500, false);
VectorOfKeyPoint modelKeyPoints;
VectorOfKeyPoint observedKeyPoints;
Matrix<int> indices;
Matrix<byte> mask;
int k = 2;
double uniquenessThreshold = 0.8;
modelKeyPoints = surfCPU.DetectKeyPointsRaw(modelImage, null);
Matrix<float> modelDescriptors = surfCPU.ComputeDescriptorsRaw(modelImage, null, modelKeyPoints);
watch = Stopwatch.StartNew();
// extract features from the observed image
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);
mask = new Matrix<byte>(dist.Rows, 1);
mask.SetValue(255);
Features2DToolbox.VoteForUniqueness(dist, uniquenessThreshold, mask);
}
int nonZeroCount = CvInvoke.cvCountNonZero(mask);
if (nonZeroCount >= 4)
{
nonZeroCount = Features2DToolbox.VoteForSizeAndOrientation(modelKeyPoints, observedKeyPoints, indices, mask, 1.5, 20);
if (nonZeroCount >= 4)
homography = Features2DToolbox.GetHomographyMatrixFromMatchedFeatures(modelKeyPoints, observedKeyPoints, indices, mask, 2);
}
Is this possible to achieve the same functionality with ACCORD.NET.
((number of matching points/number of query image key points) * 100). It works in most situations. but i feel it is not a stable formula to calculate the matching percentage. If we get this intellignece in API.It would be huge boost for many like me.
I wonder is there any implemented method, or any way how to do it, that comparing to shapes i could get percentageof similarity?
while i have coleration points, what is the best way to compare?
is it possible to get in touch with you?
Regards.
Regards
Hadeel