Как проверить, похожи ли два изображения или нет, используя openCV в java?

Мне нужно проверить, являются ли два изображения похожими или нет в java, используя OpenCV, я использую OpenCV для этого и используя ORB

Вот мой основной класс

System.out.println("Welcome to OpenCV " + Core.VERSION);
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);());
System.out.println(System.getProperty("user.dir"));
File f1 = new File(System.getProperty("user.dir") + "\\test.jpg");
File f2 = new File(System.getProperty("user.dir") + "\\test2.jpg");
MatchingDemo2 m = new MatchingDemo2();
m.mth(f1.getAbsolutePath(), f2.getAbsolutePath());

И вот мой файл MatchingDemo2.java

public class MatchingDemo2 {

public void mth(String inFile, String templateFile){
        FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB);
       //Create descriptors

        //first image
       // generate descriptors

        //second image
       // generate descriptors



        System.out.println("size " + matches.size());
        //HOW DO I KNOW IF IMAGES MATCHED OR NOT ????

        //THIS CODE IS FOR CONNECTIONS BUT I AM NOT ABLE TO DO IT
        //feature and connection colors
        Scalar RED = new Scalar(255,0,0);
        Scalar GREEN = new Scalar(0,255,0);
        //output image
        Mat outputImg = new Mat();
        MatOfByte drawnMatches = new MatOfByte();
        //this will draw all matches, works fine
        Features2d.drawMatches(img1, keypoints1, img2, keypoints2, matches, 
                outputImg, GREEN, RED,  drawnMatches, Features2d.NOT_DRAW_SINGLE_POINTS);
        int DIST_LIMIT = 80;
        List<DMatch> matchList = matches.toList();
        List<DMatch> matches_final = new ArrayList<DMatch>();
        for(int i=0; i<matchList.size(); i++){
            if(matchList.get(i).distance <= DIST_LIMIT){
                matches_final.add(matches.toList().get(i));
            } 
        }

        MatOfDMatch matches_final_mat = new MatOfDMatch();
        matches_final_mat.fromList(matches_final);
        for(int i=0; i< matches_final.size(); i++){
            System.out.println("Good Matchs "+ matches_final.get(i));
        }
}
}

