反射强度
据激光测量原理得到的点云, 包括三维坐标(XYZ)和 激光反射强度(Intensity)。
根据摄影测量原理得到的点云,包括三维坐标(XYZ)和 颜色信息(RGB)
取值范围有0~255和0~65535两种类型
将反射强度值 与色谱对应
可以基于点云数据反射强度将具备高反射强度的道路标线单独分离出来,让反射强度相对较低的道路表面被隐藏。
从而便于道路标线的高效精准自动化三维提取。
https://baijiahao.baidu.com/s?id=1750155523938661859你知道三维激光LiDAR点云的反射强度都有哪些超赞的用途吗?
points_colors = [colormap[int(points_intensity[i]) % colormap.shape[0]] for i in range(points_intensity.shape[0])]
统计数组的值出现次数
import numpy as np
from collections import Counter
data = np.array([1.1,1.1,1.1,2,3,5,4,4,4,5])
# 方法一
print('Counter(data)\n',Counter(data)) # 调用Counter函数
print('==========')
# 方法二
print('np.unique(data)\n',np.unique(data)) # unique返回的是已排序数组
for i in np.unique(data):
print(i,np.sum(data==i))
根据 intensity 为点云着色
# 假设传入的 points 包含 x-y-z-intensity 四个维度
# 自定义一个 colormap
colormap = np.random.randint(0,255,(200,3))/255
colormap = np.array([[128, 130, 120],
[235, 0, 205],
[0, 215, 0],
[235, 155, 0]]) / 255.0
# 构建 Open3D 中提供的 gemoetry 点云类
pcd = geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(points[:, :3])
points_intensity = points[:, 3] # intensity
points_colors = [colormap[int(points_intensity[i]) % colormap.shape[0]] for i in range(points_intensity.shape[0])]
pcd.colors = o3d.utility.Vector3dVector(points_colors) # 根据 intensity 为点云着色
读取或者写入
import open3d as o3d
#---------------读取-------------------#
pcd = o3d.t.io.read_point_cloud("name.pcd")
pcd_intensity = pcd.point["intensity"] #强度
pcd_points = pcd.point["positions"] #坐标
pcd_intensity = pcd_intensity[:, :].numpy() # 转换为数组类型
pcd_points = pcd_points[:, :].numpy() # 转换为数组类型
#---------------生成-------------------#
device = o3d.core.Device("CPU:0")
dtype = o3d.core.float32
pcd = o3d.t.geometry.PointCloud(device)
pcd.point["positions"] = o3d.core.Tensor(pcd_points, dtype, device)
bag中提取pcd
#注意数据的shape
import numpy as np
if __name__ == '__main__':
data = np.array([1.1,3,4,5,6])
data2 = np.array([[1.1,3,4,5,6]])
data3 = np.array([[1.1],[3],[4],[5],[6]])
print(data.shape,data2.shape,data3.shape)
print(data2.reshape(-1).shape,data3.reshape(-1).shape)
from sensor_msgs import point_cloud2
import open3d as o3d
import rosbag
bag_pcd = point_cloud2.read_points(msg,field_names=["x","y","z","intensity"])
pcd = o3d.t.geometry.PointCloud()
pcd.point["positions"] = o3d.core.Tensor(bag_pcd[:,:3], dtype=o3d.core.Dtype。Floated2)
print(bag_pcd[:,3].shape,bag_pcd[:,3].reshape(-1,1).shape)
pcd.point["intensity"] = o3d.core.Tensor(bag_pcd[:,3].reshape(-1,1), dtype, device)
利用ros工具提取pcd
rosrun是运行一个单独节点的命令
roslaunch采用XML的格式对需要运行的节点进行描述,可以同时运行多个节点
rosrun pcl_ros bag_to_pcd <input_file.bag> <topic> <output_directory>
rosrun pcl_ros pointcloud_to_pcd input:=/velodyne/pointcloud2
点云最后的保存形式为时间戳.pcd
利用ros工具提取图片
rosrun image_view extract_images _sec_per_frame:=0.01 image:=/front_wide/image_raw
rosrun image_view image_view _sec_per_frame:=0.01 image:=/front_wide/image_raw
rosrun image_view image_saver _encoding:='bgr8' _filename_format:=%s image:=/front_wide/image_raw
rosrun image_view image_saver image:=/camera0/color/image_raw _encoding:=bgr8 _filename_format:="cam%i.png"
标定Calibration:提供工具用于标定单目或双目相机 camera_calibration
https://wiki.ros.org/image_view
http://wiki.ros.org/pcl_ros
映射的方式
###一个值映射三个值 标签作为map的id
colormap = np.random.randint(0,255,(200,3))/255
points_colors = [colormap[int(points_intensity[i]) % colormap.shape[0]] for i in range(points_intensity.shape[0])]
使用索引(Index)访问列表中的某个元素
命名元组另一个用途就是作为字典的替代,因为字典存储需要更多的内存空间 from collections import namedtuple
collections.namedtuple()
命名切片 slice() 函数创建了一个切片对象
# key和values的交换
d1={'a':1,'b':2}
{value:key for key,value in d1.iteritems()}
一个键对应多个值的字典(也叫 multidict)
d1={'a':1,'b':2,'c':1}
d=defaultdict(list)
for k,v in d1.iteritems():
d[v].append(k)
参考
open3d读取和生成带强度的点云 https://blog.csdn.net/Tammy_lzh/article/details/128894477
numpy 统计数组的值出现次数与np.bincount()详细解释 https://blog.csdn.net/weixin_42280517/article/details/89788643
LiDAR点云的反射强度都有哪些超赞的用途 https://baijiahao.baidu.com/s?id=1750155523938661859
带你玩转 3D 检测和分割 (三):有趣的可视化 https://zhuanlan.zhihu.com/p/504862433
https://github.com/open-mmlab/mmdetection3d/blob/master/mmdet3d/core/visualizer/open3d_vis.py
https://github.com/PointCloudLibrary/pcl/blob/master/common/include/pcl/point_types.h
标签:python,image,shape,intensity,open3d,np,pcd,points
From: https://www.cnblogs.com/ytwang/p/17214665.html