问题描述
在使用OpenCV的undistort函数时,我有点问题.我正在使用使用广角镜的相机.假设我对它的访问存在问题,因为它已经安装.问题基本上可以归结为:
我已经成功测量了所有镜头参数,并且可以毫无扭曲地显示全帧图像,问题是我实际上是在使用线扫描模式工作的.我们仅在传感器中间使用一个切口,大约100 px高.插图图片:
现在,如果我对所讨论图像的ROI(感兴趣区域)应用不失真,则自然会认为它是全帧顶部的切口,因此校正与对图像的校正有很大不同.在整个框架的高度的一半处.
如果我仅使用较低分辨率的全帧图像,我了解如何修改相机矩阵以补偿图像比例,但是问题是:我可以以任何方式补偿裁剪出的零件偏移以实现正确的转换吗? /p>
我认为我可以使用具有全帧分辨率的黑色图像,然后将相关数据复制到中间,但这是不可能的,因为这样会影响处理速度.
感谢您的见解!
干杯,一月.
如果裁剪图像,则主要点将具有不同的坐标.例如,如果您的原始主点位于(30,40),并且在边上裁切了10个像素,那么您的新主点将位于(20,30),因为像素(20,30)位于裁剪后的图像与原始图像中的像素(30,40)相同.
您需要相应地调整相机矩阵中的cx和cy值.
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:
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:
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.
Thanks for any insights!
Cheers,Jan.
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.
You need to adjust the cx an cy values in your camera matrix accordingly.
这篇关于图像裁剪的OpenCV摄像机校准(ROI子矩阵)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!