首页 > 解决方案 > 如何应用相机校准将图像中的二维点转换为方位矢量?

问题描述

我试图通过使用 EPNP 算法 OpenGV(不是 OpenCV)的 2D-3D 点对应来找出相机绝对旋转和平移。但是我的问题是我有 2D 和 3D 点,但是如果您查看存储库中绝对姿势查找算法的测试代码,它需要点的方位矢量。您会发现它生成随机 3D 点,并通过以下代码使用旋转和平移生成相机参考系中点的方位矢量。请检查以下代码。

for( size_t i = 0; i < (size_t) gt.cols(); i++ )
    gt.col(i) = generateRandomPoint( maxDepth, minDepth );

  //create the 2D3D-correspondences by looping through the cameras
  size_t numberCams = camOffsets.size();
  size_t camCorrespondence = 0;

  for( size_t i = 0; i < (size_t) gt.cols(); i++ )
  {
    //get the camera transformation
    translation_t camOffset = camOffsets[camCorrespondence];
    rotation_t camRotation = camRotations[camCorrespondence];

    //store the point
    points.push_back(gt.col(i));

    //project the point into the viewpoint frame
    point_t bodyPoint = rotation.transpose()*(gt.col(i) - position);

    //project the point into the camera frame
    bearingVectors.push_back(camRotation.transpose()*(bodyPoint - camOffset));

    //normalize the bearing-vector to 1
    bearingVectors[i] = bearingVectors[i] / bearingVectors[i].norm();

    //add noise
    if( noise > 0.0 )
      bearingVectors[i] = addNoise(noise,bearingVectors[i]);

    //push back the camera correspondence
    camCorrespondences.push_back(camCorrespondence++);
    if(camCorrespondence > (numberCams-1) )
      camCorrespondence = 0;
  }

方位矢量是从图像中获得的输入/测量值。有关方位矢量的详细说明,您可以在此处查看

所以我正在寻找一种方法来应用相机校准将二维点转换为方位矢量。

标签: c++matrixcomputer-visiongeometry

解决方案


推荐阅读