Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Issue with cv2DRotationMatrix

My code with cv2DRotationMatrix() compiles but always terminates with status -1073741515

I've tried many codes on the internet and in books but still the same.

I can't figure out where went wrong.

My code:

int main() {

IplImage *image, *image2;
CvMat *transmat;
CvPoint2D32f center;
double angle = 45.0;
double scale = 0.6;
image = cvLoadImage("lena.jpg",CV_LOAD_IMAGE_UNCHANGED);
if(!image){
    printf("Image open failed. Shutting down\n");
    system("PAUSE");
    return -1;
}
transmat = cvCreateMat(2,3,CV_32FC1);
image2 = cvCloneImage(image);
center.x = image->width/2;
center.y = image->height/2;

cv2DRotationMatrix(center,angle,scale,transmat);
cvWarpAffine(image, image2, transmat,image->nSize);
cvShowImage("Original",image);
cvShowImage("Rotated",image2);
cvWaitKey(0);
cvDestroyWindow("Original");
cvDestroyWindow("Rotated");
cvReleaseImage(&image);
cvReleaseImage(&image2);
cvReleaseMat(&transmat);
system("PAUSE");
return 0;

}

I'm using Code::Blocks under Win7.