1. 程式人生 > >error: OpenCV Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y &

error: OpenCV Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y &

問題原因:

You are probably working outside of the image dimensions. Does any of the values you pass to the cvSetImageROI function lay outside the image boudaries?

影象的ROI區域超過了影象的尺寸,即roi.x + roi.width > m.cols && roi.y + roi.height > m.rows

解決辦法:

判斷擷取的ROI尺寸是否在影象內