python-opencv-旋转

Posted 天子骄龙

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python-opencv-旋转相关的知识,希望对你有一定的参考价值。

 


import cv2

img = cv2.imread(\'3.jpg\', 1)
cv2.imshow(\'src\', img)
imgInfo = img.shape
height= imgInfo[0]
width = imgInfo[1]
deep = imgInfo[2]
matRotate = cv2.getRotationMatrix2D((width*0.5, height*0.5), 45, 0.9) # 旋转变化矩阵
\'\'\'
参数1 必选参数。用于设置旋转中心点,点坐标为OpenCV图像坐标系下的坐标。
参数2 必选参数。用于设置旋转的角度,单位为度。
参数3 必选参数。用于设置缩放系数,即对旋转的图像进行缩放。
\'\'\'
dst = cv2.warpAffine(img, matRotate, (width,height)) #旋转
\'\'\'
参数2 变换矩阵:是一个2行3列的矩阵,由这个矩阵决定是何种变换
参数3 变换后输出图像的大小:(width,height)-->宽和高(自己规定)
\'\'\'
cv2.imshow(\'dst\',dst)


cv2.waitKey(0)
 

效果图:

 

 

 

 

以上是关于python-opencv-旋转的主要内容,如果未能解决你的问题,请参考以下文章

处理屏幕旋转上的片段重复(带有示例代码)

使用 ActionBar 旋转 Android 的双片段

Butterknife 片段旋转给出 NullPointer

python-opencv性能衡量和提升技术

Python-opencv学习第三十课:人脸检测

python-opencv实现简单的车牌定位