Opencv for android:Imgproc.findContours has an error
<p>This is my first ask question, it maybe not clear what I write.
a>I want to compare the different between two frames.</p>

<p>b> use the Imgproc.findContours and Imgproc.drawContours to draw the different.
But I have a problem.
here is my code and the error information.</p>

<pre><code>    public Mat onCameraFrame(CvCameraViewFrame inputFrame) {

    mRgba = inputFrame.rgba();
    mGray = inputFrame.gray();

    //isfirstframe is a boolean it default false.
    if(!isfirstframe){  
       mGray.copyTo(firstframe);
       isfirstframe = true;
    }
      else{
            //compare the difference between the firstframe and others 
            Core.absdiff(firstframe, mGray, foreground);
            Imgproc.threshold(foreground,foregroundThresh,30,255,Imgproc.THRESH_BINARY);
            List&lt;MatOfPoint&gt; contours = new ArrayList&lt;MatOfPoint&gt;();


            Imgproc.findContours(foregroundThresh, contours,mHierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);
            Imgproc.drawContours(mRgba, contours, -1, CONTOUR_COLOR);         
      }

      return mRgba;
}
</code></pre>

<p>but the eclipse  has error information,here is the error</p>

<blockquote>
  <p>*> 04-10 03:13:46.717: E/AndroidRuntime(3722): FATAL EXCEPTION: Thread-187</p>
  
  <p>04-10 03:13:46.717: E/AndroidRuntime(3722): Process:
  org.opencv.samples.imagemanipulations, PID: 3722</p>
  
  <p><strong>04-10 03:13:46.717: E/AndroidRuntime(3722): java.lang.NullPointerException: Attempt to read from field 'long
  org.opencv.core.Mat.nativeObj' on a null object reference</strong></p>
  
  <p><strong>04-10 03:13:46.717: E/AndroidRuntime(3722):     at org.opencv.imgproc.Imgproc.findContours(Imgproc.java:2111)</strong></p>
  
  <p>04-10 03:13:46.717: E/AndroidRuntime(3722):   at
  org.opencv.samples.imagemanipulations.ImageManipulationsActivity.onCameraFrame(ImageManipulationsActivity.java:223)</p>
  
  <p>04-10 03:13:46.717: E/AndroidRuntime(3722):   at
  org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:391)</p>
  
  <p>04-10 03:13:46.717: E/AndroidRuntime(3722):   at
  org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:350)</p>
  
  <p>04-10 03:13:46.717: E/AndroidRuntime(3722):   at
  java.lang.Thread.run(Thread.java:818)*</p>
</blockquote>