python-opencv-旋转

import cv2

img = cv2.imread('3.jpg', 1)
cv2.imshow('src', img)
imgInfo = img.shape
height= imgInfo[0]
width = imgInfo[1]
deep = imgInfo[2]
matRotate = cv2.getRotationMatrix2D((height*0.5, width*0.5), 45, 0.9) # 旋转变化矩阵
'''
参数1 必选参数。用于设置旋转中心点,点坐标为OpenCV图像坐标系下的坐标。
参数2 必选参数。用于设置旋转的角度,单位为度--逆时针角度
参数3 必选参数。用于设置缩放系数,即对旋转的图像进行缩放。
'''
dst = cv2.warpAffine(img, matRotate, (width,height))  #旋转
'''
参数2 变换矩阵:是一个2行3列的矩阵,由这个矩阵决定是何种变换
参数3 变换后输出图像的大小:(width,height)-->宽和高(自己规定)
'''
cv2.imshow('dst',dst)


cv2.waitKey(0)

猜你喜欢

转载自www.cnblogs.com/liming19680104/p/12216533.html