【无标题】

世界坐标系坐标转为像素坐标系坐标

已知相机内参和畸变参数,通过已知的世界坐标,带入projectPoints函数,获得该世界坐标的图像坐标。

// 定义内参矩阵和畸变系数
   cv::Mat camera_Matrix = (cv::Mat_<double>(3, 3) << fx, 0, cx, 0, fy, cy, 0, 0, 1);
    cv::Mat dist_Coeffs = (cv::Mat_<double>(5, 1) << k1, k2, p1, p2, k3);

    // 定义世界坐标系中的点
    std::vector<cv::Point3f> worldPoints;
    worldPoints.push_back(cv::Point3f(2, 3, 8));
    worldPoints.push_back(cv::Point3f(4, 9, 12));
    // 添加更多的世界坐标点...

    // 定义图像坐标系中的点(用于存储转换结果)
    std::vector<cv::Point2f> imagePoints;

    // 调用projectPoints函数进行转换
    cv::projectPoints(worldPoints, cv::Mat::zeros(3, 1, CV_64F), cv::Mat::zeros(3, 1, CV_64F), cameraMatrix, distCoeffs, imagePoints);

    // 打印像素坐标系中的点
    for (const auto& point : imagePoints)
    {
        std::cout << "Pixel Coordinates: (" << point.x << ", " << point.y << ")" << std::endl;
    }
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值