OpenCV3.0.0dev中对鱼眼镜头模型的主要参考是什么? [英] What are the main references to the fish-eye camera model in OpenCV3.0.0dev?

查看:497
本文介绍了OpenCV3.0.0dev中对鱼眼镜头模型的主要参考是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 OpenCV 3.0.0.dev 中使用的鱼眼镜头型号而苦恼.我已多次阅读此链接中的文档,尤其是详细说明" 部分和公式化鱼眼失真的模型.到目前为止,我有两个问题:

I am wrestling with the Fish-Eye Camera Model used in OpenCV 3.0.0.dev. I have read the documentation in this link several times, especially the "Detailed Description" part and formulas modeling fish-eye distortion. By now I have two concerns:

  1. 基于此处列出的投影模型及其"鱼眼透镜模型的准确性"通过休斯,我不知道OpenCV实施中使用了哪种投影模型.

  1. Based on the projection models listed here and their conceptual explanations in "Accuracy of Fish-Eye Lens Model" By Hughes, I can't figure out which projection model has been used in the OpenCV implementation.

由于描述非常简洁,因此我需要了解OpenCV开发人员用于实现鱼眼名称空间的主要参考文件,这样我才可以参与其中并获得通过更多细节. P.S.我检查了OpenCV 3.0.0-dev文档,但没有发现任何有用的信息.

Since the description is so concise, I need to know the main reference papers used by OpenCV developers for implementing fish-eye namespace, so that I could be on the ball and get through more details. P.S. I checked OpenCV 3.0.0-dev documentation and did not find anything useful.

推荐答案

简短答案:

OpenCV 3.0.0 Fisheye摄像机模型不使用Brown模型,也不使用OP从Panotools引用的任何模型,它使用Juho Kannala和Sami S. Brandt的通用摄像机模型.

Short answer:

OpenCV 3.0.0 Fisheye camera model doesn't use the Brown model nor any of the models that the OP refers from Panotools, it uses a Generic Camera Model by Juho Kannala and Sami S. Brandt.

Cfr 在他的回答中指出,此Ilya Krylov(在OpenCV中实现了鱼眼模型)的评论说,他们移植了Jean-Yves Bouguet的用于Matlab的相机校准工具箱:

As Cfr points in his answer, this comment from Ilya Krylov (who implemented the fisheye model in OpenCV) says they ported the Camera Calibration Toolbox for Matlab of Jean-Yves Bouguet:

Jean-Yves Bouguet网站(链接),依次提到了用于常规,宽幅的通用相机模型和校准方法-角度和鱼眼镜头,然后说:

Jean-Yves Bouguet website (link), in turn, mentions the paper A Generic Camera Model and Calibration Method for Conventional, Wide-Angle, and Fish-Eye Lenses, and says :

在此非常好的论文中,校准工具箱中包含的未记录"鱼眼模型遵循等式(3)描述的等距投影模型.失真模型遵循等式(6),除了k1 = 1(否则与f不可区分).

The "undocumented" fisheye model contained in the calibration toolbox follows the equidistance projection model described by equation (3) in this very nice paper. The distortion model follows equation (6), to the exception that k1=1 (otherwise indistinguishable from f).

我认为这是一种误导性陈述或一个简单的误解,因为等式(3)和等式(6)对应于不同的模型:等式(6)是本文介绍的实际模型,作者将其称为 >通用相机型号" (因此,纸张名称为该名称). 更准确地说,方程式(6)用作相机模型,方程式(8)和(9)用作该模型的变形"或偏离.

Which in my opinion is a misleading statement or a plain misconception as equation(3) and equation(6) correspond to different models: equation (6) is the actual model introduced in this paper which the authors refer as the Generic Camera Model (hence the name of the paper). To be more precise, equation (6) was meant to be used as the camera model and equation (8) and (9) as the "distortion" or deviation from this model.

但是冒险之旅还没有结束. OpenCV的实现(根据其文档)首先计算针孔投影以找到视场角(3D点,投影中心和光轴之间的角度). 这意味着您不能使用其鱼眼模型以90º投射光线(否则将被0除)或接近90º(可能发生数值稳定性问题,例如溢出)如果z足够小). 此外,我不确定它是否可以在超过90º的光线下工作. 所有这些使我真的很奇怪他们的鱼眼镜头模型对鱼眼镜头或广角镜的实用性".

But the odyssey is not over. OpenCV's implementation (according to its documentation) first computes the pinhole projection to find the field angle (the angle between the 3D point, the center of projection and the optical axis). This means you can't use their fisheye model to project rays at 90º (or you would divide by 0) or close to 90º (numerical stability problems, like overflow could happen if z is small enough). Moreover I'm not sure whether it will work for rays for more than 90º. All this makes me really wonder the "usefulness" of their fisheye camera model for fisheye or wide angle lenses.

如果您对此表示怀疑,可以查看OpenCV的源代码,具体地请参见

In case you're skeptic about that you can take a look at OpenCV's source code, concretely at sources\modules\calib3d\src\fisheye.cpp (I added some comments)

void cv::fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints, InputArray _rvec,
InputArray _tvec, InputArray _K, InputArray _D, double alpha, OutputArray jacobian)
{
    ...
    Rodrigues(om, R, dRdom);
    Affine3d aff(om, T);
    ...
    Vec3d Xi = objectPoints.depth() == CV_32F ? (Vec3d)Xf[i] : Xd[i];
    Vec3d Y = aff*Xi; /* To transform to camera reference frame*/

    Vec2d x(Y[0]/Y[2], Y[1]/Y[2]); /* <- The root of all evil (division by z) */

    double r2 = x.dot(x);
    double r = std::sqrt(r2);

    // Angle of the incoming ray:
    double theta = atan(r);

    double theta2 = theta*theta, theta3 = theta2*theta, theta4 = theta2*theta2, theta5 = theta4*theta,
            theta6 = theta3*theta3, theta7 = theta6*theta, theta8 = theta4*theta4, theta9 = theta8*theta;

    double theta_d = theta + k[0]*theta3 + k[1]*theta5 + k[2]*theta7 + k[3]*theta9;

    double inv_r = r > 1e-8 ? 1.0/r : 1;
    double cdist = r > 1e-8 ? theta_d * inv_r : 1;

    Vec2d xd1 = x * cdist;
    Vec2d xd3(xd1[0] + alpha*xd1[1], xd1[1]);
    Vec2d final_point(xd3[0] * f[0] + c[0], xd3[1] * f[1] + c[1]);
    ...
}

更新:拉取请求可解决此问题射线的角度≥90º.截至2018年4月,它尚未合并到master中,但正在考虑用于OpenCV 4.x 校准模块(请检查校准模块讨论也是

Update: This pull request fixes the problem with rays at angles ≥ 90º. As of April 2018 it hasn't been merged into master yet but is being considered for OpenCV 4.x Calibration Module (check calibration module discussion too)

这篇关于OpenCV3.0.0dev中对鱼眼镜头模型的主要参考是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