title: using SIFT/SURF for feature extraction using opencv on android using Android Studio
body: <p>I'm working on a feature extraction/matching app using opencv on android using android studio .. I followed <a href="https://stackoverflow.com/questions/17767557/how-to-use-opencv-in-android-studio-using-gradle-build-tool/22427267#22427267">these steps</a> 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</p>
  
  <pre><code>public class MainActivity extends Activity implements CvCameraViewListener2{
  
  private Mat                    mRgba;
  private Mat                    mGrayMat;
  private CameraBridgeViewBase   mOpenCvCameraView;
  
  Mat descriptors ;
  List&lt;Mat&gt; 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;
  }
  </code></pre>
  
  <p>when I compile and run the app it runs for less than one second then crashes.
  what is your recommendation?? (I'm using Android studio 1.1 NOT Eclipse).</p>
  
  <p>thanks in advance.</p>