Skip to content

Unable to see the image, with plt - in the Pointcloud tutorial using my sample pcd #434

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

Closed
pankaja0285 opened this issue Nov 9, 2020 · 4 comments
Assignees

Comments

@pankaja0285
Copy link

pankaja0285 commented Nov 9, 2020

@bottler , @nikhilaravi
I was able to re-install according to what you said from https://github.com/facebookresearch/pytorch3d/blob/stable/docs/tutorials/render_colored_points.ipynb
so I went past
But the issue with 512,512 - error still occurs.

a) I read from a pcd file
from pyntcloud.io import read_pcd pointcloud = read_pcd(filename) print('pointcloud',pointcloud) #which gives me
(NOTE: Due to sensitivity of data I can't give you the entire data so showing only the first point below )
#pointcloud
{'points': x y z c #0 -0.588727 -0.532933 1.233257 0.142857 #[36413 rows x 4 columns]
Then I convert to vertices and rgb as
points_xyz = pointcloud["points"][["x","y","z"]].values points_rgb = pointcloud["points"][["c"]].values verts = torch.Tensor(points_xyz).to(device) rgb = torch.Tensor(points_rgb).to(device) point_cloud = Pointclouds(points=[verts], features=[rgb])

And when I print point_cloud, I get
<pytorch3d.structures.pointclouds.Pointclouds at 0x7f8ab9ddefd0>

So, then after that I do, as per the tutorial -->

Initialize a camera.`

R, T = look_at_view_transform(20, 10, 0)
cameras = FoVOrthographicCameras(device=device, R=R, T=T, znear=0.01)

Define the settings for rasterization and shading. Here we set the output image to be of size

512x512. As we are rendering images for visualization purposes only we will set faces_per_pixel=1

and blur_radius=0.0. Refer to raster_points.py for explanations of these parameters.

raster_settings = PointsRasterizationSettings(
image_size=512,
radius = 0.003,
points_per_pixel = 10
)

Create a points renderer by compositing points using an alpha compositor (nearer points

are weighted more heavily). See [1] for an explanation.

renderer = PointsRenderer(
rasterizer=PointsRasterizer(cameras=cameras, raster_settings=raster_settings),
compositor=AlphaCompositor()
)

#--this runs fine

images = renderer(point_cloud)
images.shape`

outputs as
torch.Size([1, 512, 512, 1])

#Then as per tutorial if I use

images = renderer(point_cloud)
plt.figure(figsize=(10, 10))

plt.imshow(images[0, ..., :3].cpu().numpy())

plt.grid("off")

plt.axis("off")

#I get error --> TypeError: Invalid shape (512, 512, 1) for image data
#so if I do as you suggested which is

plt.figure(figsize=(10, 10))

plt.imshow(images[0, ..., 0].cpu().numpy(), cmap='gray')

plt.grid("off")

plt.axis("off")
`

I get the output as
(-0.5, 511.5, 511.5, -0.5)
I don't see any image.

Same thing happens for the next block of plt as well, after doing the weighted compositing.

Please advise.

@bottler
Copy link
Contributor

bottler commented Nov 9, 2020

Can you help me understand why this is a separate issue to #431? It looks quite similar to the problem there, and if the setup is different in some way you need to explain? For any new issue, you will get best results if you fully explain what you did.

(Obviously it wouldn't make sense to open a new issue because you feel answers are too slow on the first issue.)

@bottler bottler self-assigned this Nov 9, 2020
@pankaja0285
Copy link
Author

pankaja0285 commented Nov 10, 2020

@bottler - only reason I created this was because that #431 was deemed (or labeled) as install, since I felt that the install issue got resolved, but the tutorial itself I have NOT been able to successfully complete, meaning the last 2 visualizations with matplotlib were not showing the image. I felt this should be a separate issue. Bottom line, according to the tutorial, I need to be able to visualize the image, which I am not able to. Like I have indicated the block in the end - is at the most, I get the output as
(-0.5, 511.5, 511.5, -0.5)
And no image shows...

@bottler
Copy link
Contributor

bottler commented Nov 10, 2020

(I wrote #431 instead of #430 but we both understood.) I put some questions/suggestions on that issue to try to solve the problem.

@gkioxari
Copy link
Contributor

No response. Closing this as it doesn't seem related to a codebase issue.

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

3 participants