title: KeyPoints opencv FAST detector android
body: <p>I'm trying to use Opencv FAST detector setting a threshold in Android. I found a similar solved problem <a href="https://stackoverflow.com/questions/20537280/keypoint-list-to-matofkeypoint">here</a>. I have listed the keypoints list after detect method as suggested, but still doesn't work for me. In my case I want to detect the key points on my camera frame:</p>
  
  <pre><code>public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
      MatOfKeyPoint points = new MatOfKeyPoint();
  
      Mat mat=inputFrame.rgba();
      FeatureDetector fast = FeatureDetector.create(FeatureDetector.FAST);
      fast.detect(mat, points);
  
      // Sort and select 500 best keypoints
      List&lt;KeyPoint&gt; listOfKeypoints = points.toList();
      Collections.sort(listOfKeypoints, new Comparator&lt;KeyPoint&gt;() {
          @Override
          public int compare(KeyPoint kp1, KeyPoint kp2) {
              // Sort them in descending order, so the best response KPs will come first
              return (int) (kp2.response - kp1.response);
          }
      });
      List&lt;KeyPoint&gt; listOfBestKeypoints = listOfKeypoints.subList(0, 500);
      points.fromList(listOfBestKeypoints);   
  
  
  
      Scalar redcolor = new Scalar(255,0,0);
      Mat mRgba= mat.clone();
      Imgproc.cvtColor(mat, mRgba, Imgproc.COLOR_RGBA2RGB,4);
  
      Features2d.drawKeypoints(mRgba, points, mRgba, redcolor, 3);
  
      return mRgba;
  }
  </code></pre>
  
  <p>Problem is that my listOfKeypoints remains null. If I don't try to set the threshold the code works fine  but too slow.</p>
  
  <p>What am I doing wrong here? </p>
  
  <p>Thanks.</p>