当前位置: 首页 > news >正文

将3D检测的box框投影到BEV图片上

前言

点云数据作为一种丰富的三维空间信息表达方式,通常用于自动驾驶、机器人导航和三维建模等领域。然而,点云数据的直观性不如二维图像,这限制了它在一些需要快速视觉反馈的应用场景中的使用。本文将探讨如何将点云数据转换为二维图像,并介绍相关的技术和实践方法。

实现原理

将3D Box进行投影到图片上。

width, height = 480, 480
image = np.zeros((height, width, 3), dtype=np.uint8)dis_x_thresh =50
dis_y_thresh =40
# 遍历每个点,并在图像上绘制
for point in points:if abs(point[1]) < dis_y_thresh or point[0] > dis_x_thresh:x = (dis_y_thresh-point[1]) * width /(dis_y_thresh*2)  #此处的x对应于点云的yy = (dis_x_thresh-point[0]) * height /(dis_x_thresh*2)

代码实现

#获取3dbox检测框
def load_groundtruth(gt_file):with open(gt_file, "r") as hd:objects = json.load(hd)return objects
#获取检测框的角点
def get_obj_corners(obj):center = [obj["Center"]["CenterX"], obj["Center"]["CenterY"], obj["Center"]["CenterZ"]]size = [obj["Size"]["ObjectLength"], obj["Size"]["ObjectWidth"], obj["Size"]["ObjectHeight"]]yaw = obj["Yaw"]rot = np.asmatrix([[math.cos(yaw), -math.sin(yaw)],\[math.sin(yaw),  math.cos(yaw)]])plain_pts = np.asmatrix([[0.5 * size[0], 0.5*size[1]],\[0.5 * size[0], -0.5*size[1]],\[-0.5 * size[0], -0.5*size[1]],\[-0.5 * size[0], 0.5*size[1]]])tran_pts = np.asarray(rot * plain_pts.transpose())tran_pts = tran_pts.transpose()corners = np.arange(24).astype(np.float32).reshape(8, 3)for i in range(8):corners[i][0] = center[0] + tran_pts[i%4][0]corners[i][1] = center[1] + tran_pts[i%4][1]corners[i][2] = center[2] + (float(i >= 4) - 0.5) * size[2]return corners
#将3d box投影映射到Bev图片上。
for obj in objects:corners = get_obj_corners(obj)x1 = (dis_y_thresh-corners[0][1]) * width /(dis_y_thresh*2)y1 = (dis_x_thresh-corners[0][0]) * height /(dis_x_thresh*2)x2 = (dis_y_thresh-corners[1][1]) * width /(dis_y_thresh*2)y2 = (dis_x_thresh-corners[1][0]) * height /(dis_x_thresh*2)x3 = (dis_y_thresh-corners[2][1]) * width /(dis_y_thresh*2)y3 = (dis_x_thresh-corners[2][0]) * height /(dis_x_thresh*2)x4 = (dis_y_thresh-corners[3][1]) * width /(dis_y_thresh*2)y4 = (dis_x_thresh-corners[3][0]) * height /(dis_x_thresh*2)box = np.array([int(x1),int(y1),int(x2),int(y2),int(x3),int(y3),int(x4),int(y4)])boxs = box.reshape((-1,2))cv2.drawContours(image, [boxs], 0, (0, 255, 0), 2)

结果可视化

http://www.lryc.cn/news/354156.html

相关文章:

  • Flutter 中的 ClipOval 小部件:全面指南
  • ubuntu 硬盘转移
  • three.js中使用CameraHelper来可视化调整阴影相机的范围
  • Golang发送GET请求并设置查询参数
  • c++笔记3
  • 唠唠叨叨,每日进度
  • Vulhub——CAS 4.1、AppWeb、apisix
  • Python Beautiful Soup 使用详解
  • Java进阶学习笔记29——Math、System、Runtime
  • TOTP 算法实现:双因素认证的基石(C/C++代码实现)
  • aws eks理解和使用podidentity为pod授权
  • 面向可复用性和可维护性的设计模式 课程学习总结
  • 修复谷歌 AdSense 的 Ads.Txt 无效的有收益损失风险提示
  • 使用向量叉乘,来计算一个点到一条线的距离
  • 学习笔记——交通安全分析02
  • pytest-sugar插件:对自动化测试用例加入进度条
  • AI大模型的口语练习APP
  • Elasticsearch 详细介绍和经典应用
  • GEC210编译环境搭建
  • Mysql中表之间的关系
  • 文心智能体大赛:百度文心智能体平台初体验
  • AI数据面临枯竭
  • 2024.5组队学习——MetaGPT(0.8.1)智能体理论与实战(中):订阅智能体OSS实现
  • LoadBalancer
  • 【栈】Leetcode 71. 简化路径【中等】
  • 简单操作一单利润500+,最新快手缺货赔付玩法,【找店教程+详细教程】
  • 【软件设计师】先导
  • npm : 无法将“npm”项识别为 cmdlet、函数、脚本文件或可运行程序的名称
  • 如何用 MoonBit 实现 diff?
  • opencl色域变换,处理传递显存数据