用相机内部/外部重新扭曲点 [英] Re-distort points with camera intrinsics/extrinsics

查看:102
本文介绍了用相机内部/外部重新扭曲点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出一组2D点,如何应用undistortPoints的反面?

Given a set of 2D points, how can I apply the opposite of undistortPoints?

我拥有相机的内在特性和distCoeffs,并且想要(例如)创建一个正方形,并使其变形,就好像照相机是通过镜头查看它一样.

I have the camera intrinsics and distCoeffs and would like to (for example) create a square, and distort it as if the camera had viewed it through the lens.

我在这里找到了一个变形"补丁: http://code.opencv.org/issues /1387 ,但这似乎仅对图像有用,我想处理稀疏点.

I have found a 'distort' patch here : http://code.opencv.org/issues/1387 but it would seem this is only good for images, I want to work on sparse points.

推荐答案

这个问题已经很老了,但是由于我从谷歌搜索中来到这里,却没有看到一个简洁的答案,所以我还是决定回答这个问题.

This question is rather old but since I ended up here from a google search without seeing a neat answer I decided to answer it anyway.

有一个名为 projectPoints 可以做到这一点. OpenCV在使用诸如 stereoCalibrate

There is a function called projectPoints that does exactly this. The C version is used internally by OpenCV when estimating camera parameters with functions like calibrateCamera and stereoCalibrate


要将2D点用作输入,我们可以使用 convertPointsToHomogeneous ,并使用projectPoints且不旋转也不翻译.


To use 2D points as input, we can set all z-coordinates to 1 with convertPointsToHomogeneous and use projectPoints with no rotation and no translation.

cv::Mat points2d = ...;
cv::Mat points3d;
cv::Mat distorted_points2d;
convertPointsToHomogeneous(points2d, points3d);
projectPoints(points3d, cv::Vec3f(0,0,0), cv::Vec3f(0,0,0), camera_matrix, dist_coeffs, distorted_points2d);

这篇关于用相机内部/外部重新扭曲点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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