1

I want to compare two image in percent in android , here is my codes

Mat img1 = Highgui.imread("storage/external_SD/a.png");
Mat img2 = Highgui.imread("storage/external_SD/b.png");
MatOfKeyPoint keypoints1 = new MatOfKeyPoint();
MatOfKeyPoint keypoints2 = new MatOfKeyPoint();
Mat descriptors1 = new Mat();
Mat descriptors2 = new Mat();

//Definition of ORB keypoint detector and descriptor extractors
FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB); 
DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.ORB);

//Detect keypoints
detector.detect(img1, keypoints1);
detector.detect(img2, keypoints2);  
//Extract descriptors
extractor.compute(img1, keypoints1, descriptors1);
extractor.compute(img2, keypoints2, descriptors2);

//Definition of descriptor matcher
DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);

//Match points of two images
MatOfDMatch matches = new MatOfDMatch();
matcher.match(descriptors1,descriptors2 ,matches);

For example my method out put should be :

Images is 90% same

But i dont know what should i do after matcher.match(descriptors1,descriptors2 ,matches); method, can you please advise me ?

user3187514
  • 11
  • 1
  • 2

1 Answers1

-2

As I remember method match() must return value of double or float. I did same thing with face comparison and I did (according to your case):

double value = matcher.match(descriptors1,descriptors2 ,matches);

There are 2 similar questions around this. Check it out. Must be useful. OpenCV filtering ORB matches OpenCV - Java - No match with 2 opposite images using DescriptorMatcher

Community
  • 1
  • 1
Yurets
  • 3,999
  • 17
  • 54
  • 74