Perspective Transformation – Python OpenCV
In Perspective Transformation, we can change the perspective of a given image or video for getting better insights into the required information. In Perspective Transformation, we need to provide the points on the image from which want to gather information by changing the perspective. We also need to provide the points inside which we want to display our image. Then, we get the perspective transform from the two given sets of points and wrap it with the original image.
We use cv2.getPerspectiveTransform and then cv2.warpPerspective .
Syntax: cv2.getPerspectiveTransform(src, dst)
- src: Coordinates of quadrangle vertices in the source image.
- dst: Coordinates of the corresponding quadrangle vertices in the destination image.
Syntax: cv2.warpPerspective(src, dst, dsize)
- src: Source Image
- dst: output image that has the size dsize and the same type as src.
- dsize: size of output image
Below is the Python code explaining Perspective Transformation: