opencv Androidruntime fatal



在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)

有谁知道哪里出了问题吗?

好吧。这是你的"空指针":

MatOfPoint corners = null;

你需要的是:

MatOfPoint corners = new MatOfPoint();

相关内容

  • 没有找到相关文章

最新更新