这是我的第一个提问,可能不清楚我写的是什么。 a>我想比较两帧之间的差异。
B个使用Imgproc.findContours和Imgproc.drawContours绘制不同的。 但我有一个问题。 这是我的代码和错误信息。
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<MatOfPoint> contours = new ArrayList<MatOfPoint>();
Imgproc.findContours(foregroundThresh, contours,mHierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);
Imgproc.drawContours(mRgba, contours, -1, CONTOUR_COLOR);
}
return mRgba;
}
但是eclipse有错误信息,这里是错误
* GT; 04-10 03:13:46.717:E / AndroidRuntime(3722):致命异常:Thread-187
04-10 03:13:46.717:E / AndroidRuntime(3722):流程: org.opencv.samples.imagemanipulations,PID:3722
04-10 03:13:46.717:E / AndroidRuntime(3722):java.lang.NullPointerException:尝试从字段中读取'long null对象引用上的org.opencv.core.Mat.nativeObj'
04-10 03:13:46.717:E / AndroidRuntime(3722):at org.opencv.imgproc.Imgproc.findContours(Imgproc.java:2111)
04-10 03:13:46.717:E / AndroidRuntime(3722):at org.opencv.samples.imagemanipulations.ImageManipulationsActivity.onCameraFrame(ImageManipulationsActivity.java:223)
04-10 03:13:46.717:E / AndroidRuntime(3722):at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:391)
04-10 03:13:46.717:E / AndroidRuntime(3722):at org.opencv.android.JavaCameraView $ CameraWorker.run(JavaCameraView.java:350)
04-10 03:13:46.717:E / AndroidRuntime(3722):at java.lang.Thread.run(Thread.java:818)*