A pretty simple concept, I have a 640x480 Mat and a 800x480 screen, so I am trying to copy the original image to the center of a black 800x480 image so the aspect ratio is maintained but the whole screen is used.
I followed this post and tried both solutions (direct copy to and region of interest) and get the same error:
OpenCV Error: Assertion failed (0 <= _colRange.start && _colRange.start <= _colRange.end && _colRange.end <= m.cols) in Mat, file /home/pi/opencv-3.0.0/modules/core/src/matrix.cpp, line 464
terminate called after throwing an instance of 'cv::Exception'
what(): /home/pi/opencv-3.0.0/modules/core/src/matrix.cpp:464: error: (-215) 0 <= _colRange.start && _colRange.start <= _colRange.end && _colRange.end <= m.cols in function Mat
Aborted
The offending code:
cv::Mat displayimage = cv::Mat(800, 480, CV_16U, cv::Scalar(0));
modimage1.copyTo(displayimage.rowRange(1,480).colRange(81,720));
I first attempted it with start/end range/row of (0,480) and (80,720), but then the error made it sound like it couldn't start at 0, so then of course I thought I was off by 1 and I started at 1 with the same results. But in actuality, the error is for the COLUMNS and not the ROWS, and with the columns being off by 1 wouldn't even matter. So what doesn't it like about where I'm trying to copy this image to?