OpenCV 项目点的逆向 [英] Reverse of OpenCV projectPoints

查看:139
本文介绍了OpenCV 项目点的逆向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相机对着棋盘.我知道点的世界 3d 位置以及相机图像上相应投影点的 2d 位置.所有世界点都属于同一平面.我使用solvePnP:

I have a camera facing the equivalent of a chessboard. I know the world 3d location of the points as well as the 2d location of the corresponding projected points on the camera image. All the world points belong to the same plane. I use solvePnP:

Matx33d camMat;
Matx41d distCoeffs;
Matx31d rvec;
Matx31d tvec;
std::vector<Point3f> objPoints;
std::vector<Point2f> imgPoints;
solvePnP(objPoints, imgPoints, camMat, distCoeffs, rvec, tvec);

然后我可以使用 projectPoints 从 3d 世界点到 2d 图像点:

I can then go from the 3d world points to the 2d image points with projectPoints:

std::vector<Point2f> projPoints;
projectPoints(objPoints, rvec, tvec, camMat, distCoeffs, projPoints);

projPoints 非常接近 imgPoints.

projPoints are very close to imgPoints.

如何使用与属于同一平面的 3d 世界点相对应的屏幕点进行相反的操作.我知道从单一的角度来看,不可能重建 3d 位置,但在这里我在同一平面上,所以这确实是一个 2d 问题.我可以计算反向旋转矩阵以及反向平移向量,但我该如何继续?

How can I do the reverse with a screen point that corresponds to a 3d world point that belongs to the same plane. I know that from a single view, it's not possible to reconstruct the 3d location but here I'm in the same plane so it's really a 2d problem. I can calculate the reverse rotation matrix as well as the reverse translation vector but then how can I proceed?

Matx33d rot;
Rodrigues(rvec, rot);
Matx33d camera_rotation_vector;
Rodrigues(rot.t(), camera_rotation_vector);
Matx31d camera_translation_vector = -rot.t() * tvec;

推荐答案

这个问题似乎是另一个 Stackoverflow 问题的重复,其中提问者很好地提供了解决方案.这是链接:答案在这里:计算 x,y 坐标 (3D) from图像点

This question seems to be a duplicate of another Stackoverflow question in which the asker provides nicely the solution. Here is the link: Answer is here: Computing x,y coordinate (3D) from image point

这篇关于OpenCV 项目点的逆向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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