Perspective Transformation - Python OpenCV Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report 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 . cv2.getPerspectiveTransform method Syntax: cv2.getPerspectiveTransform(src, dst) Parameters: src: Coordinates of quadrangle vertices in the source image.dst: Coordinates of the corresponding quadrangle vertices in the destination image. cv2.wrapPerspective method Syntax: cv2.warpPerspective(src, dst, dsize) Parameters: src: Source Imagedst: 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: Python3 # import necessary libraries import cv2 import numpy as np # Turn on Laptop's webcam cap = cv2.VideoCapture(0) while True: ret, frame = cap.read() # Locate points of the documents # or object which you want to transform pts1 = np.float32([[0, 260], [640, 260], [0, 400], [640, 400]]) pts2 = np.float32([[0, 0], [400, 0], [0, 640], [400, 640]]) # Apply Perspective Transform Algorithm matrix = cv2.getPerspectiveTransform(pts1, pts2) result = cv2.warpPerspective(frame, matrix, (500, 600)) # Wrap the transformed image cv2.imshow('frame', frame) # Initial Capture cv2.imshow('frame1', result) # Transformed Capture if cv2.waitKey(24) == 27: break cap.release() cv2.destroyAllWindows() Output: Comment More infoAdvertise with us Next Article Perspective Transformation - Python OpenCV A ayushmankumar7 Follow Improve Article Tags : Python Image-Processing OpenCV Python-OpenCV Practice Tags : python Similar Reads Python OpenCV - Affine Transformation OpenCV is the huge open-source library for computer vision, machine learning, and image processing and now it plays a major role in real-time operation which is very important in todayâs systems. By using it, one can process images and videos to identify objects, faces, or even the handwriting of a 3 min read Image Transformations using OpenCV in Python In this tutorial, we are going to learn Image Transformation using the OpenCV module in Python. What is Image Transformation? Image Transformation involves the transformation of image data in order to retrieve information from the image or preprocess the image for further usage. In this tutorial we 5 min read Negative transformation of an image using Python and OpenCV Image is also known as a set of pixels. When we store an image in computers or digitally, itâs corresponding pixel values are stored. So, when we read an image to a variable using OpenCV in Python, the variable stores the pixel values of the image. When we try to negatively transform an image, the b 4 min read Python PIL | Image.transform() method PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, 1 min read Python OpenCV â cv2.transpose() method OpenCV is a library of programming functions mainly aimed at real-time computer vision. cv2.transpose() method is used to transpose a 2D array. The function cv::transpose rotate the image 90 degrees Counter clockwise. Syntax: cv2.cv.transpose( src[, dst] ) Parameters: src: It is the image whose matr 1 min read Like