Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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)));

         }