cvUndistort2 () and cvRemap () crash

痞子三分冷 提交于 2019-12-01 12:59:43

The problem is that cvUndistort2 and cvRemap receive 8bit images only. Hence, in order to process color images, one must use cvSplit and cvMerge:

   IplImage *r = cvCreateImage(cvGetSize(image),8,1);//subpixel
   IplImage *g = cvCreateImage(cvGetSize(image),8,1);//subpixel
   IplImage *b = cvCreateImage(cvGetSize(image),8,1);//subpixel

   while(image) {
       cvShowImage( "Calibration", image ); // Show raw image
       //cvCvtColor(image, gray_image, CV_BGR2GRAY);
       cvSplit(image, r,g,b, NULL);

       cvRemap( r, r, mapx, mapy ); // Undistort image
       cvRemap( g, g, mapx, mapy ); // Undistort image
       cvRemap( b, b, mapx, mapy ); // Undistort image

       cvMerge(r,g,b, NULL, image);
   cvShowImage( "Undistort", image); // Show corrected image
Andros

try

cvRemap( t, image, mapx, mapy ); 
cvUndistort2(t ,image , intrinsic, distortion);

instead of

cvRemap( image, t, mapx, mapy ); // Undistort image
       cvUndistort2(image, t, intrinsic, distortion);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!