openCV center of image rotation in C
Posted
by
user1477955
on Stack Overflow
See other posts from Stack Overflow
or by user1477955
Published on 2012-12-15T12:41:04Z
Indexed on
2012/12/15
17:03 UTC
Read the original article
Hit count: 168
I want to rotate 90 degrees counterclockwise, but it seems the rotation point is wrong. How do I find the rotation center of the source image?
img=cvLoadImage(argv[1],-1);
height = img->height;
width = img->width;
step = img->widthStep;
channels = img->nChannels;
data = (uchar *)img->imageData;
IplImage *rotatedImg = cvCreateImage(cvSize(height,width), IPL_DEPTH_8U,img->nChannels);
CvPoint2D32f center;
center.x = width/2;
center.y = height/2;
CvMat *mapMatrix = cvCreateMat( 2, 3, CV_32FC1 );
cv2DRotationMatrix(center, 90, 1.0, mapMatrix);
cvWarpAffine(img, rotatedImg, mapMatrix, CV_INTER_LINEAR + CV_WARP_FILL_OUTLIERS, cvScalarAll(0));
cvShowImage("My image", rotatedImg );
© Stack Overflow or respective owner