First time here? Check out the FAQ!
answered 2020-10-04 08:19:05 -0600
you need to be sure if the Rect roi is inside the image bounds
Rect roi
roi = roi & Rect(0, 0, image.cols, image.rows); Mat crop = image(roi);