【问题标题】:Projecting a 2D point from a marker to the image with computed homography使用计算单应性将 2D 点从标记投影到图像
【发布时间】:2012-08-19 21:58:24
【问题描述】:

我有一个平面标记,我已在其中运行 SIFT 算法来提取特征。然后我运行一个检测器在场景中找到这个标记并再次提取特征。我使用findHomography() 匹配这些点并使用 OpenCV 从匹配对中提取 homography

现在我想用计算的单应性投影标记中检测到的 2D 点,以将位置与从场景中测量的 3D 点进行比较,并计算重投影误差。我对像素坐标、厘米、校准矩阵感到困惑,我不知道我应该先进行哪些转换。

有没有人知道这个链接或者可以解释一下这个方法?

【问题讨论】:

    标签: opencv homography reprojection-error


    【解决方案1】:

    如果您调用单应矩阵 H,则相机矩阵 K(需要转换为像素)将是这样的,具体取决于您的分辨率。

    Mat K= Mat::zeros(3,3,CV_32FC1);
    K.at<float>(0,0)=500.0f;        
    K.at<float>(0,2)=320.0f;      // width/2    
    K.at<float>(1,1)=500.0f;    
    K.at<float>(1,2)=240.0f;      // height/2 
    K.at<float>(2,2)=1.0f;
    

    如果你的标记点是二维的向量点:

    vector<Point2f> marker_point; //containing coordinates in centimeters
    

    那么投影将是这样的,结果是像素坐标中的 3D 点。

    Mat point(3,1,CV_32FC1);        
    point.at<float>(0) = marker_point.x;
    point.at<float>(1) = marker_point.y;
    point.at<float>(2) = 1.0f;
    point = H* point;
    point = point/point.at<float>(2);       //Normalize
    point = K* point;                   //to pixels
    

    【讨论】:

      猜你喜欢
      • 2017-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-08
      • 1970-01-01
      • 1970-01-01
      • 2023-03-03
      相关资源
      最近更新 更多