cvUndistort2 () and cvRemap () crash

后端 未结 2 1562
情书的邮戳
情书的邮戳 2021-01-15 23:46

I was doing example 11-1 of \"Learning OpenCV\" by Bradski. Unfortunately the given example doesn\'t work on my computer.

The program is supposed to calibrate camera

相关标签:
2条回答
  • 2021-01-16 00:33

    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
    
    0 讨论(0)
  • 2021-01-16 00:51

    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);
    
    0 讨论(0)
提交回复
热议问题