I have image at IplImage (there is not problem to convert it to Mat). I have to rotate my image. I have image:
IplImage* mg
My method for rotate:
IplImage *rotateImage2(const IplImage *src, float angleDegrees)
{
// Create a map_matrix, where the left 2x2 matrix
// is the transform and the right 2x1 is the dimensions.
float m[6];
CvMat M = cvMat(2, 3, CV_32F, m);
int w = src->width;
int h = src->height;
float angleRadians = angleDegrees * ((float)CV_PI / 180.0f);
m[0] = (float)(cos(angleRadians));
m[1] = (float)(sin(angleRadians));
m[3] = -m[1];
m[4] = m[0];
m[2] = w*0.5f;
m[5] = h*0.5f;
// Make a spare image for the result
CvSize sizeRotated;
sizeRotated.width = cvRound(w);
sizeRotated.height = cvRound(h);
// Rotate
IplImage *imageRotated = cvCreateImage(sizeRotated,
src->depth, src->nChannels);
// Transform the image
cvGetQuadrangleSubPix(src, imageRotated, &M);
return imageRotated;
}
But after rotate my new image have incorrect resolution. Rotation occurs in this resolution, but my new image have to take new resolution. Test image(original image - center, left image - rotated by my method, right image - rotated by system service): U can see, that my new image crop hat of man, and new image have bigger width. How i could rotate my image without this problem?