雷达坐标系下的点转换为图像坐标系的思路

cv::Point2i ProjectPoint(const cv::Point3f &in_point)
{
  auto u = int(in_point.x * fx_ / in_point.z + cx_);
  auto v = int(in_point.y * fy_ / in_point.z + cy_);

  return cv::Point2i(u, v);
}


cv::Rect ProjectDetectionToRect(const autoware_msgs::DetectedObject &in_detection)
{
  cv::Rect projected_box;

  Eigen::Vector3f pos;      //三维检测框的位置
  pos << in_detection.pose.position.x,
    in_detection.pose.position.y,
    in_detection.pose.position.z;

  Eigen::Quaternionf rot(in_detection.pose.orientation.w,   //四元数矩阵
                         in_detection.pose.orientation.x,
                         in_detection.pose.orientation.y,
                         in_detection.pose.orientation.z);

  std::vector<double> dims = {
    in_detection.dimensions.x,
    in_detection.dimensions.y,
    in_detection.dimensions.z
  };

  jsk_recognition_utils::Cube cube(pos, rot, dims);

  Eigen::Affine3f range_vision_tf;
  // tf::transformTFToEigen(camera_lidar_tf_, range_vision_tf);
  tf::transformTFToEigen(cameraTolidar_tf, range_vision_tf);
  jsk_recognition_utils::Vertices vertices = cube.transformVertices(range_vision_tf);

  std::vector<cv::Point> polygon;     //二维检测框点
  for (auto &vertex : vertices)
  {
    cv::Point p = ProjectPoint(cv::Point3f(vertex.x(), vertex.y(), vertex.z()));    //转换到图像坐标系
    polygon.push_back(p);
  }

  projected_box = cv::boundingRect(polygon);

  return projected_box;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值