answered 2013-09-26 01:41:49 -0600
Check that roi is correct:
if (roi.x >= 0 && row.y >= 0 && roi.width < input_frame.cols && roi.height < input_frame.rows) { // your code } else { return -1; }