使用OpenCV解除/纠正图像 [英] Undistorting/rectify images with OpenCV

查看:915
本文介绍了使用OpenCV解除/纠正图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我举了校准相机和解除这本书图片的代码示例: shop.oreilly .com / product / 9780596516130.do

I took the example of code for calibrating a camera and undistorting images from this book: shop.oreilly.com/product/9780596516130.do

据我所知,OpenCV的通常的相机校准方法对于普通相机完美地工作。
当谈到Fisheye-Lenses,虽然我们必须使用一个8校准参数的矢量,而不是5,并且方法<$ c $中的标志 CV_CALIB_RATIONAL_MODEL c> cvCalibrateCamera2 。
至少,这是它在 OpenCV纪录片

As far as I understood the usual camera calibration methods of OpenCV work perfectly for "normal" cameras. When it comes to Fisheye-Lenses though we have to use a vector of 8 calibration parameters instead of 5 and also the flag CV_CALIB_RATIONAL_MODEL in the method cvCalibrateCamera2. At least, that's what it says in the OpenCV documentary

在像这样的图像阵列上(从OCamCalib )我使用 cvInitUndistortMap 获得以下结果: abload.de/img/rastere4u2w.jpg

So, when I use this on an array of images like this (Sample images from OCamCalib) I get the following results using cvInitUndistortMap: abload.de/img/rastere4u2w.jpg

由于生成的图像是从整个未失真的图像中剪切出来的,我继续使用 cvInitUndistortRectifyMap (如此处所述 stackoverflow.com/questions/8837478 / opencv-cvremap-cropping-image )。所以我得到了以下结果: abload.de/img/rasterxisps.jpg

Since the resulting images are cut out of the whole undistorted image, I went ahead and used cvInitUndistortRectifyMap (like it's described here stackoverflow.com/questions/8837478/opencv-cvremap-cropping-image). So I got the following results: abload.de/img/rasterxisps.jpg

现在我的问题是:为什么整个图像不失真?在我以后的结果的一些照片,你可以认识到,例如笔记本电脑仍然完全扭曲。我如何使用标准的OpenCV方法,使用更好的结果?

And now my question is: Why is not the whole image undistorted? In some pics of my later results you can recognize that the laptop for example is still totally distorted. How can I acomplish even better results using the standard OpenCV methods?

我是新的stackoverflow和我是新的OpenCV,所以请原谅我的任何

I'm new to stackoverflow and I'm new to OpenCV as well, so please excuse any of my shortcomings when it comes to expressing my problems.

推荐答案


  1. 所有棋盘角都应该是可见的被发现。算法期望一定大小的棋盘,例如4x3或7x6(例如)。棋盘周围的白色边框应该是可见的,否则可能无法精确定义深色方块。

  1. All chessboard corners should be visible to be found. The algorithm expect a certain size of chessboard such as 4x3 or 7x6 (for example). The white border around a chess board should be visible too or dark squares may not be defined precisely.

在undistort()之后,图像周围仍然有高失真,因为失真是径向的(即它们随半径增加) 。后者是错误的,因为校准过程最小化像素坐标中的平方误差的总和,并且您没有表示具有足够样本的外围。

You still have high distortions at the image periphery after undistort() since distortions are radial (that is they increase with the radius) and your found coefficients are wrong. The latter are wrong since a calibration process minimizes the sum of squared errors in pixel coordinates and you did not represent the periphery with enough samples.

TODO:如果使用8 distCoeff,则必须有20-40个棋盘图案。以不同的角度倾斜你的板,把它们放在不同的距离,并将它们展开,特别是在周边。请记住,校准的成功取决于抽样,也取决于您的棋盘上的消失点因此倾斜和倾斜)

TODO: You have to have 20-40 chess board pattern images if you use 8 distCoeff. Slant your boards at different angles, put them at different distances and spread them around, especially at the periphery. Remember, the success of calibration depends on sampling and also on seeing vanishing points clearly from your chess board (hence slanting and tilting).

这篇关于使用OpenCV解除/纠正图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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