问题描述
我想从参考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< = m.cols &功放;&安培; 0℃= roi.y和放大器;&安培; 0℃= roi.height和放大器;&安培; roi.y + roi.height< = m.rows)的CV ::垫::垫(常量CV ::垫和放大器;,const的矩形和放大器),文件/home/reports/ci/slave_desktop/50-SDK/opencv/modules/core/src/matrix.cpp,线路323
我也看过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断言错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!