SURF and SIFT algorithms doesn't work in OpenCV 3.0 Java for android
I tried to use Sift or surf descriptors for machine learning in an android application. But when i run the program i get this error.
OpenCV Error: Bad argument (Specified feature detector type is not supported.) in cv::javaFeatureDetector::create
My code:
public void train() {
// Creating Training Data
Mat trainData = new Mat();
Mat train_labels = new Mat();
Mat descriptors ;
FeatureDetector featureDetector;
MatOfKeyPoint keyPoints;
DescriptorExtractor descriptorExtractor;
Mat descriptors1 ;
FeatureDetector featureDetector1;
MatOfKeyPoint keyPoints1;
DescriptorExtractor descriptorExtractor1;
String Newligne=System.getProperty("line.separator");
for (int i = 0; i <48; i++) {
String path1 = Environment.getExternalStorageDirectory().toString()
+ "/Pictures/images/" + "a"+i + ".jpg";
/* String path1 = Environment.getExternalStorageDirectory().toString()
+ "/Pictures/images/" +"a"+ i + ".jpg";*/
Mat img = Imgcodecs.imread(path1);
featureDetector=FeatureDetector.create(FeatureDetector.PYRAMID_FAST);
descriptorExtractor=DescriptorExtractor.create(DescriptorExtractor.SIFT);
keyPoints = new MatOfKeyPoint();
descriptors = new Mat();
featureDetector.detect(img, keyPoints);
Log.d("LOG!", "number of query Keypoints= " + keyPoints.size());
// Descript keypoints
descriptorExtractor.compute(img, keyPoints, descriptors);
Log.d("LOG!", "number of descriptors= " + descriptors.size());
Log.i(TAG,"error"+i+img.empty());
trainData.push_back(descriptors)// add 1 item
train_labels.push_back(new Mat(1, 1, CvType.CV_32SC1, new Scalar(i)));
}
can you show us some code for more details?
i put my code. Can you help me
sad as it is, sift & surf were moved to opencv_contrib, and the java bindings did not survive that move.
Well, then a Possibility to use them in Android would be when you use OpenCV as native Library. Here A answer which explains how to build opencv for Android. As Berak mentioned, SIFT and SURF have been moved to opencv-contrib so you have to build opencv with that included.
Concerning BOW is it supported by java ?
@nadia, from plain java atm, - not at all
(go , and run wild with the natives ...)
I am sorry for the disturbance but i have an other question. which types of texture or shape descriptors opencv can use
Hello. I am newbie and I write on Windows 10 PC, so Android and Linux ways to solve the same problem as in topic are not applicable. Can someone help me?
i have this problem How did you solve it Please?
My email: [email protected]