我尝试使用相机姿势(位置和方向)转换3D点。 摄像头位置为(0,1400,0) 问题是投影的2D点没有标准化为(-1,1),其中0,0是屏幕的中心(图像)
这是我的方程式
std::vector<Ogre::Vector2> projectedFeaturePoints;
Core::CameraIntrinsics cameraIntrinsics = Core::EnvironmentInformation::getSingleton()->getCameraIntrinsics();
for (int i = 0; i < out.numberofpoints; i++)
{
Ogre::Vector4 pt;
pt.x = out.pointlist[i];
pt.y = out.pointlist[(3*i) + 1];
pt.z = out.pointlist[(3*i)+2];
pt.w = 1;
Ogre::Vector4 pnt = cameraPose.inverse()*pt;
float x = ((pnt.x - cameraPosition.x)*cameraIntrinsics.focalLength.x)/pnt.z + cameraPosition.x;
float y = ((pnt.y - cameraPosition.y)*cameraIntrinsics.focalLength.y)/pnt.z + cameraPosition.y;
projectedFeaturePoints.push_back(Ogre::Vector2(x,y));
}
一个样本值
Camera Position ( 0, 1400,0)
(Ogre::Vector4) pt = (x = 255.985977, y = -896.562255, z = 175.277557, w = 1)
(Ogre::Vector4) pnt = (x = 314.670929, y = -963.910278, z = -2083.82031, w = 1)
ProjectedPoint = (Ogre::Vector2) [0] = (x = -0.25423786, y = 1401.90991)