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

python: lidar点云转BEV投影及pillar/voxel

点云BEV投影及pillar体素化

  • bev投影
  • pillar/voxel

bev投影

点云bev投影代码

pillar/voxel

#!/usr/bin/env python
# -*- encoding: utf-8 -*-import os
import numpy as np
import mathn_max_points_per_pillar = 32
n_max_pillars = 20736  # 144*144 = 20736
n_in_features = 7  # x y z i xc yc zcx_step = 0.32  # 32cm 32*144 = 4608 = 46.08m
y_step = 0.16  # 16cm 16*144 =  = 15.36mmax_intensity = 255def read_pcd(pcd_file, readline=11):# np.fromfile read pcd 文本/二进制# cloud = np.fromfile(str(pcd_file), dtype=np.float32, count=-1)data = []with open(pcd_file, 'r') as f:lines = f.readlines()[readline:]          for line in lines:line = np.array(line.strip('\n').split(' '), dtype=np.float32)# print(line.shape, line)x,y,z,i = line[0], line[1], line[2], line[3]# print(x,y,z,i)# r = math.sqrt(x**2 + y**2 + z**2) * i  # for rslidar# r = float(line[4]) # for ouster lidar data.append([x,y,z,i])# points = list(map(lambda line: list(map(lambda x: float(x), line.split(' '))), lines))points = np.array(data)return pointsdef points_to_pillars(points, list_roi_xyz = [0.0, 69.12, -11.52, 11.52, -2.5, 0.5],list_pillar_xy = [0.48, 0.16],list_grid_xy = [144, 144],  # (69.12 - 0) / 0.48list_pillar_szie = [20736, 32, 7]):x_min, x_max, y_min, y_max, z_min, z_max = list_roi_xyzx_grid, y_grid = list_grid_xyx_pillar, y_pillar = list_pillar_xyn_max_pillars, n_max_points_per_pillar, n_in_features = list_pillar_szie# ROIidx = np.where((points[:, 0] > x_min) & (points[:, 0] < x_max) &(points[:, 1] > y_min) & (points[:, 1] < y_max) &(points[:, 2] > z_min) & (points[:, 2] < z_max))points_roi = points[idx[0]]# intensity normlizepoints_roi[:,3] /= 255# 计算每个点所在的voxel索引# Compute the indices of the pillars that each point belongs to.x_img = (points_roi[:,0] - x_min) // x_pillary_img = (points_roi[:,1] - y_min) // y_pillarx_img = x_img.reshape(-1, 1).astype(int)y_img = y_img.reshape(-1, 1).astype(int)# pillar_coords = np.concatenate((x_img, y_img), axis=1)# 计算pillar的索引pillar_idx = x_img * y_grid + y_img  # 找到每个pillar的点数unique_pillars, num_points_per_pillars = np.unique(pillar_idx, return_counts=True)# print("num pillars: ",unique_pillars, num_points_per_pillars)num_points_per_pillars = np.minimum(num_points_per_pillars, n_max_points_per_pillar)# Initialize the pillar representation with zeros.pillars = np.zeros([n_max_pillars, n_max_points_per_pillar, n_in_features]).astype(np.float32)for i, pillar_id in enumerate(unique_pillars):# 找出pillar对应的点indices = np.where(pillar_idx == pillar_id)[0]  # 每个pillar内所有点的索引indices = indices[:num_points_per_pillars[i]]  # 每个pillar内取前n个点的索引# 计算pillar的中心坐标pillar_c = np.mean(points_roi[indices, :3], axis=0)        # 计算pillar的中心坐标和每个点的偏移offsets = points_roi[indices, :3] - pillar_c# 将点和偏移添加到pillar中pillars[pillar_id, :num_points_per_pillars[i], :4] = points_roi[indices]pillars[pillar_id, :num_points_per_pillars[i], 4:7] = offsetsprint(pillars[pillar_id, ...])if __name__=="__main__":path = "/home/data"for i,f in enumerate(os.listdir(path)):file = os.path.join(path, f)if i < 20:points = read_pcd(file)points_to_pillars(points)
http://www.lryc.cn/news/110075.html

相关文章:

  • 我的创作纪念日2023.8.5
  • 课程作业-基于Python实现的迷宫搜索游戏附源码
  • 差值结构的相互作用能
  • UI、UE、UX的区别
  • RabbitMQ 教程 | 第10章 网络分区
  • Flask学习笔记_异步论坛(四)
  • K8S系列文章之 kubeasz部署K8S环境
  • nodejs和vue的关系--vue3教程
  • 前端大屏尺寸实现自适应屏幕大小
  • leetcode 416. 分割等和子集
  • cesium加载三维模型3dtiles
  • el-select控制单选还是多选
  • nginx使用
  • 基于Jenkins+Python+Ubuntu+Docker的接口/UI自动化测试环境部署详细过程
  • Linux|ubuntu下运行python
  • 使用FreeMarker导出word文档(支持导出图片)
  • C/C++中变量按位操作
  • uni、css——制作表格样式的模型
  • mac前端代码编辑 Sublime Text 4 Dev 中文v4.0(4151)
  • 面试之HashMap
  • promethues mysql-rules
  • Maven项目中Lifecycle和Plugins下的install的区别
  • 02-状态模式
  • Python异常处理中异常的种类有哪些?你知道几个?
  • COBOL语言介绍及使用场景
  • 【计算机视觉 | 图像分割】arxiv 计算机视觉关于图像分割的学术速递(8 月 1 日论文合集)
  • Jetson nano 安装swapfile 解决Cannot allocate memory 问题
  • ElasticsSearch基础概念和安装
  • 【GEMM预备工作】行主序和列主序矩阵的内存中的连续性,解决理解问题
  • 利用el-button 画圆 ,通过border-radius >50% 就成圆形