title: Android OpenCV Object Detection
body: <p>Im trying to implement something like this: <a href="http://www.youtube.com/watch?v=zjxWpKCQqJc">http://www.youtube.com/watch?v=zjxWpKCQqJc</a> on android.</p>
  
  <p>Here my code:</p>
  
  <pre><code>public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
      Mat novo = new Mat();
      Mat resp = new Mat();
      Mat homer = new Mat();
  
      //resp = inputFrame.gray();
      novo = inputFrame.gray();
  
      Mat lido = new Mat();
      try {
          lido = Utils.loadResource(this, R.drawable.homer);
      } catch (IOException e) {
          e.printStackTrace();
      }
      Imgproc.cvtColor(lido, homer, Imgproc.COLOR_RGB2GRAY);
  
      FeatureDetector surf = FeatureDetector.create(FeatureDetector.FAST);
  
      MatOfKeyPoint keypointsHomer = new MatOfKeyPoint();
      MatOfKeyPoint keypoints = new MatOfKeyPoint();
  
      surf.detect(homer, keypointsHomer);
      surf.detect(novo, keypoints);
  
      DescriptorExtractor SurfExtractor = DescriptorExtractor.create(FeatureDetector.SURF);
  
      Mat descriptors = new Mat();
      Mat homerDescriptors = new Mat();
  
      SurfExtractor.compute(novo, keypoints, descriptors);
      SurfExtractor.compute(homer, keypointsHomer, homerDescriptors);
  
      DescriptorMatcher m = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE);
      MatOfDMatch matches = new MatOfDMatch();
  
      m.match(descriptors, homerDescriptors, matches);
  
      Features2d.drawMatches(novo, keypoints, homer, keypointsHomer, matches, resp);
  
      return resp;
  }
  </code></pre>
  
  <p>And i got the following error: <a href="https://dl.dropboxusercontent.com/u/2345114/error_android.png">https://dl.dropboxusercontent.com/u/2345114/error_android.png</a></p>
  
  <p>If i try draw the keypoints like this: </p>
  
  <pre><code>Features2d.drawKeypoints(novo, keypoints, resp);
  Features2d.drawKeypoints(homer, keypointsHomer, resp);
  </code></pre>
  
  <p>Both works fine!
  Whats i doing wrong? </p>