在Grabcut断言错误 [英] Assertion error in Grabcut

查看:1087
本文介绍了在Grabcut断言错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从<一个在Android中实现Grabcut href=\"http://semaster.google$c$c.com/svn/trunk/BgChanger/src/com/opencv/grabcut/android/Grabcut.java\"相对=nofollow>参考code 。但是,当我运行code会生成以下错误。

I am trying to implement Grabcut in Android from reference code. But when I run the code the following error is generated.

错误:

OpenCV的错误:断言失败(0℃= roi.x和放大器;&安培; 0℃= roi.width和放大器;&安培; roi.x + roi.width&LT; = m.cols &功放;&安培; 0℃= roi.y和放大器;&安培; 0℃= roi.height和放大器;&安培; roi.y + roi.height&LT; = m.rows)的CV ::垫::垫(常量CV ::垫和放大器;,const的矩形和放大器),文件/home/reports/ci/slave_desktop/50-SDK/opencv/modules/core/src/matrix.cpp,线路323

我也看过<一个href=\"http://stackoverflow.com/questions/19667555/c-opencv-how-to-apply-filter-to-sub-rect-of-mat\">Similar文章#2 并形成如下的code的变化,但仍然得到了同样的错误。

I have also read Similar article on Stackoverflow and made following changes in the code but still got the same error.

参考code更改的部分:

Changed Part of reference code:

private void backgroundSubtracting(Mat img, Mat background) {
    Mat firstMask = new Mat();
    Mat bgModel = new Mat();
    Mat fgModel = new Mat();
    Mat mask;
    Mat source = new Mat(1, 1, CvType.CV_8U, new Scalar(3.0));
    dst = new Mat();
    Rect rect = new Rect(318,100,513,349);  // <= Static value for checking

    Imgproc.grabCut(img, firstMask, rect, bgModel, fgModel, 1, 0 /* GC_INIT_WITH_RECT */);

PS:如果在格式化任何错误这是我的第一个问题很抱歉

PS: This is my first question so sorry if there are any mistakes in formatting.

推荐答案

在我的角度来看,断言当grabcut矩形是不是里面垫发生。结果
什么是图片的尺寸?

In my point of view, assertion happens when grabcut rect isn't inside mat.
What is the image dimensions ?

这篇关于在Grabcut断言错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