标签:
java 在centos6.5+eclipse环境下调用opencv实现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("/home/Tian/software/meng.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()); } //以下代码实现了对主函数中代码的封装 /** * 传入一张图片得到sift特征点 * @param mat * @return */ public MatOfKeyPoint getFeaturePoints(Mat mat){ FeatureDetector fd = FeatureDetector.create(FeatureDetector.SIFT); MatOfKeyPoint mkp =new MatOfKeyPoint(); fd.detect(mat, mkp); return mkp; } /** * 获取sift特征 * @param mat * @return */ public Mat getFeature(Mat mat){ Mat desc = new Mat(); MatOfKeyPoint mkp = getFeaturePoints(mat); DescriptorExtractor de = DescriptorExtractor.create(DescriptorExtractor.SIFT); de.compute(mat,mkp,desc );//提取sift特征 return desc; } }
java 在centos6.5+eclipse环境下调用opencv实现sift算法
标签:
原文地址:http://www.cnblogs.com/tianyalu/p/4969750.html