import cv2
from math import *

def remote(img,degree):
    #degree左转
    img = cv2.imread(img)
    height, width = img.shape[:2]
    heightNew = int(width * fabs(sin(radians(degree))) + height * fabs(cos(radians(degree))))
    widthNew = int(height * fabs(sin(radians(degree))) + width * fabs(cos(radians(degree))))

    matRotation = cv2.getRotationMatrix2D((width / 2, height / 2), degree, 1)

    matRotation[0, 2] += (widthNew - width) / 2
    matRotation[1, 2] += (heightNew - height) / 2
    imgRotation = cv2.warpAffine(img, matRotation, (widthNew, heightNew), borderValue=(255, 255, 255))

    cv2.imshow("img", img)
    cv2.imshow("imgRotation", imgRotation)
    cv2.waitKey(0)
remote('1.jpg',90)

 

相关文章:

  • 2021-11-23
  • 2021-11-10
  • 2022-02-15
  • 2022-02-15
  • 2022-01-28
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-15
  • 2021-09-20
  • 2021-12-28
  • 2022-03-02
  • 2022-01-19
  • 2022-02-17
  • 2022-02-11
相关资源
相似解决方案