目录
二、利用getPerspectiveTransform函数获取透视转换矩阵
三、利用warpPerspective函数获取处理好的鸟瞰图像
Tip:顺序是左上,右上,左下和右下的四个坐标点位置

Tips:
- getPerspectiveTransform(src,dst):
- src是原图像的四点坐标(左上,右上,左下和右下)
- dst是转换后的图像的四点坐标(一一对应)
matrix = cv2.getPerspectiveTransform(pts1,pts2)
Tips:
Outimg = cv2.warpPerspective(src,matrix,(width,height))
- src:原图像
- matrix:原图像到鸟瞰图像的透视变换矩阵
- (widht,height):处理后的图像的宽度和高度
imgOutput = cv2.warpPerspective(img,matrix,(width,height))


- import numpy as np
- import cv2
-
- img = cv2.imread('./test.png')
-
- width,height=250,350
- pts1 = np.float32([[81,126],[236,156],[81,359],[235,314]])
- pts2 = np.float32([[0,0],[width,0],[0,height],[width,height]])
-
- matrix = cv2.getPerspectiveTransform(pts1,pts2)
- imgOutput = cv2.warpPerspective(img,matrix,(width,height))
-
- for x in range(0,4):
- cv2.circle(img,(pts1[x][0],pts1[x][1]),5,(0,0,255),cv2.FILLED)
-
- cv2.imshow('original img',img)
- cv2.imshow('output img',imgOutput)
-
- cv2.waitKey(0)