OpenCv C++透视变换
我正在尝试使用 OpenCv 校正图像的失真,然后计算给定像素坐标的真实世界坐标。我在网上或 OpenCv 书中找不到任何关于如何执行此操作的示例。
我已经用棋盘图像完成了相机校准。现在,我只需要一个基本函数,我可以为其提供像素坐标,该函数将根据相机矩阵、畸变系数、旋转和平移向量为我提供真实世界坐标。
有谁知道该怎么做?
I am trying to use OpenCv to correct an image for distortion and then calculate the real world coordinates given a pixel coordinate. I can not find any examples online or in the OpenCv book of how to do this.
I have done the camera calibration with the chess board image. Now, I just need a basic function that I can give pixel coordinates to that will give me real world coordinates based off of the camera matrix, the distortion coefficients, rotational and translation vectors.
Does anyone know how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看一下
findHomography()
函数。如果您知道一组点在现实世界中的位置,则可以使用此函数创建可与函数perspectiveTransform()
一起使用的变换矩阵。您可以找到有关函数 此处
Take a look at the
findHomography()
function. If you know the location in the real world of a set of points you can use this function to create transformation matrix that you can use with the functionperspectiveTransform()
You can find more information about the function here
据我正确理解,你需要一个来自图像点的世界点。对于单目相机来说这个问题是无法解决的。您无法确定现实世界点到相机的深度(距离)。
有些视觉同步定位与建图 (SLAM) 算法可以创建世界地图并根据视频计算摄像机的轨迹,但它们完全是另一回事。
As I understand correctly you need a world point from image point. With a monocular camera this problem is unsolvable. You can not determine the depth (distance) of the real world point to the camera.
There are visual simultaneous localization and mapping (SLAM) algorithms that create a map of the world and compute the trajectory of the camera from a video, but they are a whole other thing.
给定一个图像及其上的一个点(以 2D 像素坐标表示),现实世界中存在无限多个 3D 点,所有这些点都属于一条线,映射到图像中的点...而不仅仅是一个观点。
Given a single image and a point on it, expressed in terms of 2D pixel coordinates, there is an infinity of 3D points in the real world, all belonging to a line, which map to your point in your image... not just one point.
但是,如果您知道物体距相机的距离(以像素 (x,y) 为单位),则可以计算其 3D 位置。
But, if you know the distance of the object in pixel (x,y) from the camera then you can calculate its location in 3D.