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 @ 2023-11-04 18:24  scott_h  阅读(91)  评论(0编辑  收藏  举报