Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add color to pointcloud #2

Open
an99990 opened this issue Jul 28, 2022 · 0 comments
Open

Add color to pointcloud #2

an99990 opened this issue Jul 28, 2022 · 0 comments

Comments

@an99990
Copy link

an99990 commented Jul 28, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant