以下是我的EmguCV ( OpenCV的C# 端口) 解决方案:public static Image Rotate90(this Image img)
where TColor : struct, IColor
where TDepth : new()
{
var rot = new Image(img.Height, img.Width);
CvInvoke.cvTranspose(img.Ptr, rot.Ptr);
rot._Flip(FLIP.HORIZONTAL);
return rot;
}
public static Image Rotate180(this Image img)
where TColor : struct, IColor
where TDepth : new()
{
var rot = img.CopyBlank();
rot = img.Flip(FLIP.VERTICAL);
rot._Flip(FLIP.HORIZONTAL);
return rot;
}
public static void _Rotate180(this Image img)
where TColor : struct, IColor
where TDepth : new()
{
img._Flip(FLIP.VERTICAL);
img._Flip(FLIP.HORIZONTAL);
}
public static Image Rotate270(this Image img)
where TColor : struct, IColor
where TDepth : new()
{
var rot = new Image(img.Height, img.Width);
CvInvoke.cvTranspose(img.Ptr, rot.Ptr);
rot._Flip(FLIP.VERTICAL);
return rot;
}
把它翻译成 C++ 应该不难。