opencv图片旋转90度,180度,270度

网上关于opencv图片旋转的代码有很多,但是对于像90度,180度,270度的这样特殊的角度用opencv自带的cvTranspose和cvFlip就可以很容易实现旋转了,cvFlip的第三个参数1,2,3分别对应90度,180度,270度,下面是图片旋转90度简单的例子:

#include "cv.h"
#include "highgui.h"
int main()
{
	IplImage* src = cvLoadImage("threshold12.bmp",-1);
	IplImage* srcCopy = cvCreateImage(cvSize(src->height, src->width),src->depth, src->nChannels);
	cvTranspose(src, srcCopy);
	cvFlip(srcCopy, NULL, 1);

	cvNamedWindow("result");
	cvShowImage("result", srcCopy);
	cvSaveImage("rotate.bmp", srcCopy);
	cvWaitKey();

	return 0;
}


你可能感兴趣的:(opencv)