import os
import cv2
import numpy as np
def get_rotate_crop_image(img, before_points, after_points):
pts_std = np.float32(after_points)
points = np.float32(before_points)
(img_after_width, img_after_height) = int(after_points[2][0] + after_points[2][1] * 0.1), int(
after_points[2][1] * 1.1)
M = cv2.getPerspectiveTransform(points, pts_std)
dst_img = cv2.warpPerspective(
img,
M, (img_after_width, img_after_height),
borderMode=cv2.BORDER_REPLICATE,
flags=cv2.INTER_CUBIC)
return dst_img,M
def get_coord(pos, cvt_M):
u = pos[0]
v = pos[1]
x = (cvt_M[0][0] * u + cvt_M[0][1] * v + cvt_M[0][2]) / (cvt_M[2][0] * u + cvt_M[2][1] * v + cvt_M[2][2])
y = (cvt_M[1][0] * u + cvt_M[1][1] * v + cvt_M[1][2]) / (cvt_M[2][0] * u + cvt_M[2][1] * v &#
仿射变换利用M对特征点对应坐标点计算
最新推荐文章于 2024-01-12 09:20:44 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)