Ask Your Question
1

How to count the matching lines in SURF ?

asked 2016-12-01 09:28:10 -0600

rugby2312 gravatar image

updated 2016-12-01 09:37:16 -0600

berak gravatar image

Hi ,

I am using SURF and trying to extract features and matches, so far so good, however, the only thing that I'have not been able to figure out is how to count the number of matching lines between the two compared images.

Which property , attribute , should I use ?

I'm pretty sure the value is probably within the vector of match, just don't know now how to extract it..

P.S : I'm using a .NET Wrapper

Many thanks in advance

edit retag flag offensive close merge delete

Comments

1

So you want to actually count the matches?

Vintez gravatar imageVintez ( 2016-12-01 09:33:15 -0600 )edit

"count the matching lines" seems an inadequate description, - can you try again ?

(also, let's try to abstract away from your (unsupported, 3rdparty) c# api wrapper)

berak gravatar imageberak ( 2016-12-01 09:34:22 -0600 )edit

By counting the matching lines , I meant as counting the red lines as in this image http://imgur.com/YiKrLxd

rugby2312 gravatar imagerugby2312 ( 2016-12-01 20:09:07 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2016-12-01 09:56:49 -0600

Vintez gravatar image

updated 2016-12-01 09:58:12 -0600

Because I don't know how your .NET Wrapper works, I don't think that I can give you a proper Answer for .NET. Instead I show you, what would be necessary in c#.

starting from the code mentioned here on the emguCV site.

The most important variable there is the mask which is put into the findMatchesMethod here:

FindMatch(modelImage, observedImage, out matchTime, out modelKeyPoints, out observedKeyPoints, matches, out mask, out homography);

This mask holds the result of the complete matching. (to be exact, it is as big as the KeyPoints you have). Now if you want to count the matches (no Line without a Match so number of Lines == number of Matches) you check each field in this array for the value 1 which represents a Match.

Here a code example:

public int CountHowManyPairsExist( Matrix<byte> mask)
{
    var matched = mask.ManagedArray;
    var list = matched.OfType<byte>().ToList();
    var count = list.Count(a => a.Equals(1));
    return count;
}
edit flag offensive delete link more

Comments

1

Thanks Vintez. I'm actually using EmguCV , sorry I did not mention, and what you are proposing that's exactly what I need. One last question :

I have declared "mask" variable as a Mat . How do I convert "mask" from Mat to Matrix<byte> ?

rugby2312 gravatar imagerugby2312 ( 2016-12-01 19:55:20 -0600 )edit
1

I did the conversion by using :

Matrix<byte> xx = new Matrix<byte>(mask.Rows, mask.Cols);
mask.CopyTo(xx); CountHowManyPairsExist(xx);

Thank you for your help.

rugby2312 gravatar imagerugby2312 ( 2016-12-01 20:49:48 -0600 )edit
1

@rugby2312 glad that I could help you! hope it works exactly as expected

Vintez gravatar imageVintez ( 2016-12-02 01:30:00 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-12-01 09:28:10 -0600

Seen: 699 times

Last updated: Dec 01 '16