pytorch3d icon indicating copy to clipboard operation
pytorch3d copied to clipboard

difference between rendering using PyTorch3d and Pyrender

Open abderrahimlaaz opened this issue 2 years ago • 0 comments

I'm working on project were i'm trying to generate a 3D object from 2D images, i'm using pytorch3d for rendering using this code:

` image_size = torch.tensor([[374., 499.]], device='cuda:0') cameras = pytorch3d.utils.cameras_from_opencv_projection(R=R, tvec=T, camera_matrix=K, image_size=image_size) blend_params = BlendParams(sigma=1e-4, gamma=1e-4)

raster_settings = RasterizationSettings( image_size=[imagesInfor.imagesList[0].shape[0],imagesInfor.imagesList[0].shape[1]], blur_radius=np.log(1. / 1e-4 - 1.) * blend_params.sigma, faces_per_pixel=100, )

silhouette_renderer = MeshRenderer( rasterizer=MeshRasterizer( cameras=cameras, raster_settings=raster_settings ), shader=SoftSilhouetteShader(blend_params=blend_params) ) `

The problem is that the constructed mesh is always smaller than the original mesh. (with 6 to 9 mm in length) after a long search for the source of the problem i end up with a difference in resulting rendering images between pytorch3d and pyrender. the below image shows the difference rendering results i got using the same camera parameters in both of theme.

Screenshot from 2022-08-11 10-10-31

the foot with black color is given using pyrender and yellow color is given using pytorch3d.

the black color is the overlap between rendering using pytorch3d and pyrender and the yellow represent the difference between theme (yellow pixels are pytorch3d pixels)

this is the code i use to render with pyrender

node_camera = scene.add(camerasPyrender[i], pose=camera_poses_pyrender[i]) renderer = pyrender.OffscreenRenderer(width, heigth) foot_view = renderer.render(scene,pyrender.RenderFlags.DEPTH_ONLY) any suggestion why there is a difference between rendering using pytorch3d and pyrender with same camera parameters.

abderrahimlaaz avatar Aug 11 '22 09:08 abderrahimlaaz