Ask Your Question
0

cv::flann::index::knnsearch values of indices and dists

asked 2016-02-02 14:47:41 -0600

phirestalker gravatar image

updated 2016-02-02 21:22:08 -0600

ok given the following code

    index.knnSearch(mat,indices,dists,3);

when using binary descriptors how do I make dists results into a useful ratio or percentage match?

edit retag flag offensive close merge delete

Comments

"a useful ratio or percentage match" -- describing what ?

the smaller the distance, the closer your mat is to the retrieved items

berak gravatar imageberak ( 2016-02-02 23:56:52 -0600 )edit

Thanks I did some reading and I think I've got a formula

phirestalker gravatar imagephirestalker ( 2016-02-03 00:13:01 -0600 )edit

oh, please tell us ?

berak gravatar imageberak ( 2016-02-03 00:22:48 -0600 )edit
1

it returns the amount of differing bits between the 2 matches. so for 500 descriptors at 32 BYTES each so 256 bits, 256 X 500 descriptors 128,000 bits per set of descriptors so a 90% match would mean a value of 12,800 so anything lower than that is a good match

phirestalker gravatar imagephirestalker ( 2016-02-03 00:29:10 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-02-05 13:12:26 -0600

phirestalker gravatar image

updated 2016-02-05 13:56:44 -0600

here is some code that will solve the question

bool goodMatch(int distance, float percent, int descriptornum)
{
    int descriptorbits = 256 * descriptornum;
    int result = descriptorbits - (descriptorbits * percent);
    return (distance <= result);
}

distance - the value returned in dists percent - float value of percent (i.e. 90% = 0.9) descriptornum - the number of descriptors

edit flag offensive delete link more

Comments

1

Just some style: "return (distance <= result);"

FooBar gravatar imageFooBar ( 2016-02-05 13:54:09 -0600 )edit

thanks, edited

phirestalker gravatar imagephirestalker ( 2016-02-05 13:57:01 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-02-02 14:47:41 -0600

Seen: 337 times

Last updated: Feb 05 '16