Android opencv中两个图像之间的相似度

Android opencv中两个图像之间的相似度,android,opencv,orb,Android,Opencv,Orb,我试图计算两幅图像之间的相似度,但每次都是0 这是我的代码: public class TemplateMatching{ static void analyze(Mat image, MatOfKeyPoint keypoints, Mat descriptors){ detector.detect(image, keypoints); extractor.compute(image, keypoints, descriptors); } static FeatureDete

我试图计算两幅图像之间的相似度,但每次都是0

这是我的代码:

public class  TemplateMatching{
static void analyze(Mat image, MatOfKeyPoint keypoints, Mat descriptors){
    detector.detect(image, keypoints);
    extractor.compute(image, keypoints, descriptors);
}
static FeatureDetector detector= FeatureDetector.create(FeatureDetector.ORB);
static DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.BRIEF);           
final static DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);
static void ana(Mat image, MatOfKeyPoint keypoints, Mat descriptors){
    detector.detect(image, keypoints);
    extractor.compute(image, keypoints, descriptors);
}
static MatOfDMatch filterMatchesByDistance(MatOfDMatch matches){
    List<DMatch> matches_original = matches.toList();
    List<DMatch> matches_filtered = new ArrayList<DMatch>();

    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 < matches_original.size(); i++) {
        DMatch d = matches_original.get(i); 
        if (Math.abs(d.distance) <= DIST_LIMIT) {
            matches_filtered.add(d);                
        }
    }
    Log.d("DISTFILTER", "FIL SIZE:" + matches_filtered.size() + "");

    MatOfDMatch mat = new MatOfDMatch();
    mat.fromList(matches_filtered);
    return mat;
}
public int  comparer(Mat frame,Mat test) {
    // Info to store analysis stats
    int distance=0;
    MatOfKeyPoint keypoints_o = new MatOfKeyPoint();
    MatOfKeyPoint keypoints_t = new MatOfKeyPoint();
    Mat descriptors_o = new Mat();
    Mat descriptors_t = new Mat();
    // Detect key points and compute descriptors for inputFrame


    ana(frame, keypoints_o, descriptors_o);
    ana(test, keypoints_t, descriptors_t);
    // Compute matches
    MatOfDMatch matches = new MatOfDMatch();
    matcher.match(descriptors_o, descriptors_t, matches);
    // Filter matches by distance
    MatOfDMatch filtered = filterMatchesByDistance(matches);
    // If count of matches is OK, apply homography check
    distance = (int) filtered.size().height;

        return (distance);

}

每次的距离都是0。如果我给相同的图像,它也给我0表示距离

除了代码之外,你能简单描述一下你的算法吗?我在项目中使用的图像匹配器最多都是相同的代码,但它不适合我