Но когда я проверяю "Хорошие совпадения", я получаю это

 size 1x328
 Good Matchs DMatch [queryIdx=0, trainIdx=93, imgIdx=0, distance=52.0]
 Good Matchs DMatch [queryIdx=1, trainIdx=173, imgIdx=0, distance=57.0]
 Good Matchs DMatch [queryIdx=2, trainIdx=92, imgIdx=0, distance=53.0]
 Good Matchs DMatch [queryIdx=3, trainIdx=80, imgIdx=0, distance=26.0]
 Good Matchs DMatch [queryIdx=5, trainIdx=164, imgIdx=0, distance=40.0]
 Good Matchs DMatch [queryIdx=6, trainIdx=228, imgIdx=0, distance=53.0]
 Good Matchs DMatch [queryIdx=7, trainIdx=179, imgIdx=0, distance=14.0]
 Good Matchs DMatch [queryIdx=8, trainIdx=78, imgIdx=0, distance=61.0]
 Good Matchs DMatch [queryIdx=9, trainIdx=166, imgIdx=0, distance=69.0]
 Good Matchs DMatch [queryIdx=10, trainIdx=74, imgIdx=0, distance=65.0]
 Good Matchs DMatch [queryIdx=11, trainIdx=245, imgIdx=0, distance=38.0]
 Good Matchs DMatch [queryIdx=12, trainIdx=120, imgIdx=0, distance=66.0]
 Good Matchs DMatch [queryIdx=13, trainIdx=244, imgIdx=0, distance=41.0]
 Good Matchs DMatch [queryIdx=14, trainIdx=67, imgIdx=0, distance=50.0]
 Good Matchs DMatch [queryIdx=15, trainIdx=185, imgIdx=0, distance=55.0]
 Good Matchs DMatch [queryIdx=16, trainIdx=97, imgIdx=0, distance=21.0]
 Good Matchs DMatch [queryIdx=17, trainIdx=172, imgIdx=0, distance=67.0]
 Good Matchs DMatch [queryIdx=18, trainIdx=354, imgIdx=0, distance=67.0]
 Good Matchs DMatch [queryIdx=19, trainIdx=302, imgIdx=0, distance=53.0]
 Good Matchs DMatch [queryIdx=20, trainIdx=176, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=21, trainIdx=60, imgIdx=0, distance=66.0]
 Good Matchs DMatch [queryIdx=22, trainIdx=72, imgIdx=0, distance=62.0]
 Good Matchs DMatch [queryIdx=23, trainIdx=63, imgIdx=0, distance=54.0]
 Good Matchs DMatch [queryIdx=24, trainIdx=176, imgIdx=0, distance=63.0]
 Good Matchs DMatch [queryIdx=25, trainIdx=49, imgIdx=0, distance=58.0]
 Good Matchs DMatch [queryIdx=26, trainIdx=77, imgIdx=0, distance=52.0]
 Good Matchs DMatch [queryIdx=27, trainIdx=302, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=28, trainIdx=265, imgIdx=0, distance=71.0]
 Good Matchs DMatch [queryIdx=29, trainIdx=67, imgIdx=0, distance=49.0]
 Good Matchs DMatch [queryIdx=30, trainIdx=302, imgIdx=0, distance=64.0]
 Good Matchs DMatch [queryIdx=31, trainIdx=265, imgIdx=0, distance=65.0]
 Good Matchs DMatch [queryIdx=32, trainIdx=73, imgIdx=0, distance=73.0]
 Good Matchs DMatch [queryIdx=33, trainIdx=67, imgIdx=0, distance=55.0]
 Good Matchs DMatch [queryIdx=34, trainIdx=283, imgIdx=0, distance=63.0]
 Good Matchs DMatch [queryIdx=35, trainIdx=145, imgIdx=0, distance=60.0]
 Good Matchs DMatch [queryIdx=36, trainIdx=71, imgIdx=0, distance=54.0]
 Good Matchs DMatch [queryIdx=37, trainIdx=167, imgIdx=0, distance=67.0]
 Good Matchs DMatch [queryIdx=38, trainIdx=94, imgIdx=0, distance=60.0]
 Good Matchs DMatch [queryIdx=39, trainIdx=88, imgIdx=0, distance=68.0]
 Good Matchs DMatch [queryIdx=40, trainIdx=88, imgIdx=0, distance=69.0]
 Good Matchs DMatch [queryIdx=41, trainIdx=179, imgIdx=0, distance=28.0]
 Good Matchs DMatch [queryIdx=42, trainIdx=64, imgIdx=0, distance=61.0]
 Good Matchs DMatch [queryIdx=43, trainIdx=223, imgIdx=0, distance=71.0]
 Good Matchs DMatch [queryIdx=44, trainIdx=80, imgIdx=0, distance=30.0]
 Good Matchs DMatch [queryIdx=45, trainIdx=196, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=46, trainIdx=52, imgIdx=0, distance=65.0]
 Good Matchs DMatch [queryIdx=47, trainIdx=93, imgIdx=0, distance=60.0]
 Good Matchs DMatch [queryIdx=48, trainIdx=187, imgIdx=0, distance=49.0]
 Good Matchs DMatch [queryIdx=49, trainIdx=179, imgIdx=0, distance=50.0]
 Good Matchs DMatch [queryIdx=50, trainIdx=283, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=51, trainIdx=171, imgIdx=0, distance=61.0]
 Good Matchs DMatch [queryIdx=52, trainIdx=302, imgIdx=0, distance=60.0]
 Good Matchs DMatch [queryIdx=53, trainIdx=67, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=54, trainIdx=15, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=55, trainIdx=173, imgIdx=0, distance=66.0]
 Good Matchs DMatch [queryIdx=56, trainIdx=302, imgIdx=0, distance=56.0]
 Good Matchs DMatch [queryIdx=57, trainIdx=47, imgIdx=0, distance=56.0]
 Good Matchs DMatch [queryIdx=58, trainIdx=187, imgIdx=0, distance=58.0]
 Good Matchs DMatch [queryIdx=59, trainIdx=344, imgIdx=0, distance=64.0]
 Good Matchs DMatch [queryIdx=60, trainIdx=164, imgIdx=0, distance=65.0]
 Good Matchs DMatch [queryIdx=61, trainIdx=125, imgIdx=0, distance=50.0]
 Good Matchs DMatch [queryIdx=62, trainIdx=77, imgIdx=0, distance=72.0]
 Good Matchs DMatch [queryIdx=63, trainIdx=22, imgIdx=0, distance=79.0]
 Good Matchs DMatch [queryIdx=64, trainIdx=82, imgIdx=0, distance=69.0]
 Good Matchs DMatch [queryIdx=65, trainIdx=93, imgIdx=0, distance=63.0]
 Good Matchs DMatch [queryIdx=66, trainIdx=241, imgIdx=0, distance=35.0]
 Good Matchs DMatch [queryIdx=67, trainIdx=80, imgIdx=0, distance=18.0]
 Good Matchs DMatch [queryIdx=68, trainIdx=179, imgIdx=0, distance=20.0]
 Good Matchs DMatch [queryIdx=69, trainIdx=242, imgIdx=0, distance=50.0]
 Good Matchs DMatch [queryIdx=70, trainIdx=80, imgIdx=0, distance=22.0]
 Good Matchs DMatch [queryIdx=71, trainIdx=179, imgIdx=0, distance=19.0]
 Good Matchs DMatch [queryIdx=72, trainIdx=92, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=73, trainIdx=94, imgIdx=0, distance=56.0]
 Good Matchs DMatch [queryIdx=74, trainIdx=173, imgIdx=0, distance=49.0]
 Good Matchs DMatch [queryIdx=75, trainIdx=94, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=76, trainIdx=94, imgIdx=0, distance=48.0]
 Good Matchs DMatch [queryIdx=77, trainIdx=92, imgIdx=0, distance=52.0]
 Good Matchs DMatch [queryIdx=78, trainIdx=80, imgIdx=0, distance=20.0]
 Good Matchs DMatch [queryIdx=80, trainIdx=119, imgIdx=0, distance=61.0]
 Good Matchs DMatch [queryIdx=81, trainIdx=228, imgIdx=0, distance=47.0]
 Good Matchs DMatch [queryIdx=82, trainIdx=179, imgIdx=0, distance=14.0]
 Good Matchs DMatch [queryIdx=83, trainIdx=227, imgIdx=0, distance=52.0]
 Good Matchs DMatch [queryIdx=84, trainIdx=84, imgIdx=0, distance=57.0]
 Good Matchs DMatch [queryIdx=85, trainIdx=245, imgIdx=0, distance=40.0]
 Good Matchs DMatch [queryIdx=86, trainIdx=58, imgIdx=0, distance=64.0]
 Good Matchs DMatch [queryIdx=87, trainIdx=14, imgIdx=0, distance=62.0]
 Good Matchs DMatch [queryIdx=88, trainIdx=187, imgIdx=0, distance=61.0]
 Good Matchs DMatch [queryIdx=89, trainIdx=185, imgIdx=0, distance=57.0]
 Good Matchs DMatch [queryIdx=90, trainIdx=178, imgIdx=0, distance=25.0]
 Good Matchs DMatch [queryIdx=91, trainIdx=220, imgIdx=0, distance=56.0]
 Good Matchs DMatch [queryIdx=92, trainIdx=205, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=93, trainIdx=60, imgIdx=0, distance=61.0]
 Good Matchs DMatch [queryIdx=94, trainIdx=44, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=95, trainIdx=16, imgIdx=0, distance=72.0]
 Good Matchs DMatch [queryIdx=96, trainIdx=157, imgIdx=0, distance=63.0]
 Good Matchs DMatch [queryIdx=97, trainIdx=135, imgIdx=0, distance=52.0]
 Good Matchs DMatch [queryIdx=98, trainIdx=60, imgIdx=0, distance=61.0]
 Good Matchs DMatch [queryIdx=99, trainIdx=344, imgIdx=0, distance=60.0]
 Good Matchs DMatch [queryIdx=100, trainIdx=77, imgIdx=0, distance=67.0]
 Good Matchs DMatch [queryIdx=101, trainIdx=95, imgIdx=0, distance=76.0]
 Good Matchs DMatch [queryIdx=102, trainIdx=72, imgIdx=0, distance=45.0]
 Good Matchs DMatch [queryIdx=103, trainIdx=134, imgIdx=0, distance=70.0]
 Good Matchs DMatch [queryIdx=104, trainIdx=154, imgIdx=0, distance=54.0]
 Good Matchs DMatch [queryIdx=105, trainIdx=208, imgIdx=0, distance=77.0]
 Good Matchs DMatch [queryIdx=106, trainIdx=73, imgIdx=0, distance=79.0]
 Good Matchs DMatch [queryIdx=107, trainIdx=72, imgIdx=0, distance=61.0]
 Good Matchs DMatch [queryIdx=108, trainIdx=64, imgIdx=0, distance=73.0]
 Good Matchs DMatch [queryIdx=109, trainIdx=72, imgIdx=0, distance=63.0]
 Good Matchs DMatch [queryIdx=110, trainIdx=365, imgIdx=0, distance=66.0]
 Good Matchs DMatch [queryIdx=111, trainIdx=148, imgIdx=0, distance=64.0]
 Good Matchs DMatch [queryIdx=112, trainIdx=81, imgIdx=0, distance=42.0]
 Good Matchs DMatch [queryIdx=113, trainIdx=56, imgIdx=0, distance=62.0]
 Good Matchs DMatch [queryIdx=114, trainIdx=162, imgIdx=0, distance=48.0]
 Good Matchs DMatch [queryIdx=115, trainIdx=56, imgIdx=0, distance=56.0]
 Good Matchs DMatch [queryIdx=116, trainIdx=120, imgIdx=0, distance=58.0]
 Good Matchs DMatch [queryIdx=117, trainIdx=72, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=118, trainIdx=92, imgIdx=0, distance=63.0]
 Good Matchs DMatch [queryIdx=119, trainIdx=131, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=120, trainIdx=72, imgIdx=0, distance=46.0]
 Good Matchs DMatch [queryIdx=121, trainIdx=74, imgIdx=0, distance=78.0]
 Good Matchs DMatch [queryIdx=122, trainIdx=94, imgIdx=0, distance=56.0]
 Good Matchs DMatch [queryIdx=123, trainIdx=72, imgIdx=0, distance=52.0]
 Good Matchs DMatch [queryIdx=124, trainIdx=134, imgIdx=0, distance=71.0]
 Good Matchs DMatch [queryIdx=125, trainIdx=72, imgIdx=0, distance=46.0]
 Good Matchs DMatch [queryIdx=126, trainIdx=15, imgIdx=0, distance=73.0]
 Good Matchs DMatch [queryIdx=127, trainIdx=72, imgIdx=0, distance=50.0]
 Good Matchs DMatch [queryIdx=128, trainIdx=93, imgIdx=0, distance=56.0]
 Good Matchs DMatch [queryIdx=129, trainIdx=68, imgIdx=0, distance=46.0]
 Good Matchs DMatch [queryIdx=130, trainIdx=205, imgIdx=0, distance=65.0]
 Good Matchs DMatch [queryIdx=131, trainIdx=187, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=132, trainIdx=72, imgIdx=0, distance=47.0]
 Good Matchs DMatch [queryIdx=133, trainIdx=220, imgIdx=0, distance=57.0]
 Good Matchs DMatch [queryIdx=134, trainIdx=289, imgIdx=0, distance=60.0]
 Good Matchs DMatch [queryIdx=135, trainIdx=82, imgIdx=0, distance=65.0]
 Good Matchs DMatch [queryIdx=136, trainIdx=93, imgIdx=0, distance=53.0]
 Good Matchs DMatch [queryIdx=137, trainIdx=244, imgIdx=0, distance=18.0]
 Good Matchs DMatch [queryIdx=138, trainIdx=244, imgIdx=0, distance=25.0]
 Good Matchs DMatch [queryIdx=139, trainIdx=92, imgIdx=0, distance=66.0]
 Good Matchs DMatch [queryIdx=140, trainIdx=244, imgIdx=0, distance=20.0]
 Good Matchs DMatch [queryIdx=141, trainIdx=93, imgIdx=0, distance=45.0]
 Good Matchs DMatch [queryIdx=142, trainIdx=93, imgIdx=0, distance=51.0]
 Good Matchs DMatch [queryIdx=143, trainIdx=94, imgIdx=0, distance=51.0]
 Good Matchs DMatch [queryIdx=144, trainIdx=94, imgIdx=0, distance=40.0]
 Good Matchs DMatch [queryIdx=145, trainIdx=93, imgIdx=0, distance=47.0]
 Good Matchs DMatch [queryIdx=146, trainIdx=244, imgIdx=0, distance=28.0]
 Good Matchs DMatch [queryIdx=147, trainIdx=172, imgIdx=0, distance=77.0]
 Good Matchs DMatch [queryIdx=148, trainIdx=170, imgIdx=0, distance=72.0]
 Good Matchs DMatch [queryIdx=149, trainIdx=261, imgIdx=0, distance=72.0]
 Good Matchs DMatch [queryIdx=150, trainIdx=228, imgIdx=0, distance=55.0]
 Good Matchs DMatch [queryIdx=151, trainIdx=179, imgIdx=0, distance=19.0]
 Good Matchs DMatch [queryIdx=152, trainIdx=227, imgIdx=0, distance=60.0]
 Good Matchs DMatch [queryIdx=153, trainIdx=107, imgIdx=0, distance=56.0]
 Good Matchs DMatch [queryIdx=154, trainIdx=174, imgIdx=0, distance=41.0]
 Good Matchs DMatch [queryIdx=155, trainIdx=283, imgIdx=0, distance=76.0]
 Good Matchs DMatch [queryIdx=156, trainIdx=254, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=157, trainIdx=185, imgIdx=0, distance=51.0]
 Good Matchs DMatch [queryIdx=158, trainIdx=178, imgIdx=0, distance=30.0]
 Good Matchs DMatch [queryIdx=159, trainIdx=278, imgIdx=0, distance=53.0]
 Good Matchs DMatch [queryIdx=160, trainIdx=91, imgIdx=0, distance=62.0]
 Good Matchs DMatch [queryIdx=161, trainIdx=148, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=162, trainIdx=157, imgIdx=0, distance=63.0]
 Good Matchs DMatch [queryIdx=163, trainIdx=373, imgIdx=0, distance=73.0]
 Good Matchs DMatch [queryIdx=164, trainIdx=226, imgIdx=0, distance=48.0]
 Good Matchs DMatch [queryIdx=165, trainIdx=278, imgIdx=0, distance=64.0]
 Good Matchs DMatch [queryIdx=166, trainIdx=283, imgIdx=0, distance=62.0]
 Good Matchs DMatch [queryIdx=167, trainIdx=196, imgIdx=0, distance=64.0]
 Good Matchs DMatch [queryIdx=168, trainIdx=344, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=169, trainIdx=157, imgIdx=0, distance=53.0]
 Good Matchs DMatch [queryIdx=170, trainIdx=144, imgIdx=0, distance=79.0]
 Good Matchs DMatch [queryIdx=171, trainIdx=154, imgIdx=0, distance=61.0]
 Good Matchs DMatch [queryIdx=172, trainIdx=211, imgIdx=0, distance=75.0]
 Good Matchs DMatch [queryIdx=173, trainIdx=279, imgIdx=0, distance=64.0]
 Good Matchs DMatch [queryIdx=174, trainIdx=211, imgIdx=0, distance=79.0]
 Good Matchs DMatch [queryIdx=175, trainIdx=220, imgIdx=0, distance=68.0]
 Good Matchs DMatch [queryIdx=176, trainIdx=218, imgIdx=0, distance=45.0]
 Good Matchs DMatch [queryIdx=177, trainIdx=289, imgIdx=0, distance=75.0]
 Good Matchs DMatch [queryIdx=178, trainIdx=223, imgIdx=0, distance=63.0]
 Good Matchs DMatch [queryIdx=179, trainIdx=57, imgIdx=0, distance=65.0]
 Good Matchs DMatch [queryIdx=180, trainIdx=36, imgIdx=0, distance=73.0]
 Good Matchs DMatch [queryIdx=181, trainIdx=111, imgIdx=0, distance=72.0]
 Good Matchs DMatch [queryIdx=182, trainIdx=93, imgIdx=0, distance=65.0]
 Good Matchs DMatch [queryIdx=183, trainIdx=137, imgIdx=0, distance=63.0]
 Good Matchs DMatch [queryIdx=184, trainIdx=157, imgIdx=0, distance=60.0]
 Good Matchs DMatch [queryIdx=185, trainIdx=72, imgIdx=0, distance=61.0]
 Good Matchs DMatch [queryIdx=186, trainIdx=172, imgIdx=0, distance=47.0]
 Good Matchs DMatch [queryIdx=187, trainIdx=279, imgIdx=0, distance=69.0]
 Good Matchs DMatch [queryIdx=188, trainIdx=72, imgIdx=0, distance=55.0]
 Good Matchs DMatch [queryIdx=189, trainIdx=96, imgIdx=0, distance=61.0]
 Good Matchs DMatch [queryIdx=190, trainIdx=220, imgIdx=0, distance=68.0]
 Good Matchs DMatch [queryIdx=191, trainIdx=93, imgIdx=0, distance=48.0]
 Good Matchs DMatch [queryIdx=192, trainIdx=279, imgIdx=0, distance=54.0]
 Good Matchs DMatch [queryIdx=193, trainIdx=157, imgIdx=0, distance=54.0]
 Good Matchs DMatch [queryIdx=194, trainIdx=91, imgIdx=0, distance=65.0]
 Good Matchs DMatch [queryIdx=195, trainIdx=278, imgIdx=0, distance=66.0]
 Good Matchs DMatch [queryIdx=196, trainIdx=220, imgIdx=0, distance=57.0]
 Good Matchs DMatch [queryIdx=197, trainIdx=74, imgIdx=0, distance=63.0]
 Good Matchs DMatch [queryIdx=198, trainIdx=93, imgIdx=0, distance=34.0]
 Good Matchs DMatch [queryIdx=199, trainIdx=81, imgIdx=0, distance=53.0]
 Good Matchs DMatch [queryIdx=200, trainIdx=93, imgIdx=0, distance=45.0]
 Good Matchs DMatch [queryIdx=201, trainIdx=90, imgIdx=0, distance=52.0]
 Good Matchs DMatch [queryIdx=202, trainIdx=93, imgIdx=0, distance=52.0]
 Good Matchs DMatch [queryIdx=203, trainIdx=94, imgIdx=0, distance=42.0]
 Good Matchs DMatch [queryIdx=204, trainIdx=93, imgIdx=0, distance=35.0]
 Good Matchs DMatch [queryIdx=205, trainIdx=94, imgIdx=0, distance=44.0]
 Good Matchs DMatch [queryIdx=206, trainIdx=90, imgIdx=0, distance=72.0]
 Good Matchs DMatch [queryIdx=207, trainIdx=179, imgIdx=0, distance=54.0]
 Good Matchs DMatch [queryIdx=208, trainIdx=92, imgIdx=0, distance=48.0]
 Good Matchs DMatch [queryIdx=209, trainIdx=91, imgIdx=0, distance=61.0]
 Good Matchs DMatch [queryIdx=210, trainIdx=119, imgIdx=0, distance=77.0]
 Good Matchs DMatch [queryIdx=211, trainIdx=227, imgIdx=0, distance=66.0]
 Good Matchs DMatch [queryIdx=212, trainIdx=186, imgIdx=0, distance=56.0]
 Good Matchs DMatch [queryIdx=213, trainIdx=96, imgIdx=0, distance=69.0]
 Good Matchs DMatch [queryIdx=214, trainIdx=77, imgIdx=0, distance=52.0]
 Good Matchs DMatch [queryIdx=215, trainIdx=372, imgIdx=0, distance=67.0]
 Good Matchs DMatch [queryIdx=216, trainIdx=334, imgIdx=0, distance=69.0]
 Good Matchs DMatch [queryIdx=217, trainIdx=278, imgIdx=0, distance=67.0]
 Good Matchs DMatch [queryIdx=218, trainIdx=325, imgIdx=0, distance=61.0]
 Good Matchs DMatch [queryIdx=219, trainIdx=188, imgIdx=0, distance=60.0]
 Good Matchs DMatch [queryIdx=220, trainIdx=340, imgIdx=0, distance=56.0]
 Good Matchs DMatch [queryIdx=221, trainIdx=72, imgIdx=0, distance=64.0]
 Good Matchs DMatch [queryIdx=222, trainIdx=278, imgIdx=0, distance=69.0]
 Good Matchs DMatch [queryIdx=223, trainIdx=221, imgIdx=0, distance=72.0]
 Good Matchs DMatch [queryIdx=224, trainIdx=339, imgIdx=0, distance=74.0]
 Good Matchs DMatch [queryIdx=225, trainIdx=155, imgIdx=0, distance=66.0]
 Good Matchs DMatch [queryIdx=226, trainIdx=278, imgIdx=0, distance=56.0]
 Good Matchs DMatch [queryIdx=227, trainIdx=165, imgIdx=0, distance=78.0]
 Good Matchs DMatch [queryIdx=228, trainIdx=279, imgIdx=0, distance=71.0]
 Good Matchs DMatch [queryIdx=229, trainIdx=355, imgIdx=0, distance=65.0]
 Good Matchs DMatch [queryIdx=231, trainIdx=69, imgIdx=0, distance=80.0]
 Good Matchs DMatch [queryIdx=232, trainIdx=278, imgIdx=0, distance=65.0]
 Good Matchs DMatch [queryIdx=233, trainIdx=65, imgIdx=0, distance=71.0]
 Good Matchs DMatch [queryIdx=234, trainIdx=93, imgIdx=0, distance=79.0]
 Good Matchs DMatch [queryIdx=235, trainIdx=203, imgIdx=0, distance=78.0]
 Good Matchs DMatch [queryIdx=236, trainIdx=159, imgIdx=0, distance=70.0]
 Good Matchs DMatch [queryIdx=237, trainIdx=93, imgIdx=0, distance=45.0]
 Good Matchs DMatch [queryIdx=238, trainIdx=172, imgIdx=0, distance=58.0]
 Good Matchs DMatch [queryIdx=239, trainIdx=374, imgIdx=0, distance=67.0]
 Good Matchs DMatch [queryIdx=240, trainIdx=278, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=241, trainIdx=223, imgIdx=0, distance=55.0]
 Good Matchs DMatch [queryIdx=242, trainIdx=365, imgIdx=0, distance=58.0]
 Good Matchs DMatch [queryIdx=243, trainIdx=91, imgIdx=0, distance=62.0]
 Good Matchs DMatch [queryIdx=244, trainIdx=238, imgIdx=0, distance=57.0]
 Good Matchs DMatch [queryIdx=245, trainIdx=299, imgIdx=0, distance=62.0]
 Good Matchs DMatch [queryIdx=246, trainIdx=289, imgIdx=0, distance=63.0]
 Good Matchs DMatch [queryIdx=247, trainIdx=93, imgIdx=0, distance=41.0]
 Good Matchs DMatch [queryIdx=249, trainIdx=5, imgIdx=0, distance=56.0]
 Good Matchs DMatch [queryIdx=250, trainIdx=93, imgIdx=0, distance=53.0]
 Good Matchs DMatch [queryIdx=251, trainIdx=93, imgIdx=0, distance=34.0]
 Good Matchs DMatch [queryIdx=252, trainIdx=97, imgIdx=0, distance=34.0]
 Good Matchs DMatch [queryIdx=253, trainIdx=93, imgIdx=0, distance=37.0]
 Good Matchs DMatch [queryIdx=254, trainIdx=174, imgIdx=0, distance=55.0]
 Good Matchs DMatch [queryIdx=255, trainIdx=91, imgIdx=0, distance=72.0]
 Good Matchs DMatch [queryIdx=256, trainIdx=81, imgIdx=0, distance=59.0]
 Good Matchs DMatch [queryIdx=257, trainIdx=92, imgIdx=0, distance=57.0]
 Good Matchs DMatch [queryIdx=258, trainIdx=212, imgIdx=0, distance=76.0]
 Good Matchs DMatch [queryIdx=259, trainIdx=119, imgIdx=0, distance=67.0]
 Good Matchs DMatch [queryIdx=260, trainIdx=228, imgIdx=0, distance=73.0]
 Good Matchs DMatch [queryIdx=261, trainIdx=119, imgIdx=0, distance=68.0]
 Good Matchs DMatch [queryIdx=263, trainIdx=266, imgIdx=0, distance=74.0]
 Good Matchs DMatch [queryIdx=264, trainIdx=319, imgIdx=0, distance=72.0]
 Good Matchs DMatch [queryIdx=265, trainIdx=157, imgIdx=0, distance=76.0]
 Good Matchs DMatch [queryIdx=266, trainIdx=365, imgIdx=0, distance=65.0]
 Good Matchs DMatch [queryIdx=267, trainIdx=341, imgIdx=0, distance=76.0]
 Good Matchs DMatch [queryIdx=268, trainIdx=303, imgIdx=0, distance=63.0]
 Good Matchs DMatch [queryIdx=269, trainIdx=313, imgIdx=0, distance=69.0]
 Good Matchs DMatch [queryIdx=271, trainIdx=350, imgIdx=0, distance=62.0]
 Good Matchs DMatch [queryIdx=272, trainIdx=313, imgIdx=0, distance=68.0]
 Good Matchs DMatch [queryIdx=278, trainIdx=267, imgIdx=0, distance=69.0]
 Good Matchs DMatch [queryIdx=280, trainIdx=223, imgIdx=0, distance=71.0]
 Good Matchs DMatch [queryIdx=281, trainIdx=267, imgIdx=0, distance=71.0]
 Good Matchs DMatch [queryIdx=283, trainIdx=334, imgIdx=0, distance=72.0]
 Good Matchs DMatch [queryIdx=284, trainIdx=313, imgIdx=0, distance=63.0]
 Good Matchs DMatch [queryIdx=285, trainIdx=78, imgIdx=0, distance=76.0]
 Good Matchs DMatch [queryIdx=286, trainIdx=312, imgIdx=0, distance=73.0]
 Good Matchs DMatch [queryIdx=287, trainIdx=271, imgIdx=0, distance=68.0]
 Good Matchs DMatch [queryIdx=288, trainIdx=170, imgIdx=0, distance=64.0]
 Good Matchs DMatch [queryIdx=289, trainIdx=278, imgIdx=0, distance=64.0]
 Good Matchs DMatch [queryIdx=290, trainIdx=282, imgIdx=0, distance=70.0]
 Good Matchs DMatch [queryIdx=291, trainIdx=91, imgIdx=0, distance=65.0]
 Good Matchs DMatch [queryIdx=292, trainIdx=334, imgIdx=0, distance=67.0]
 Good Matchs DMatch [queryIdx=293, trainIdx=80, imgIdx=0, distance=72.0]
 Good Matchs DMatch [queryIdx=294, trainIdx=92, imgIdx=0, distance=47.0]
 Good Matchs DMatch [queryIdx=295, trainIdx=301, imgIdx=0, distance=44.0]
 Good Matchs DMatch [queryIdx=297, trainIdx=220, imgIdx=0, distance=78.0]
 Good Matchs DMatch [queryIdx=298, trainIdx=374, imgIdx=0, distance=76.0]
 Good Matchs DMatch [queryIdx=300, trainIdx=329, imgIdx=0, distance=74.0]
 Good Matchs DMatch [queryIdx=302, trainIdx=285, imgIdx=0, distance=77.0]
 Good Matchs DMatch [queryIdx=305, trainIdx=271, imgIdx=0, distance=80.0]
 Good Matchs DMatch [queryIdx=307, trainIdx=350, imgIdx=0, distance=76.0]
 Good Matchs DMatch [queryIdx=308, trainIdx=320, imgIdx=0, distance=71.0]
 Good Matchs DMatch [queryIdx=309, trainIdx=163, imgIdx=0, distance=76.0]
 Good Matchs DMatch [queryIdx=310, trainIdx=170, imgIdx=0, distance=73.0]
 Good Matchs DMatch [queryIdx=311, trainIdx=357, imgIdx=0, distance=65.0]
 Good Matchs DMatch [queryIdx=312, trainIdx=320, imgIdx=0, distance=62.0]
 Good Matchs DMatch [queryIdx=314, trainIdx=342, imgIdx=0, distance=75.0]
 Good Matchs DMatch [queryIdx=315, trainIdx=162, imgIdx=0, distance=72.0]
 Good Matchs DMatch [queryIdx=316, trainIdx=239, imgIdx=0, distance=74.0]
 Good Matchs DMatch [queryIdx=317, trainIdx=171, imgIdx=0, distance=56.0]
 Good Matchs DMatch [queryIdx=318, trainIdx=244, imgIdx=0, distance=61.0]
 Good Matchs DMatch [queryIdx=319, trainIdx=369, imgIdx=0, distance=77.0]
 Good Matchs DMatch [queryIdx=320, trainIdx=346, imgIdx=0, distance=67.0]
 Good Matchs DMatch [queryIdx=322, trainIdx=158, imgIdx=0, distance=78.0]
 Good Matchs DMatch [queryIdx=325, trainIdx=92, imgIdx=0, distance=73.0]
 Good Matchs DMatch [queryIdx=326, trainIdx=236, imgIdx=0, distance=76.0]
 Good Matchs DMatch [queryIdx=327, trainIdx=162, imgIdx=0, distance=70.0]

