matlab - 如何从 Scaramuzza 全向相机校准工具箱中消除未失真全景图像的底部失真?
问题描述
Scaramuzza 全向相机标定工具箱已用于标定和保存相机参数。然后使用这些参数从 180 度 FOV 鱼眼相机中获取全景视图。我从这里遵循了全向相机校准教程。如何使全景图像的底部不失真?或者我怎样才能不扭曲一些特定的图像点?
解决方案
以下代码可用于获取未失真的全景图像:
#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;
};
推荐阅读
- r - 计算字符串组合的频率
- c# - 将反射属性投射到 ObservableCollection
- delphi - 滚动框鼠标滚轮delphi
- c++ - 使用 gcc 是否可以链接库,但前提是它存在?
- java - 如何从 HashMap 中的对象访问 ArrayList?JAVA
- mysql - MySQL防止插入重复字段
- java - 如何获取与作为参数传递的列表的所有值匹配的行?
- java - 如何在 Android 上创建和显示乐谱
- kubernetes - 如果我的 kubernetes Pod 有四个容器中的一个不健康容器会发生什么?
- firebase - 基于角色的身份验证取决于 google cloud firestore 规则中的组