Ask Your Question
0

Using SIFT/SURF for feature extraction using opencv on android in Android Studio

asked 2015-02-24 04:55:49 -0600

alaa gravatar image

'm working on a feature extraction/matching app using opencv on android using android studio .. I followed these steps for using native code in order to use SIFT or SURF algorithms.. I have copied the folders (armeabi, armeabi-v7a, ...etc) to the jniLibs folder and here is my code for the main methods

public class MainActivity extends Activity implements CvCameraViewListener2{

private Mat                    mRgba;
private Mat                    mGrayMat;
private CameraBridgeViewBase   mOpenCvCameraView;

Mat descriptors ;
List<Mat> descriptorsList;

FeatureDetector featureDetector;
MatOfKeyPoint keyPoints;
DescriptorExtractor descriptorExtractor;
DescriptorMatcher descriptorMatcher;

boolean mIsJavaCamera = true;
static {System.loadLibrary("opencv_java");}

////////////////////////////////////////////////////////////////
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
    @Override
    public void onManagerConnected(int status) {
        switch (status) {
            case LoaderCallbackInterface.SUCCESS:
            {
                //Log.i(TAG, "OpenCV loaded successfully");
                mOpenCvCameraView.enableView();
            } break;
            default:
            {
                super.onManagerConnected(status);
            } break;
        }
    }
};

@Override
public void onCameraViewStarted(int width, int height) {

    mRgba = new Mat();
    mGrayMat = new Mat();
    featureDetector=FeatureDetector.create(FeatureDetector.SIFT);
         descriptorExtractor=DescriptorExtractor.create(DescriptorExtractor.SURF);
    descriptorMatcher=DescriptorMatcher.create(6);
    keyPoints = new MatOfKeyPoint();
    descriptors = new Mat();
 }

public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
    final Mat rgba = inputFrame.rgba();

   Imgproc.cvtColor(rgba, rgba, Imgproc.COLOR_RGBA2GRAY);
   featureDetector.detect(rgba, keyPoints);
   Features2d.drawKeypoints(rgba, keyPoints, rgba);
   return rgba;
}

when I compile and run the app it runs for less than one second then crashes. However, for the exact sam code above when I replace SIFT or SURF with ORB, STAR the app works perfectly. How can I make sure that the SIFT/SURF are compiled correctly? Where can I find the code of them? what are your recommendations ?? (I'm using Android studio 1.1 NOT Eclipse).

thanks in advance.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-04-15 18:38:44 -0600

lanshan317 gravatar image

SIFT and SURF are not in OpenCL4Android. They are included in nonfree module. Please check this thread for solutions.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-02-24 04:55:49 -0600

Seen: 9,411 times

Last updated: Feb 24 '15