Количество совпадений, которые я получаю, одинаково для одного и того же изображения, а также для разных изображений Я действительно смущен? Можете ли вы объяснить, как сравнить два изображения и сказать, похожи они или нет, используя OpenCV

Вот несколько, которые я пытаюсь достичь

Ответ 1

Поскольку вы используете BRUTEFORCE, вы всегда получите наилучшие совпадения для всех дескрипторов ключевых слов из вашего запроса (шаблона) в вашем поезде (изображение, содержащее запрос). i.e: BRUTEFORCE-матчер всегда найдет 100% -ые совпадения (наилучшие эквивалентные ключевые точки для всех дескрипторов ключевых слов запроса в дескрипторах поездов).

Это означает, что вам нужно отфильтровать совпадения как правильные совпадения (inliers) и неправильные совпадения (outliers).

Вы можете сделать это двумя способами.

1. Расчет сопротивления

Использование расстояния, как упоминал Андрей Смородов. Вы можете использовать этот метод (Но это не всегда дает правильные результаты)

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)
        min_dist = dist;
    if (dist > max_dist)
    max_dist = dist;
}

LinkedList<DMatch> good_matches = new LinkedList<DMatch>();
for (int i = 0; i < matchesList.size(); i++)  {  
    if (matchesList.get(i).distance <= (3 * min_dist)) // change the limit as you desire
    good_matches.addLast(matchesList.get(i));
}

