首页 > 解决方案 > 如何从 Scaramuzza 全向相机校准工具箱中消除未失真全景图像的底部失真?

问题描述

原始图像

未失真的图像

Scaramuzza 全向相机标定工具箱已用于标定和保存相机参数。然后使用这些参数从 180 度 FOV 鱼眼相机中获取全景视图。我从这里遵循了全向相机校准教程。如何使全景图像的底部不失真?或者我怎样才能不扭曲一些特定的图像点?

标签: matlabopencvcamera-calibration

解决方案


以下代码可用于获取未失真的全景图像:

#include <stdlib.h>
#include <stdio.h>
#include <float.h>
#include <math.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>


void create_panoramic_undistortion_LUT(CvMat* mapx, CvMat* mapy, float Rmin, float 
Rmax, float xc, float yc)
{
int i, j;
float theta;
int width = mapx->width;
int height = mapx->height;
float* data_mapx = mapx->data.fl;
float* data_mapy = mapy->data.fl;
float rho;

for (i = 0; i < height; i++)
    for (j = 0; j < width; j++)
    {
        theta = -((float)j) / width * 2 * 3.1416; // Note, if you would like to flip 
the image, just inverte the sign of theta
        rho = Rmax - (Rmax - Rmin) / height * i;
        *(data_mapx + i * width + j) = yc + rho * sin(theta); //in OpenCV "x" is the
        *(data_mapy + i * width + j) = xc + rho * cos(theta);
    }
}


int main() {


IplImage* src1 = cvLoadImage("test_catadioptric6.jpg");
CvSize size_pan_image = cvSize(1100, 400);        // size of the undistorted 
panoramic image
IplImage* dst_pan = cvCreateImage(size_pan_image, 8, 3);    // undistorted panoramic 
image
CvMat* mapx_pan = cvCreateMat(dst_pan->height, dst_pan->width, CV_32FC1);
CvMat* mapy_pan = cvCreateMat(dst_pan->height, dst_pan->width, CV_32FC1);
float Rmax = 920;  // the maximum radius of the region you would like to undistort 
into a panorama
float Rmin = 150;
float xc = 959;
float yc = 959;
create_panoramic_undistortion_LUT(mapx_pan, mapy_pan, Rmin, Rmax, xc, yc);

cvRemap(src1, dst_pan, mapx_pan, mapy_pan, CV_INTER_LINEAR + CV_WARP_FILL_OUTLIERS, 
cvScalarAll(0));
CvSize size_pan = cvSize(800, 800);
IplImage* dst = cvCreateImage(size_pan, 8, 3);

cvResize(src1, dst, CV_INTER_LINEAR);


cvNamedWindow("Original Catadioptric camera image", 1);
cvShowImage("Original Catadioptric camera image", dst);
cvNamedWindow("Undistorted Panoramic Image", 1);
cvShowImage("Undistorted Panoramic Image", dst_pan);
cvWaitKey();
cvReleaseImage(&src1);
cvReleaseImage(&dst_pan);
cvReleaseMat(&mapx_pan);
cvReleaseMat(&mapy_pan);
return 0;

};

不失真的全景


推荐阅读