views:

54

answers:

2

I am using those codes for rotation transforming an image, but it doesn't work. Waht is the problem?

IplImage *src = cvLoadImage("image.jpg",1),
         *dst = cvCloneImage(src);
CvMat *rotation_mat = cvCreateMat(2,3,CV_32FC1);
CvPoint2D32f center = cvPoint2D32f(src->width/2 ,src->height/2);
cvZero(dst);

double angle = -50.0,
       scale = 0.6;

cv2DRotationMatrix(center, angle, scale, rotation_mat);

cvWarpAffine(src, dst, rotation_mat);

cvNamedWindow("rotation");
cvShowImage("rotation",dst);
cvWaitKey(0);
cvReleaseMat(&rotation_mat);
cvReleaseImage(&src);
cvReleaseImage(&dst);
cvDestroyAllWindows();
return 0;
+1  A: 

Does it close right away? cvWaitKey(0) says "wait for the user press a key for 0 milliseconds". If it closes right away, try changing it to

while (cvWaitKey(100) != 27) { //Wait for the user to press ESC (ASCII code is 27)

}

This will loop infinitely until user presses ESC

waitinforatrain
it didn't work.
sundowatch
You haven't even posted your error, you're not even trying to understand it. laters.
waitinforatrain
A: 

Which codes will be in the while loop?

sundowatch
It's an empty loop
waitinforatrain