I have a binary mask which always forms a rectangular-ish object like this:
What I need to do is find the rectangle that fits within this area, like the pink one here:
I tried using
cv::boundingRect() like this:
cv::Mat points; cv::findNonZero(output_mask, points); cv::Rect r = cv::boundingRect(points); cv::rectangle(output, r, cv::Scalar(0, 0, 255));
but of course that gives me a rectangle that includes the outside of what I want vs the inside rectangle:
I feel like I’m missing something obvious.