Skip to content

Add color to pointcloud #2

@an99990

Description

@an99990

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions