OpenCV image Comparison And Similarity in Android : <p>I'm <code>OpenCV</code> learner. I was trying Image Comparison. I have used <strong>OpenCV 2.4.13.3</strong>
I have these two images <code>1.jpg</code> and <code>cam1.jpg</code>.</p>

<p><a href="https://i.stack.imgur.com/HkVgF.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/HkVgF.jpg" alt="enter image description here"></a>  <a href="https://i.stack.imgur.com/u4TgR.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/u4TgR.jpg" alt="enter image description here"></a></p>

<p>When I use the following command in openCV</p>

<pre><code>File sdCard = Environment.getExternalStorageDirectory();
String path1, path2;
path1 = sdCard.getAbsolutePath() + "/1.jpg";
path2 = sdCard.getAbsolutePath() + "/cam1.jpg";

FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB);
DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.BRIEF);
DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);

Mat img1 = Highgui.imread(path1);
Mat img2 = Highgui.imread(path2);

Mat descriptors1 = new Mat();
MatOfKeyPoint keypoints1 = new MatOfKeyPoint();
detector.detect(img1, keypoints1);
extractor.compute(img1, keypoints1, descriptors1);

//second image
// Mat img2 = Imgcodecs.imread(path2);
Mat descriptors2 = new Mat();
MatOfKeyPoint keypoints2 = new MatOfKeyPoint();
detector.detect(img2, keypoints2);
extractor.compute(img2, keypoints2, descriptors2);


//matcher image descriptors
MatOfDMatch matches = new MatOfDMatch();
matcher.match(descriptors1,descriptors2,matches);

// Filter matches by distance
MatOfDMatch filtered = filterMatchesByDistance(matches);

int total = (int) matches.size().height;
int Match= (int) filtered.size().height;
Log.d("LOG", "total:" + total + " Match:"+Match);
</code></pre>

<p><strong>Method filterMatchesByDistance</strong></p>

<pre><code>    static MatOfDMatch filterMatchesByDistance(MatOfDMatch matches){
    List&lt;DMatch&gt; matches_original = matches.toList();
    List&lt;DMatch&gt; matches_filtered = new ArrayList&lt;DMatch&gt;();

    int DIST_LIMIT = 30;
    // Check all the matches distance and if it passes add to list of filtered matches
    Log.d("DISTFILTER", "ORG SIZE:" + matches_original.size() + "");
    for (int i = 0; i &lt; matches_original.size(); i++) {
        DMatch d = matches_original.get(i);
        if (Math.abs(d.distance) &lt;= DIST_LIMIT) {
            matches_filtered.add(d);
        }
    }
    Log.d("DISTFILTER", "FIL SIZE:" + matches_filtered.size() + "");

    MatOfDMatch mat = new MatOfDMatch();
    mat.fromList(matches_filtered);
    return mat;
}
</code></pre>

<p><strong>Log</strong></p>

<pre><code>total:122 Match:30
</code></pre>

<p>As we can see from the log match is 30.<br>
But as we can see both images have same visual element (in).<br>
How can I get match=90 using openCV?<br>
It would be great if somebody can help with code snippet.<br>
If using opencv it is not possible then what are the other 
alternatives we can look for?<br></p>
