In this tutorial, I will show you image warping in OpenCV. Perspective view warping is to convert or perspective correction of images from angle to birds eye view transform. To convert image to birds eye view I will be using warp perspective OpenCV function.

Convert image to birds eye view

Above image is showing what we are going to do in this article. This is called birds eye view transform.

# Output image size

width, height = 250,350

# Desired points value in output images

converted_red_pixel_value = [0,0]

converted_green_pixel_value = [width,0]

converted_black_pixel_value = [0,height]

converted_blue_pixel_value = [width,height]

# Convert points

converted_points = np.float32([converted_red_pixel_value,converted_green_pixel_value,

converted_black_pixel_value,converted_blue_pixel_value])

Perspective correction OpenCV python

As we have defined all points now let’s do perspective correction or birds eye view transform.

# perspective transform opencv

perspective_transform = cv2.getPerspectiveTransform(point_matrix,converted_points)

# perspective view warping opencv

img_Output = cv2.warpPerspective(img,perspective_transform,(width,height))

Full code with detailed explanation

--

--