Ask Your Question
1

How to draw inscribed rectangle in fish eye corrected image using opencv?

asked 2014-07-01 05:20:31 -0600

muglikar gravatar image

updated 2014-07-01 05:26:53 -0600

How to draw inscribed rectangle in fish eye corrected image using opencv?

Original image:

image description

This is the fish eye corrected image: image description

This is what I need to crop the image: Either the 4 corner points of the rectangle or the midpoints of the sides.

image description

Final manually corrected image:

image description

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2014-07-01 15:42:53 -0600

Witek gravatar image

Use undistortPoints to find the coordinates of points lying on the image edges. For each edge, find the maximum/minimum value of x/y coordinates (whichever is necessary for a given edge). These will be your midpoints that you marked with little dashes. The rest is straightforward.

edit flag offensive delete link more
0

answered 2014-07-01 06:05:42 -0600

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?

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-07-01 05:20:31 -0600

Seen: 1,556 times

Last updated: Jul 01 '14