一、
1.图像旋转,矩阵变换
2. cv2.getRotationMatrix2D((x,y),angle,scale) 得到旋转矩阵
(x,y)旋转中心
Angle,旋转角度,单位°
scale,缩放比
3.旋转矩阵
其中a = scale*cos angle;b = s*sin a,所以,又可以表示为
二、
# 图像旋转实现
import cv2
import numpy as np
img = cv2.imread('image01.jpg',1)
imgHeight,imgWidth,_ = img.shape
matRotate = cv2.getRotationMatrix2D((imgWidth*0.5,imgHeight*0.5),45,0.5)
dstImg = cv2.warpAffine(img,matRotate,(imgWidth,imgHeight))
cv2.imshow('image', dstImg)
cv2.waitKey(0)
cv2.destroyAllWindows()