ROS2-Point-Cloud-Demo
ROS2-Point-Cloud-Demo copied to clipboard
Add color to pointcloud
Hi, Thank you for this great demo. I have used your subscriber and publisher and have successfully subscribed and published PointCloud2 mgs. However, I am unable to visualise them in RVIZ. Is it because theres no rgba channel ?
here is my code, thank you
pt_cloud_image = np.array(list(read_points(pt_cloud_msg)))
pt_cloud_image = np.reshape(pt_cloud_image,
(rgb_image.shape[0],rgb_image.shape[1],pt_cloud_image.shape[1]))
resized_pt_cloud = cv2.resize(pt_cloud_image, self.dim, interpolation=cv2.INTER_AREA)
for mask in masks:
x = np.dstack([pt_cloud[:,:,0]])
y = np.dstack([pt_cloud[:,:,1]])
z = np.dstack([pt_cloud[:,:,2]])
mask = mask.detach().cpu().numpy()
x_new = np.multiply(x[:,:,0],mask)
y_new = np.multiply(y[:,:,0],mask)
z_new = np.multiply(z[:,:,0],mask)
pt_cloud = np.dstack([x_new, y_new, z_new])
pt_cloud_msg = point_cloud(pt_cloud,'zed2_base_link')
self.object_point_pub_.publish(pt_cloud_msg)
What I am trying to do is apply a mask to the point cloud to only get the points within that mask. Thank you for any support.