图像裁剪的 OpenCV 相机校准(ROI 子矩阵) [英] OpenCV camera calibration of an image crop (ROI submatrix)

查看:43
本文介绍了图像裁剪的 OpenCV 相机校准(ROI 子矩阵)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 OpenCV 的 undistort 函数时遇到了一点问题.我正在使用使用广角镜头的相机.假设我对它的访问是有问题的,因为它已经安装了.问题基本上归结为:

I have a bit of a problem working with OpenCV's undistort function. I am working with a camera using a wide angle lens. Let's say my access to it is problematic as it is already installed. The problem basically boils down to this:

我已经成功测量了所有镜头参数,并且可以毫无问题地使全帧图像不失真,问题是我实际上是在某种线扫描模式下工作.我们只在传感器中间使用了一个切口,大约 100 像素高.图片说明:

I have successfully measured all the lens parameters and can undistort a full frame image with no problem, the issue is I am actually working in sort of a linescan mode. We're using just a cut out in the middle of the sensor, about 100 px tall. Images for illustration:

现在,如果我对相关图像的 ROI(感兴趣区域)应用 undistort,它自然会假定它是全帧顶部的切口,因此校正与它应该是大不相同的全画幅高度的一半.

Now, if I apply undistort to the ROI (Region of interest) of the image in question it naturally assumes it is a cutout at the top of the full frame, therefore the correction is massively different to what it should be about a halfway down the height of the full frame.

如果我只使用较低分辨率的全帧,我了解如何修改相机矩阵以补偿图像比例,但问题是:我能否以任何方式补偿裁剪的部分偏移以实现正确的转换?

I understand how I can modify the camera matrix to compensate for image scale were I using just a lower resolution full frame, but the question is: Can I compensate for a cropped out part shift in any way to achieve correct transformation?

我想我可以使用全帧分辨率的黑色图像,然后将相关数据复制到其中,但这是不可能的,因为这样会影响处理速度.

I figured I could use a black image with full frame resolution and just copy the relevant data to the middle of it, but that is out of the question as the processing speed would take too much of a hit that way.

感谢您的任何见解!

干杯,一月.

推荐答案

如果你裁剪图像,那么主点将有不同的坐标.例如,如果您的原始主点位于 (30,40),并且您在两侧裁剪 10 个像素,那么您的新主点将位于 (20,30),因为像素 (20,30) 在裁剪后的图像与原始图像中的像素 (30,40) 相同.

If you crop the image, then the principal point is going to have different coordinates. For example, if your original principal point was at (30,40), and you crop 10 pixels around the sides, then your new principal point is going to be at (20,30), because the pixel (20,30) in the cropped image is the same as pixel (30,40) in the original image.

您需要相应地调整相机矩阵中的 cx an cy 值.

You need to adjust the cx an cy values in your camera matrix accordingly.

这篇关于图像裁剪的 OpenCV 相机校准(ROI 子矩阵)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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