opencv ROI边界报错

版权声明:原创文章,转载请标明来源 https://blog.csdn.net/ngy321/article/details/89383269

error: (-215: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 function 'Mat'

出现这个错误是因为roi超出图像范围,无法在图像上呈现,记得每次做有关roi的处理时加个判断,使 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows

我也想过要不要修正roi的参数,但是决定不改,因为我觉得发生不满足上述条件的情况,应该是roi选取有问题,无法保证修正后就是对的,那不如出现异常的roi之后就保持原图,不要去做后续的处理

猜你喜欢

转载自blog.csdn.net/ngy321/article/details/89383269
今日推荐