Маска 2.Determine

Вы можете использовать findHomography, чтобы получить маску, которая позволяет вам четко определить листы и выбросы (поскольку он учитывает, что камера позиционирует перспективу, это почти правильно)

        LinkedList<Point> objList = new LinkedList<Point>();
        LinkedList<Point> sceneList = new LinkedList<Point>();

        List<KeyPoint> keypoints_RefList = keypointsRef.toList();
        List<KeyPoint> keypoints_List = keypoints.toList();

        for (int i = 0; i < good_matches.size(); i++) {
            objList.addLast(keypoints_RefList.get(good_matches.get(i).queryIdx).pt);
            sceneList.addLast(keypoints_List.get(good_matches.get(i).trainIdx).pt);
        }                 

        MatOfPoint2f obj = new MatOfPoint2f();
        MatOfPoint2f scene = new MatOfPoint2f();

        obj.fromList(objList);  
        scene.fromList(sceneList);  

        Mat mask = new Mat();
        Mat hg = Calib3d.findHomography(obj, scene, 8, 10,  mask);

Теперь маска является необязательным выходом в findHomography, который представляет собой массив из 1 или 0 значений для каждого совпадения. Значение маски для соответствующего соответствия               1, если он является более               0, если это ошибка.

Вы можете использовать это в качестве критерия, чтобы решить, есть ли у вас почти 90% маски, чтобы быть 1, тогда вы можете иметь результат как истинный.

