Ask Your Question
1

SURF & SIFT feature detector and descriptor on OpenCV android

asked 2015-02-16 03:33:11 -0600

Nawara gravatar image

updated 2015-02-16 03:36:33 -0600

I want to detect image keypoints. I tried the following code with differents feature detectors from the OpenCV library.

It work for ORB , BRISK , FAST , etc. But not for SURF/SIFT and even MSER detector !

 public class ReadImaageActivity extends ActionBarActivity {

 Mat image ; File fileimage ;
 TimePicker time ; 
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
        @Override
        public void onManagerConnected(int status) {
            switch (status) {
                case LoaderCallbackInterface.SUCCESS:
                {
                    Log.i("activity", "OpenCV loaded successfully");

                    fileimage = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/7.jpg");

                    if (fileimage.exists())

                    image = Highgui.imread(fileimage.getAbsolutePath() ,Highgui.CV_LOAD_IMAGE_COLOR);

                    else Log.i("activity","dont exit")       ;


                //  

                    long startTime = System.nanoTime();

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

                    MatOfKeyPoint keypoints= new MatOfKeyPoint(); 
                    try 
                    {

                    fd.detect(image, keypoints);

                } catch (Exception e) {
                    e.printStackTrace();
                }

                    long endTime = System.nanoTime();

                    long duration = (endTime - startTime)/1000000;  //divide by 1000000 to get milliseconds.



                    if (!keypoints.empty())
                    {   

                        Log.i("Keypoints", "is not empty"); 


                        System.out.println("duration"+""+duration);


                        System.out.println("size"+""+keypoints.size());
                }
                    else
                            Log.i("Keypoints", "is not empty");
                /*
                    Mat descriptors=new Mat();
                    DescriptorExtractor dex =DescriptorExtractor.create(DescriptorExtractor.SURF);


                    {   


                    dex.compute(image, keypoints, descriptors);

                    long endTime = System.nanoTime();

                    long duration = (endTime - startTime)/1000000;  //divide by 1000000 to get milliseconds.
                    System.out.println(descriptors.size());
                    System.out.println("duration"+duration);
                    }
                    else System.out.println("a3");

                    */










                } break;
                default:
                {
                    super.onManagerConnected(status);
                } break;
            }
        }
    };
@SuppressLint("NewApi") @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_read_imaage);


 }

@Override
public void onResume()
{
    super.onResume();
    OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_9, this, mLoaderCallback);
}

          }

the code is tested with my debvice ZTE Blade android 2.3.7

edit retag flag offensive close merge delete

Comments

1

"does not work" - means what exactly ?

berak gravatar imageberak ( 2015-02-16 03:35:28 -0600 )edit

there is no results and the app crash

Nawara gravatar imageNawara ( 2015-02-16 03:39:39 -0600 )edit
1

unfortunately, i'm no more up-to-date with android dev, but the 1st thing to check would be, if

FeatureDetector fd= FeatureDetector.create(FeatureDetector.SURF); results in a null-pointer

berak gravatar imageberak ( 2015-02-16 03:53:39 -0600 )edit

no.. the program is blocked in this instruction

Nawara gravatar imageNawara ( 2015-02-16 04:55:49 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-04-15 18:40:25 -0600

lanshan317 gravatar image

SIFT/SURF are in the nonfree module, and it is not included in the OpenCV for Android. Please check my answer in this thread for solutions.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-02-16 03:33:11 -0600

Seen: 3,474 times

Last updated: Feb 16 '15