2010-03-12 86 views
0

我正在使用這些代碼來旋轉圖像,但它不起作用。 Waht是問題嗎?OpenCV旋轉解決方案?

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; 
+0

您需要更具體與您的問題並表現出一定願意理解代碼,如果你想獲得好的答案 – bcoughlan 2010-03-13 00:49:57

回答

1

立即關閉嗎? cvWaitKey(0)表示「等待用戶按下一個鍵0毫秒」。如果關閉馬上,嘗試將其更改爲

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

} 

這將無限循環播放,直到用戶按ESC

+0

它沒有工作。 – sundowatch 2010-03-14 16:49:58