Question

My project is herbs recognition based on android. I use ORB to get keypoints, features, and matching the features.

I want to use this algorithm:

  1. I use 4 reference image, and matching their features image1 to image1, 1-2, 1-3, 1-4, 2-3, 3,4.
  2. Then I store the minimum and maximum distance to database as a threshold. (minimum threshold = total minimum/6)
  3. When I recognize the new image, I compare that new minimum and maximum distance with in database. But I don't know how to do that.

{

for (j=MinID; j<=MaxID; j++){
                        MatOfDMatch matches = DetectUtility.match(features, matFromJson(DB.GetORBFitur(j)));
                        List<DMatch> matchesList = matches.toList();
                        Double max_dist = 0.0;
                        Double min_dist = 100.0;
                        for (int i = 0; i < matchesList.size(); i++){
                            Double dist = (double) matchesList.get(i).distance;
                            if (dist < min_dist && dist != 0){
                                min_dist = dist;
                            }
                            if (dist > max_dist){
                                max_dist = dist;
                            }
                        }

From this site, I get this code:

//-- Draw only "good" matches (i.e. whose distance is less than 3*min_dist )
std::vector< DMatch > good_matches;

for( int i = 0; i < descriptors_object.rows; i++ )
{ if( matches[i].distance < 3*min_dist )
 { good_matches.push_back( matches[i]); }
}   

How to get that magic number 3? and what must I do to the maximum distance?

The algoritma that I want to use, I used before on using Invariant Moment, and City Block Distance to matching the image with the smallest distance.

Was it helpful?

Solution

I don`t know either. Distance is measure of the feature point similarity, less is better. The original ORB paper (fig. 5, below) shows distribution of the distances for good and bad matches. One can surely says that "good" distance threshold would be around 64. Distance distribution for ORB

So more correct is :

double dist_th = 64;
for( int i = 0; i < descriptors_object.rows; i++ )
{ if( matches[i].distance < dist_th )
 { good_matches.push_back( matches[i]); }
} 

And then you still have to use RANSAC to filter inconsistent matches. So, the simplest solution is to do match you query image with all 4 database images.

But I`d advise you to use some classifier, not just matching. See this guy approach (it works, I know him) - http://cmp.felk.cvut.cz/~sulcmila/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top