問題原因:
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尺寸是否在圖像內