opencv java api提取图片sift特征

opencv在2.4.4版本以后添加了对java的最新支持,可以利用java api了。下面就是我利用opencv的java api 提取图片的sift特征。

import org.opencv.core.Core;

import org.opencv.core.Mat;

import org.opencv.core.MatOfKeyPoint;

import org.opencv.highgui.Highgui;

import org.opencv.features2d.*;

public class ExtractSIFT

{

 public static void main( String[] args )

 {

    System.loadLibrary( Core.NATIVE_LIBRARY_NAME );

    Mat test_mat = Highgui.imread("pfau.jpg");

    Mat desc = new Mat();

    FeatureDetector fd = FeatureDetector.create(FeatureDetector.SIFT);

    MatOfKeyPoint mkp =new MatOfKeyPoint();

    fd.detect(test_mat, mkp);

    DescriptorExtractor de = DescriptorExtractor.create(DescriptorExtractor.SIFT);

    de.compute(test_mat,mkp,desc );//提取sift特征

    System.out.println(desc.cols());

    System.out.println(desc.rows());

 

 }

}

 

你可能感兴趣的:(opencv)