Slide 129
Slide 129 text
Perspective Transformation
void TransformImage(Point[] corners)
{
//Do nothing if square wasn’t found.
if (corners == null) return;
//Input detect corners.
Point2f[] input = { corners[0], corners[1],
corners[2], corners[3] };
//Define corners of square image.
Point2f[] square =
{ new Point2f(0, 0), new Point2f(0, 255),
new Point2f(255, 255), new Point2f(255, 0) };
//Calculation of transformation matrix.
Mat transform = Cv2.GetPerspectiveTransform(input, square);
//Deform image as front view square.
Cv2.WarpPerspective(bgr,bgr,transform, new Size(256, 256));
}
(0, 0) (255, 0)
(0, 255) (255 255)
[0]
[1] [2]
[3]