Ask Your Question

Revision history [back]

you need to be sure if the Rect roi is inside the image bounds

roi = roi & Rect(0, 0, image.cols, image.rows);
Mat crop = image(roi);