在Open cv Tutorial1中,我只想使用一些Imgproc函数来处理回调函数上的输入摄像机图像:public Mat onCameraFrame(CvCameraViewFrame inputFrame)
。我刚刚在onCameraFram
添加了这句话:
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
MatOfPoint corners = null;
mRgba = inputFrame.rgba();
mGray= inputFrame.gray();
Imgproc.goodFeaturesToTrack(mGray, corners, 10, 0.5, 0.5);
return mRgba;
}
但当它运行到Imgpro.goodFeaturesToTrack
时,错误会在我的手机上跳出,程序停止。
这是错误
03-21 11:08:32.519: E/Trace(8212): error opening trace file: No such file or directory (2)
03-21 11:08:32.972: E/OpenCV_for_Tegra(8212): Tegra Version detected: 0
03-21 11:08:33.534: E/AndroidRuntime(8212): FATAL EXCEPTION: Thread-405
03-21 11:08:33.534: E/AndroidRuntime(8212): java.lang.NullPointerException
03-21 11:08:33.534: E/AndroidRuntime(8212): at org.opencv.imgproc.Imgproc.goodFeaturesToTrack(Imgproc.java:6486)
03-21 11:08:33.534: E/AndroidRuntime(8212): at org.opencv.samples.tutorial1.Tutorial1Activity.onCameraFrame(Tutorial1Activity.java:161)
03-21 11:08:33.534: E/AndroidRuntime(8212): at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:376)
03-21 11:08:33.534: E/AndroidRuntime(8212): at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:294)
03-21 11:08:33.534: E/AndroidRuntime(8212): at java.lang.Thread.run(Thread.java:856)
有人知道可能出现什么问题吗?
答案 0 :(得分:0)
好。这是你的'空指针':
MatOfPoint corners = null;
你需要的是:
MatOfPoint corners = new MatOfPoint();