opencv 图片旋转
1 import cv2 as cv 2 import numpy as np 3 4 # 图片旋转 5 img = cv.imread('../images/face.jpg', flags=1) # flags=1读取为彩色,flags=0读取为灰度 6 h, w = img.shape[:2] 7 mat_rotate = cv.getRotationMatrix2D(center=(w*0.5, h*0.5), angle=45, scale=1) # center旋转中心 angle旋转角度 scale缩放比例 8 dst = cv.warpAffine(img, mat_rotate, (w, h)) 9 cv.imshow('img1', img) 10 cv.imshow('img2', dst) 11 cv.waitKey(0)