Hey there,
In my program, I am looping through a 2D Mat, using a rectangle with width 5 and height 1, and checking float point values in this sub array. My code goes as follow:
for (int i = 0; i < dist.rows; ++i) {
for (int j = 2; j < dist.cols -2; ++j) {
search_mask = dist(Rect(i, j - 2, 5, 1).clone();
minMaxLoc(search_mask, NULL, NULL, NULL, &local_max);
if (local_max.x == i) {
skeleton.at<uchar>(i, j) = 255;
}
}
}
My original picture has size 640*363. When the first loop reached the value i = 359, I get an assertion error:
OpenCV Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in cv:: Mat::Mat
As far as I can tell, the problem is, that when i = 359, roi.x = 359, roi. width = 5 and so roi.x + roi.width = 364, and m.cols = 363 and so 364 <= 363 is false.
My first question is, am I doing something wrong here?
My second question, why the hell would the number of rows matter when it comes to deciding if the number of columns in the sub array is not greater, than the number of columns in the original image.
Thank you for your help.
Also, sorry if I have left something important out.