Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to find the parameters needed in descriptorExtractor.match(..)

i want to find the similar features in two images, i wrote the below code and followed the steps needed, but i do not know which parameters should pass to the method descripMatcher.match(par1, par2, par3)

as the docs reads, i have to specify queryDescriptors and trainDescriptors. is the queryDescriptor is the output of descriptorExtract.compute(...)?

and what is the trainDescriptors, and how can i find it.

please have a look at the code below:

code:

public static void main(String[] args) {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

                                /*Feature Detection*/
    FeatureDetector fDetect =  FeatureDetector.create(FeatureDetector.SIFT);

    MatOfKeyPoint matKeyPts_jf01 = new MatOfKeyPoint();
    fDetect.detect(path2Mat(path_jf01), matKeyPts_jf01);
    System.out.println("matKeyPts_jf01.size: " + matKeyPts_jf01.size());

    MatOfKeyPoint matKeyPts_jf01_rev = new MatOfKeyPoint();
    fDetect.detect(path2Mat(path_jf01_rev), matKeyPts_jf01_rev);
    System.out.println("matKeyPts_jf01_rev.size: " + matKeyPts_jf01_rev.size());

    Mat mat_jf01_OutPut = new Mat();
    Features2d.drawKeypoints(path2Mat(path_jf01), matKeyPts_jf01, mat_jf01_OutPut);
    Highgui.imwrite(path_jf01_DetectedOutPut, mat_jf01_OutPut);

    Mat mat_jf0_rev_OutPut = new Mat();
    Features2d.drawKeypoints(path2Mat(path_jf01_rev), matKeyPts_jf01, mat_jf0_rev_OutPut);
    Highgui.imwrite(path_jf01_rev_DetectedOutPut, mat_jf0_rev_OutPut);

                                /*DescriptorExtractor*/
    DescriptorExtractor descExtract = DescriptorExtractor.create(DescriptorExtractor.SIFT);
    Mat mat_jf01_Descriptor = new Mat();
    descExtract.compute(path2Mat(path_jf01), matKeyPts_jf01, mat_jf01_Descriptor);
    System.out.println("mat_jf01_Descriptor.size: " + mat_jf01_Descriptor.size());

    Mat mat_jf01_rev_Descriptor = new Mat();
    descExtract.compute(path2Mat(path_jf01_rev), matKeyPts_jf01_rev, mat_jf01_rev_Descriptor);
    System.out.println("mat_jf01_rev_Descriptor.size: " + mat_jf01_rev_Descriptor.size());

                                /*DescriptorMatcher*/
    MatOfDMatch matDMatch_jf01 = new MatOfDMatch();
    MatOfDMatch matDMatch_jf01_rev = new MatOfDMatch();
    DescriptorMatcher descripMatcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE);
    descripMatcher.match(queryDescriptors, trainDescriptors, matDMatch_jf01);//is queryDescriptor = mat_jf01_Descriptor
                                                                      //what is trainDescriptor

}

private static Mat path2Mat(String path2File) {
    // TODO Auto-generated method stub
    return Highgui.imread(path2File);
}
click to hide/show revision 2
retagged

updated 2015-03-29 08:43:52 -0600

berak gravatar image

how to find the parameters needed in descriptorExtractor.match(..)

i want to find the similar features in two images, i wrote the below code and followed the steps needed, but i do not know which parameters should pass to the method descripMatcher.match(par1, par2, par3)

as the docs reads, i have to specify queryDescriptors and trainDescriptors. is the queryDescriptor is the output of descriptorExtract.compute(...)?

and what is the trainDescriptors, and how can i find it.

please have a look at the code below:

code:

public static void main(String[] args) {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

                                /*Feature Detection*/
    FeatureDetector fDetect =  FeatureDetector.create(FeatureDetector.SIFT);

    MatOfKeyPoint matKeyPts_jf01 = new MatOfKeyPoint();
    fDetect.detect(path2Mat(path_jf01), matKeyPts_jf01);
    System.out.println("matKeyPts_jf01.size: " + matKeyPts_jf01.size());

    MatOfKeyPoint matKeyPts_jf01_rev = new MatOfKeyPoint();
    fDetect.detect(path2Mat(path_jf01_rev), matKeyPts_jf01_rev);
    System.out.println("matKeyPts_jf01_rev.size: " + matKeyPts_jf01_rev.size());

    Mat mat_jf01_OutPut = new Mat();
    Features2d.drawKeypoints(path2Mat(path_jf01), matKeyPts_jf01, mat_jf01_OutPut);
    Highgui.imwrite(path_jf01_DetectedOutPut, mat_jf01_OutPut);

    Mat mat_jf0_rev_OutPut = new Mat();
    Features2d.drawKeypoints(path2Mat(path_jf01_rev), matKeyPts_jf01, mat_jf0_rev_OutPut);
    Highgui.imwrite(path_jf01_rev_DetectedOutPut, mat_jf0_rev_OutPut);

                                /*DescriptorExtractor*/
    DescriptorExtractor descExtract = DescriptorExtractor.create(DescriptorExtractor.SIFT);
    Mat mat_jf01_Descriptor = new Mat();
    descExtract.compute(path2Mat(path_jf01), matKeyPts_jf01, mat_jf01_Descriptor);
    System.out.println("mat_jf01_Descriptor.size: " + mat_jf01_Descriptor.size());

    Mat mat_jf01_rev_Descriptor = new Mat();
    descExtract.compute(path2Mat(path_jf01_rev), matKeyPts_jf01_rev, mat_jf01_rev_Descriptor);
    System.out.println("mat_jf01_rev_Descriptor.size: " + mat_jf01_rev_Descriptor.size());

                                /*DescriptorMatcher*/
    MatOfDMatch matDMatch_jf01 = new MatOfDMatch();
    MatOfDMatch matDMatch_jf01_rev = new MatOfDMatch();
    DescriptorMatcher descripMatcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE);
    descripMatcher.match(queryDescriptors, trainDescriptors, matDMatch_jf01);//is queryDescriptor = mat_jf01_Descriptor
                                                                      //what is trainDescriptor

}

private static Mat path2Mat(String path2File) {
    // TODO Auto-generated method stub
    return Highgui.imread(path2File);
}