java - Bruteforce and matching gives reverse/wrong results -
i've been making application 2 images can compared (2 pictures on smartphone). there use fast detector , freak descriptor on limited amount of keypoints (i filtered out 300 best ones according response). when try match bruteforce_hamming, gives 0 matches.
matching happens with
matofdmatch matches = new matofdmatch(); matcher = descriptormatcher.create(descriptormatcher.bruteforce_hamming); matcher.match(descriptors,descriptors1,matches); matofdmatch goedematches = new matofdmatch(); double max_dist = 0; double min_dist = 100; //if (descriptors.cols() == descriptors1.cols()) //{ for( int = 0; < descriptors.rows(); i++ ) { double dist = matches.toarray()[i].distance; if( dist < min_dist ) min_dist = dist; if( dist > max_dist ) max_dist = dist; } // should draw matches for( int = 0; < descriptors.rows(); i++ ) { matofdmatch temp = new matofdmatch(); if( matches.toarray()[i].distance < 2*min_dist ) { temp.fromarray(matches.toarray()[i]); goedematches.push_back(temp); } // } } log.d("log!", "number of matches= " + goedematches.size());
when compare image itself, following output. output 0x0 matches.
05-02 15:52:30.325: d/log!(17866): number of descriptors image 1= 64x286 05-02 15:52:30.325: d/log!(17866): number of descriptors image 2= 64x286 05-02 15:52:30.325: d/log!(17866): description time elapsed 339 ms 05-02 15:52:30.555: d/log!(17866): minimum distance = 0.0 05-02 15:52:30.560: d/log!(17866): maximum distance= 0.0 05-02 15:52:30.560: d/log!(17866): number of matches= 0x0
when use same picture , 1 has nothing it, 471 matches. there wrong inside code, can't seem see what's wrong (the code seems reserve, cause same isn't matched, , it's matched when it's different. code doing wrong?)
important: don't mind red dots on right picture, it's old picture took when drew keypoints on screen. not stand matching itself! other picture has nothing first image.
05-02 16:03:06.120: d/log!(19025): number of descriptors image 1= 64x259 05-02 16:03:06.120: d/log!(19025): number of descriptors image 2= 64x286 05-02 16:03:06.420: d/log!(19025): minimum distance= 93.0 05-02 16:03:06.420: d/log!(19025): maximum distance = 183.0 05-02 16:03:06.420: d/log!(19025): number of matches= 1x286
if( matches.toarray()[i].distance < 2*min_dist )
in first case compare same images, value of min_dist therefore 0 , if statement reject matches no distance smaller 0.
in second case min_dist 93*2=186 , since maximum_distance 183 lead accepting matches instead of rejecting them.
consider looking opencv computer vision cookbook in chapter 9 there approach keeping matches based on ratio , symmetry test.
Comments
Post a Comment