使用线段检测器时,应用程序停止工作

时间:2018-03-05 10:34:57

标签: android opencv crash

我正在尝试使用线段检测器在Android中查找和创建矩形(作为实验) 因为我刚刚开始这是我到目前为止所做的:

public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) 
{ 
    gray=inputFrame.gray(); 
    lines=new Mat();
    canvas=new Mat(480,640, CvType.CV_8UC1);
    LineSegmentDetector det=Imgproc.createLineSegmentDetector();
    det.detect(gray,lines);
    det.drawSegments(gray,lines);
    return gray;
}

logcat的:

03-05 16:21:48.469 17450-17450/com.kibo.ninad.cropping D/JavaCameraView: 
Preview Frame received. Frame size: 622080
03-05 16:21:48.500 17450-17450/com.kibo.ninad.cropping D/JavaCameraView: 
Preview Frame received. Frame size: 622080
03-05 16:21:48.535 17450-17450/com.kibo.ninad.cropping D/JavaCameraView: 
Preview Frame received. Frame size: 622080
03-05 16:21:48.550 17450-17555/com.kibo.ninad.cropping D/CameraBridge: 
mStretch value: 1.4
03-05 16:21:48.567 17450-17450/com.kibo.ninad.cropping D/JavaCameraView: 
Preview Frame received. Frame size: 622080
03-05 16:21:48.601 17450-17450/com.kibo.ninad.cropping D/JavaCameraView: 
Preview Frame received. Frame size: 622080
03-05 16:21:48.628 17450-17555/com.kibo.ninad.cropping D/CameraBridge: 
mStretch value: 1.4
03-05 16:21:48.636 17450-17450/com.kibo.ninad.cropping D/JavaCameraView: 
Preview Frame received. Frame size: 622080

这就是我得到的......没有错误记录

这样可以正常工作一段时间,然后应用程序崩溃而没有任何暗示

有人可以告诉我我做错了吗

再次感谢!!

[编辑]

当我使用runOnUiThread

时会发生这种情况

代码:

public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) 
{
    mRgb=inputFrame.rgba();
    gray=inputFrame.gray();
    lines=new Mat();
    canvas=new Mat(gray.rows(),gray.cols(), CvType.CV_8UC1);
    LineSegmentDetector det=Imgproc.createLineSegmentDetector();
    det.detect(gray,lines);
    det.drawSegments(canvas,lines);
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            lines=new Mat();
            canvas=new Mat(gray.rows(),gray.cols(), CvType.CV_8UC1);
            LineSegmentDetector det=Imgproc.createLineSegmentDetector();
            det.detect(gray,lines);
            det.drawSegments(canvas,lines);
        }
    });
    return canvas;
}

logcat的:

03-05 19:14:10.893 12415-12528/com.kibo.ninad.cropping A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x65400 in tid 12528 (Thread-4)
03-05 19:14:10.893 12415-12532/com.kibo.ninad.cropping A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0xfd200 in tid 12532 (Thread-4)
03-05 19:14:10.893 12415-12532/com.kibo.ninad.cropping I/libc: Another thread contacted debuggerd first; not contacting debuggerd.
03-05 19:14:10.893 12415-12415/com.kibo.ninad.cropping A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 12415 (.ninad.cropping)
03-05 19:14:10.893 12415-12415/com.kibo.ninad.cropping I/libc: Another thread contacted debuggerd first; not contacting debuggerd.
03-05 19:14:10.894 12415-12531/com.kibo.ninad.cropping A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x32a00 in tid 12531 (Thread-4)
03-05 19:14:10.894 12415-12531/com.kibo.ninad.cropping I/libc: Another thread contacted debuggerd first; not contacting debuggerd.
03-05 19:14:10.894 12415-12529/com.kibo.ninad.cropping A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x97e00 in tid 12529 (Thread-4)

它发出如下错误,现在称为致命信号错误

0 个答案:

没有答案