我有边框,我想用这个边框裁剪图像。
然而,我想要增加包围框的大小,所以我想。
if ((roi_.x - 5) > 0) // i test here in case the component at the left near border we do not minus otherwise it will be error
{
roi_.x += (-5);
}
if ((roi_.y - 5) > 0) // i test here in case the component at the left near border we do not minus otherwise it will be error
{
roi_.y += (-5);
}
if (&(roi_ + cv::Size(10, 0)) != NULL)
{
roi_.width += 10;
}
if (&(roi_ + cv::Size(0, 10)) != NULL)
{
roi_.height += 10;
}用于最右边靠近边框的组件,如果我增加宽度,它将是错误的。如果组件位于边界附近的底部,则高度相同。
有处理此异常的方法吗?
发布于 2014-02-17 16:21:29
您会得到错误,因为&需要l-值,这对roi_ + cv::Size(10, 0)和roi_ + cv::Size(0, 10)都不适用。
你需要改变
if (&(roi_ + cv::Size(10, 0)) != NULL)
...
if (&(roi_ + cv::Size(0, 10)) != NULL)至
if ((roi_.x + roi_.width + 10) < img.cols)
...
if ((roi_.y + roi_.height + 10) < img.rows)https://stackoverflow.com/questions/21834072
复制相似问题