断言失败,我找不到问题的原因


for (size_t i = 1; i < count + 1; i++) {
Mat img = vFrames[i - 1].Image1;
Mat half1(mFinalImage, cv::Rect(-final_vector[i - 1].x + minx + abs(minx), -final_vector[i - 1].y - miny + abs(maxy), img.cols, img.rows));
img.copyTo(half1);
}
Mat half1(mFinalImage, cv::Rect(-final_vector[i - 1].x + minx + abs(minx), -final_vector[i - 1].y - miny + abs(maxy), img.cols, img.rows)); in line 
Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in cv::Mat::Mat,

我经常遇到这样的错误,是什么原因和解决方案

断言错误消息解释了这一点。Mat构造函数中的以下语句之一为false,但所有语句都应该成立。

0 <= roi.x
0 <= roi.width
roi.x + roi.width <= m.cols
0 <= roi.y
0 <= roi.height
roi.y + roi.height <= m.rows

可能感兴趣的区域不在矩阵内。确保矩形的尺寸保持在矩阵中。

最新更新