How to find good matches of FeatureDetector

83 views Asked by At

I am using OpenCV 3.0 in Java, I want to track a known object using FAST(FeatureDetector)/ORB(DescriptorExtractor)/BRUTEFORCE(DescriptorMathcer). Then when I want to get good_matches from matches found, it doesn't return any match, because it doesn't satisfied the if clause condition. for better understanding the question look to code below:

        double max_dist = 0, min_dist = 100;

        DMatch[] _matches = matches.toArray();

        for (int i = 0; i < descriptors_object.rows(); i++) {
            double dist = _matches[i].distance;
            if (dist < min_dist) {
                min_dist = dist;
            }
            if (dist > max_dist) {
                max_dist = dist;
            }
        }

In the array above (_matches) there is one element which is 0, so min_dist becomes 0, then in the following loop

        List<DMatch> good_matches = new ArrayList<>();
        for (int i = 0; i < descriptors_object.rows(); i++) {
            if (_matches[i].distance < 3 * min_dist) {
               good_matches.add(_matches[i]);
            }
        }

the condation inside the if clause will not be satisfied because (3*0) always return 0, then the good_matches list is empty.

I have googled and also saw the OpenCV examples all of them was the same as code above. Is there any problem in the code, or is there any better way to find good matches. If anyone knows then please let me know. Thanks in advance!

0

There are 0 answers