因为需要将函数进行右转,发现opencv自带 的过于麻烦。自己写了个右转的。可以根据这个想法写出任何方向的
1 //函数功能,右转图片 2 IplImage* convertImage(IplImage* image) 3 { 4 CvSize size = cvGetSize(image); 5 IplImage* ori_image = cvCreateImage(cvSize(size.width / 2, size.height / 2), image->depth, image->nChannels); 6 IplImage* cvt_image = cvCreateImage(cvSize(size.height / 2, size.width / 2), image->depth, image->nChannels); 7 cvResize(image, ori_image); 8 int x, y, w; 9 for (y = ori_image->height; y >= 0; y--) 10 { 11 uchar* oriptr = (uchar*)(ori_image->imageData + y*ori_image->widthStep); 12 for (x = 0; x < ori_image->width; x++) 13 { 14 uchar* curptr = (uchar*)(cvt_image->imageData + x*cvt_image->widthStep); 15 curptr[3 * y] = oriptr[3 * x]; 16 curptr[3 * y + 1] = oriptr[3 * x + 1]; 17 curptr[3 * y + 2] = oriptr[3 * x + 2]; 18 } 19 } 20 cvReleaseImage(&image); 21 cvReleaseImage(&ori_image); 22 return cvt_image; 23 }
时间: 2024-10-10 08:30:56