OpenCV camera calibration of an image crop (ROI submatrix)

时光怂恿深爱的人放手 提交于 2020-01-01 17:00:09

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/22437737/opencv-camera-calibration-of-an-image-crop-roi-submatrix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!