ros中kinect相机sensor_msgs.msg PointCloud2类型点云 转 open3d 点云
·
ros中kinect相机sensor_msgs.msg PointCloud2类型点云 转 open3d 点云
python 语言
时间:2023.7.30
代码:
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import rospy
from sensor_msgs.msg import PointCloud2
from sensor_msgs import point_cloud2
import open3d
class PointCloudSubscriber(object):
def __init__(self) -> None:
self.sub = rospy.Subscriber("/kinect_98/kinect2/hd/points",
PointCloud2,
self.callback, queue_size=5)
def callback(self, msg):
assert isinstance(msg, PointCloud2)
points = point_cloud2.read_points(msg,field_names=("x","y","z"))
#points = point_cloud2.read_points_list(
# msg, field_names=("x", "y", "z"))
p = open3d.geometry.PointCloud()
p.points = open3d.utility.Vector3dVector(points)
print(p)
#后续对点云进行各种操作,就用open3d的库函数即可
if __name__ =='__main__':
rospy.init_node("pointcloud_subscriber")
PointCloudSubscriber()
rospy.spin()
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)