Ask Your Question
1

Issue with cv2DRotationMatrix

asked 2012-09-20 17:05:49 -0600

Egnatius gravatar image

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.

edit retag flag offensive close merge delete

Comments

It seems to work perfect after switching from 2.4.2 to 2.4.0.

Egnatius gravatar imageEgnatius ( 2012-09-20 19:42:50 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2012-09-21 05:06:16 -0600

Nghia gravatar image

The 4th parameter passed to cvWarpAffine looks wrong. The function definition is

void cvWarpAffine(const CvArr* src, CvArr* dst, const CvMat* mapMatrix, int flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, CvScalar fillval=cvScalarAll(0))

might not solve your original problem though.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-09-20 17:05:49 -0600

Seen: 1,199 times

Last updated: Sep 21 '12