Я использую его для распознавания определенных объектов из фрейма камеры javascript android и получил результаты этого журнала

08-22 01:08:38.929: I/OCVSample::Activity(25799): Keypoints Size: 1x477  KeypointsRef Size : 1x165
08-22 01:08:39.049: I/OCVSample::Activity(25799): descriptor Size: 32x477  descriptorRef Size : 32x165
08-22 01:08:39.129: I/OCVSample::Activity(25799): Matches Size: 1x165
08-22 01:08:39.129: I/OCVSample::Activity(25799): matchesList Size: 165
08-22 01:08:39.139: I/OCVSample::Activity(25799): Max dist : 460.44110107421875   Min dist : 100.0
08-22 01:08:39.139: I/OCVSample::Activity(25799): good matches size: 19
08-22 01:08:39.139: I/OCVSample::Activity(25799): obj size : 1x165
08-22 01:08:39.139: I/OCVSample::Activity(25799): scene size : 1x165
08-22 01:08:40.239: I/OCVSample::Activity(25799): Homography  mask size : 1x165
08-22 01:08:40.239: I/OCVSample::Activity(25799): Homography  mask : [1; 1; 1; 1; 1; 1; 1; 0; 1; 0; 1; 1; 1; 1; 0; 1; 1; 1; 0; 1; 1; 1; 1; 0; 1; 0; 1; 1; 1; 1; 1; 1; 0; 0; 1; 1; 1; 1; 0; 1; 0; 1; 1; 1; 1; 1; 0; 1; 1; 1; 1; 1; 1; 1; 0; 1; 1; 0; 1; 0; 1; 0; 0; 1; 0; 1; 1; 1; 1; 1; 1; 1; 0; 1; 1; 1; 1; 1; 0; 1; 1; 1; 1; 0; 0; 1; 1; 0; 1; 1; 1; 1; 0; 1; 0; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 0; 1; 1; 1; 1; 0; 0; 0; 1; 0; 1; 1; 1; 1; 0; 0; 1; 1; 1; 1; 1; 0; 1; 0; 1; 1; 0; 1; 0; 1; 1; 1; 1; 1; 1; 0; 1; 1; 0; 1; 1; 1; 1; 0; 1; 1; 1; 1; 1; 1; 1; 0; 1; 1; 0; 0; 1; 1]

