openCV 图像处理 翻转,旋转

flip 翻转

摄像头显示左右反了,用这个沿Y轴翻转 就可以

void cv::flip(
cv::InputArray src, // Input array
cv::OutputArray dst, // Result array, size and type of 'src'
int flipCode = 0 // >0: y-flip, 0: x-flip, <0: both
);
This function flips an image around the x-axis, the y-axis, or both. By default, flip
Code is set to 0, which flips around the x-axis.
If flipCode is set greater than zero (e.g., +1), the image will be flipped around the yaxis, and if set to a negative value (e.g., –1), the image will be flipped about both axes.
When doing video processing on Win32 systems, you will find yourself using this
function often to switch between image formats with their origins at the upper left
and lower left of the image
//flip_mode 指定数组翻转模式
//flip_mode > 0 :沿Y轴翻转
//flip_mode = 0 :沿X轴翻转
//flip_mode < 0 :沿X轴和Y轴翻转(以0,0为顶点, 翻转)
cv::Mat SrcImage,destImage;
//init srcImage by camera (or picture *.jpeg...)
cv::flip(SrcImage, destImage, 1);

rotate 旋转图像,(无法沿X轴或者Y轴反转)

enum RotateFlags {
ROTATE_90_CLOCKWISE = 0, //Rotate 90 degrees clockwise
ROTATE_180 = 1, //Rotate 180 degrees clockwise
ROTATE_90_COUNTERCLOCKWISE = 2, //Rotate 270 degrees clockwise
};
cv::rotate(SrcImage, DestImage, ROTATE_180);

以上都是cpp接口,c接口cv_flip, cv_rotate

接口具体信息 在头文件中都有说明。

posted @   scott_h  阅读(115)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
历史上的今天:
2018-11-04 Jlink flash 烧录HEX 程序
2015-11-04 process thread Fiber(linux)
点击右上角即可分享
微信分享提示