Java in the CENTOS6.5+ECLIPSE environment calls OPENCV implementation SIFT algorithm, the code is as follows:
ImportOrg.opencv.core.Core;ImportOrg.opencv.core.Mat;ImportOrg.opencv.core.MatOfKeyPoint;ImportOrg.opencv.highgui.Highgui;Importorg.opencv.features2d.*; Public classextractsift{ Public Static voidMain (string[] args) {system.loadlibrary (core.native_library_name); Mat Test_mat= Highgui.imread ("/home/tian/software/meng.jpg"); Mat desc=NewMat (); Featuredetector FD=featuredetector.create (Featuredetector.sift); Matofkeypoint MKP=NewMatofkeypoint (); Fd.detect (Test_mat, MKP); Descriptorextractor de=descriptorextractor.create (Descriptorextractor.sift); De.compute (TEST_MAT,MKP,DESC);//extracting Sift featuresSystem.out.println (Desc.cols ()); System.out.println (Desc.rows ()); } //The following code implements the encapsulation of the code in the main function /*** Pass in a picture to get sift feature points *@paramMat *@return */ Publicmatofkeypoint Getfeaturepoints (Mat mat) {Featuredetector fd=featuredetector.create (Featuredetector.sift); Matofkeypoint MKP=NewMatofkeypoint (); Fd.detect (Mat, MKP); returnMKP; } /*** Get SIFT Features *@paramMat *@return */ PublicMat Getfeature (Mat mat) {Mat desc=NewMat (); Matofkeypoint MKP=Getfeaturepoints (MAT); Descriptorextractor de=descriptorextractor.create (Descriptorextractor.sift); De.compute (MAT,MKP,DESC);//extracting Sift features returndesc; } }View Code
Java calls OPENCV implementation sift algorithm in CENTOS6.5+ECLIPSE environment