1 | initial version |
You could find the midpoints by analyzing your mask. I guess you have a default value for the pixel outside of the fish-eye correction, therefore, using a blob detector, and its bounding box, you have the midpoint: get the max X value for the left part, the max Y for the upper part, etc. With these values, it's easy to draw the rectangle (and crop the image).
This is just a hack, maybe the rectangle can be deduce from your fish-eye correction process?