OpenCV:如果我知道 Gimp 中的镜头校正系数,如何为“不失真"提供矩阵? [英] OpenCV : how to provide matrix for 'undistort' if I know lens correction factor in Gimp?

查看:75
本文介绍了OpenCV:如果我知道 Gimp 中的镜头校正系数,如何为“不失真"提供矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从具有强烈鱼眼效果的 IP 摄像机获取图像.我发现在 Gimp 中,通过应用主要"值为 -30 的镜头失真"过滤器(所有其他参数保持为零),我可以获得大部分直线.

I'm getting images from an IP camera that have a strong fish-eye effect. I found that in Gimp I can get lines mostly straight by applying the Lens Distortion filter with a "main" value of -30 (all other parameters remain zero).

现在我需要使用 OpenCV 临时执行此操作.我收集到 undistort 函数在 imgproc 将是正确的调用方式.但是如何生成正确的相机和失真矩阵?我看到有一个 calibrateCamera 功能,但它似乎您需要计算机视觉博士学位才​​能使用它.我没有任何线索.既然我知道一个参数,那么一定有一种简单的方法可以将其转换为 'undistort' 所期望的矩阵吗?

Now I need to do this ad-hoc using OpenCV. I gathered that the undistort function in imgproc would be the right thing to call. But how do I generate the correct camera and distortion matrix? I see there is a calibrateCamera function, but it seem you need a PhD in computer vision or so to use it. I have no clue. Since I know the one parameter, there must be a simple way to translate it into the matrix expected by 'undistort'?

注意:我只需要径向畸变系数,我对切向畸变不感兴趣.

Note: I only need the radial distortion coefficients, I'm not interested in the tangential distortion.

推荐答案

opencv 提供了一个示例用于 校准.为此,您只需要棋盘格图像的列表(大约 20 个应该不错).由您想要的相机拍摄.它将为您提供所有必需的参数(失真系数、内在参数等).然后您可以使用 opencv 的undistort"功能来校正您的图像.您需要在 default.xml 中更改(或者您可以创建自己的 .xml)xml 文件的名称,其中包含您的图像地址、内部方块的数量及其在现实世界中的尺寸.

There is a sample provided by opencv for calibration. For that all you need is the list of the images of checkerboard(around 20 should be good). taken by your desired camera. It will give you all the required parameters( distortion coefficients, intrinsic parameters etc.). Then you can use 'undistort' function of opencv to correct your image. You need to change in default.xml,(or you can create your own .xml) the name of the xml file containing the address of your images, the count of inner squares and their dimension in real world.

tadaa 你有你需要的参数 :-)

tadaa you have you required parameters :-)

这篇关于OpenCV:如果我知道 Gimp 中的镜头校正系数,如何为“不失真"提供矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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