So I’m trying to crop an image of 3280 x 1030 with the code below where x_min and x_max are 293, 1223 respectively, and y_min and y_max are 222 and 506.
cv::Mat crop_goal(cv::Mat img, vector<Point> goal)
{
int x_min,x_max, y_min,y_max;
tie(x_min, x_max, y_min, y_max) = min_max(goal);
cout << img.size() << endl;
cv::Mat cropped_image = img(Range(x_min, x_max), Range(y_min, y_max));
return cropped_image;
I have drawn some circles on those points and that works but I get an error which from what I read online means my values are out of bounds. This is the error code:
OpenCV(3.4.15) Error: Assertion failed (0<= _rowRange.start && _rowRange.start<=_rowRange.end && _rowRange.end<=m.rows) in cv::Mat::Mat, file C:\build\3_4_winpack-build-win64-vc15\opencv\modules\core\src\matrix.cpp, line 709
Any help will be greatly appreciated. Here’s the image in case is needed, with pink points where I want to cut it (yes, I want the black space):