title: How to use threshold on CameraFrame android + openCV
body: <p>I try to use threshold in openCV sample code "ColorBlobDetection". But I found some error.</p>
  
  <p>The error.</p>
  
  <pre><code>11-13 20:10:03.798  28032-30391/app.heng.opencv E/cv::error()﹕ OpenCV Error: Assertion failed (src.type() == CV_8UC1) in double cv::threshold(cv::InputArray, cv::OutputArray, double, double, int), file /home/reports/ci/slave_desktop/50-SDK/opencv/modules/imgproc/src/thresh.cpp, line 719
  11-13 20:10:03.828  28032-30391/app.heng.opencv E/org.opencv.imgproc﹕ imgproc::threshold_10() caught cv::Exception: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/imgproc/src/thresh.cpp:719: error: (-215) src.type() == CV_8UC1 in function double cv::threshold(cv::InputArray, cv::OutputArray, double, double, int)
  11-13 20:10:03.858  28032-30391/app.heng.opencv E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-10693
  CvException [org.opencv.core.CvException: cv::Exception: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/imgproc/src/thresh.cpp:719: error: (-215) src.type() == CV_8UC1 in function double cv::threshold(cv::InputArray, cv::OutputArray, double, double, int)
  ]
          at org.opencv.imgproc.Imgproc.threshold_0(Native Method)
          at org.opencv.imgproc.Imgproc.threshold(Imgproc.java:9180)
          at app.heng.opencv.ColorBlobDetectionActivity.onCameraFrame(ColorBlobDetectionActivity.java:241)
          at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:387)
          at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:328)
          at java.lang.Thread.run(Thread.java:841)
  </code></pre>
  
  <p>Here sample picture before use threshold.
  <a href="https://i.stack.imgur.com/WzFWy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WzFWy.jpg" alt="Here sample picture before use threshold"></a></p>
  
  <p>Here sample picture after use threshold that I want.
  <a href="https://i.stack.imgur.com/F57hG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F57hG.jpg" alt="Here sample picture after use threshold that I want"></a></p>
  
  <p>The openCV sample code</p>
  
  <pre><code>public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
      mRgba = inputFrame.rgba();  // mRbga = input frame with color
      MatOfPoint2f  approxCurve = new MatOfPoint2f();
  
      if (mIsColorSelected) {
          mDetector.process(mRgba);
          final List&lt;MatOfPoint&gt; contours = mDetector.getContours();  //contour info is ready in detector
          Log.e(TAG, "Contours count: " + contours.size());   
  
          Core.putText(mRgba, ""+contours.size(), new Point(mRgba.cols()/2, mRgba.rows()/2), 3, 1, new Scalar(255, 255, 255, 255), 2);
  
          //green contous and size=5
          Imgproc.drawContours(mRgba, contours, -1, new Scalar(0, 255, 0), 3);
  
  
  
          Imgproc.threshold(mRgba, mRgba, 0, 255, Imgproc.THRESH_OTSU);
  
  
  
          Mat colorLabel = mRgba.submat(4, 68, 4, 68);
          colorLabel.setTo(mBlobColorRgba);
          Mat spectrumLabel = mRgba.submat(4, 4 + mSpectrum.rows(), 70, 70 + mSpectrum.cols());
          mSpectrum.copyTo(spectrumLabel); 
      }
  
      return mRgba;
  }
  </code></pre>
  
  <p>This is original source code <a href="https://github.com/Itseez/opencv/blob/master/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/ColorBlobDetectionActivity.java" rel="nofollow noreferrer">Here</a></p>