opencv: Rotate image by 90, 180 or 270 degrees
Opencv or by Image 90 rotate 180
2023-09-27 14:24:37 时间
opencv2:
void rotate_cw(const cv::Mat& image, cv::Mat& dest, int degrees) { switch (degrees % 360) { case 0: dest = image.clone(); break; case 90: cv::flip(image.t(), dest, 1); break; case 180: cv::flip(image, dest, -1); break; case 270: cv::flip(image.t(), dest, 0); break; default: cv::Mat r = cv::getRotationMatrix2D({image.cols/2.0F, image.rows/2.0F}, degrees, 1.0); int len = std::max(image.cols, image.rows); cv::warpAffine(image, dest, r, cv::Size(len, len)); break; //image size will change } }
opencv3:
void cv::rotate(InputArray src, OutputArray dst, int rotateCode )
Rotates a 2D array in multiples of 90 degrees. The function rotate rotates the array in one of three different ways: Rotate by 90 degrees clockwise (rotateCode = ROTATE_90). Rotate by 180 degrees clockwise (rotateCode = ROTATE_180). Rotate by 270 degrees clockwise (rotateCode = ROTATE_270).
Core.rotate(Mat src, Mat dst, Core.ROTATE_90_CLOCKWISE); //ROTATE_180 or ROTATE_90_COUNTERCLOCKWISE
相关文章
- 详解用OpenCV绘制各类几何图形
- 报错 cv2.error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function ‘drawMarker‘
- 【1】windows下安装OpenCV(4.3)+VS2017安装+opencv_contrib4.3.0配置
- 实战 | 电感元件定位--Halcon与OpenCV实现详解(附源码)
- C# OpenCV-EmguCV找圆应用实例(一) 基于轮廓拟合
- Halcon缺陷检测实例转OpenCV实现(六) 瓶口缺陷检测
- 使用Python,OpenCV在视频中进行实时条形码检测
- OpenCV之图像分割(五) 证件照背景替换
- 【Android OpenCV】Visual Studio 创建支持 OpenCV 库的 CMake 工程 ① ( 下载 OpenCV 库 | Windows 中安装 OpenCV 库 )
- opencv中的SVM图像分类(二)
- 【树莓派4B实现垃圾分类】Chap.0 项目概述 Tensorflow 1.14.0+Keras: 2.2.0+Opencv: 3.4+Python: 3.6+Numpy:1.16【深度学习 招式
- opencv-mean计算均值