我想在android上使用canny函数我之前在c ++上使用它 现在我像这样写
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
mRgba = inputFrame.gray();
Imgproc.Canny(mRgba, edge, 225, 250);
return edge;
}
代码上没有错误,但是当我在手机上运行时它会给我
Unfortunately , NameProject Preview has stopped
和adb show
07-20 23:03:01.568: E/OpenCV_for_Tegra(6648): Tegra Version detected: 0
07-20 23:03:01.588: D/dalvikvm(6648): GC_FOR_ALLOC freed 150K, 10% free 9182K/10148K, paused 15ms, total 16ms
07-20 23:03:01.588: I/dalvikvm-heap(6648): Grow heap (frag case) to 11.226MB for 1536016-byte allocation
07-20 23:03:01.598: D/dalvikvm(6648): GC_FOR_ALLOC freed 0K, 9% free 10682K/11652K, paused 12ms, total 12ms
07-20 23:03:01.608: D/JavaCameraView(6648): startPreview
07-20 23:03:01.658: E/dalvikvm(6648): adjustAdaptiveCoef max=4194304, min=1048576, ut=568
07-20 23:03:01.658: D/dalvikvm(6648): GC_CONCURRENT freed 3K, 9% free 10681K/11652K, paused 3ms+2ms, total 62ms
07-20 23:03:02.149: D/JavaCameraView(6648): Starting processing thread
07-20 23:03:02.469: D/JavaCameraView(6648): Preview Frame received. Frame size: 576000
07-20 23:03:02.529: D/JavaCameraView(6648): Preview Frame received. Frame size: 576000
07-20 23:03:02.639: D/JavaCameraView(6648): Preview Frame received. Frame size: 576000
07-20 23:03:02.739: D/JavaCameraView(6648): Preview Frame received. Frame size: 576000
07-20 23:03:02.839: D/JavaCameraView(6648): Preview Frame received. Frame size: 576000
07-20 23:03:02.939: D/JavaCameraView(6648): Preview Frame received. Frame size: 576000
07-20 23:03:03.000: W/dalvikvm(6648): threadid=11: thread exiting with uncaught exception (group=0x40fb2930)
07-20 23:03:03.000: E/AndroidRuntime(6648): FATAL EXCEPTION: Thread-21050
07-20 23:03:03.000: E/AndroidRuntime(6648): java.lang.NullPointerException
07-20 23:03:03.000: E/AndroidRuntime(6648): at org.opencv.imgproc.Imgproc.Canny(Imgproc.java:448)
07-20 23:03:03.000: E/AndroidRuntime(6648): at org.opencv.samples.tutorial1.Tutorial1Activity.onCameraFrame(Tutorial1Activity.java:167)
07-20 23:03:03.000: E/AndroidRuntime(6648): at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:387)
07-20 23:03:03.000: E/AndroidRuntime(6648): at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:328)
07-20 23:03:03.000: E/AndroidRuntime(6648): at java.lang.Thread.run(Thread.java:856)
07-20 23:03:03.040: D/JavaCameraView(6648): Preview Frame received. Frame size: 576000
07-20 23:03:03.150: D/JavaCameraView(6648): Preview Frame received. Frame size: 576000
07-20 23:03:03.210: D/JavaCameraView(6648): Disconnecting from camera
07-20 23:03:03.210: D/JavaCameraView(6648): Notify thread
07-20 23:03:03.210: D/JavaCameraView(6648): Wating for thread
任何想法?
答案 0 :(得分:0)
抱歉,我不能发表评论你必须这样做
public void onCameraViewStarted(int width, int height) {
cany= new Mat(height, width, CvType.CV_8UC4);
}
请参阅此问题here