亲,双击屏幕即可自动滚动
4.2.3 图像旋转
    4.2.3 图像旋转
    图像旋转的物理意义,可以理解为摄像头或者相机和物体的夹角发生了变化。
    img=cv2.imread("../picture/pig.jpg")
    img1 = cv2.cvtcolor(img, cv2.color_bgr2rgb)
    rows,cols,_ = img.shape
    matrix = cv2.getrotationmatrix2d((cols/2,rows/2),90,1)
    img2 = cv2.warpaffine(img1,matrix,(cols,rows))
    matrix = cv2.getrotationmatrix2d((cols/2,rows/2),180,1)
    img3 = cv2.warpaffine(img1,matrix,(cols,rows))
    matrix = cv2.getrotationmatrix2d((cols/2,rows/2),270,1)
    img4 = cv2.warpaffine(img1,matrix,(cols,rows))
    如图4-9所示,把图像分别旋转90度、180度和270度,旋转的中心是原图像的中心。