# 定义旋转rotate函数 def rotate(image, angle, center=None, scale=1.0): # 获取图像尺寸 (h, w) = image.shape[:2] # 若未指定旋转中心,则将图像中心设为旋转中心 if center is None: center = (w / 2, h / 2) # 执行旋转 M = cv2.getRotationMatrix2D(center, angle, scale) rotated = cv2.warpAffine(image, M, (w, h)) # 返回旋转后的图像
return rotated
---------------------
frame=cv2.resize(frame,(h,w),interpolation=cv2.INTER_CUBIC)