This Python program uses OpenCV to perform a perspective transformation on an image. It allows the user to specify the coordinates of four points in the source image and maps them to a new image of specified dimensions.
-
Run the script.
-
Follow the on-screen prompts to provide the necessary input: Image filename (e.g., image.jpg) New height and width of the desired image Coordinates of the four corners (top left, bottom left, top right, bottom right)
Note: You need to know the coordinates of the four corners in the source image.
- The program will process the image and save the transformed image as
Modified image.jpgin the current directory.
Enter the filename for conversion along with the format, e.g., .jpg: example.jpg Required height of the image: 500 Required width of the image: 700 Coordinates of the top left corner, separated by a comma: 50,50 Coordinates of the bottom left corner, separated by a comma: 50,450 Coordinates of the top right corner, separated by a comma: 650,50 Coordinates of the bottom right corner, separated by a comma: 650,450 DONE! You can close the program or press ENTER