这种方法选择图片后不会剪切掉溢出边缘的部分,而是重新生成一张更大的图片,将图片扩大为一张正方形图片,具体效果请见文末:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#!/usr/bin/env python
import numpy as np
import sys
import cv2
import os
def rotate_bound(image, angle):
# grab the dimensions of the image and then determine the
# center
(h, w) = image.shape[:2]
(cX, cY) =</