3. Еще один более простой подход - сравнить гистограмму этих двух изображений для этого, вы можете использовать функцию compHist(); для openCV, как показано здесь а также ссылаться на документы openCV.

Различные методы сравнения гистограммы дают выходной диапазон от 0 до 1 или выше, этот выход зависит от сходства между гистограммами. Тщательно в некоторых методах 1 есть 100% положительное совпадение и 0 в каком-либо другом методе. "Для хи-квадратного метода низкий балл представляет лучшее совпадение, чем высокий балл. Совершенное совпадение равно 0, а полное несоответствие неограниченно (в зависимости от размера гистограммы).

Остаток: - Два совершенно разных изображения могут иметь точно такое же значение гистограммы.

Советов:

1. Теперь о knnMatch просто используйте matcher.knnMatch(); и соответствующие типы данных для вывода.

2. Также в

 matcher.match(query, train, matches);

дескрипторы ключевого слова query = > для шаблона - например. мяч и

описатель поезда = > keypoint для изображения, содержащего в нем один и тот же шар. Нет дескриптора запроса меньше, чем нет дескриптора поезда, убедитесь, что вы правильно это поняли.

Теперь удачи.

Ответ 2

Поиск только для ближайшего совпадения диаграмм ключевых точек. Для разницы в измерениях вам нужно использовать (среднюю) сумму (или другую метрику) расстояний.