Replies: 3 comments
-
From a first read, you camera definition seems off. You define the camera in screen space but don't set it that way. https://github.com/facebookresearch/pytorch3d/blob/main/docs/notes/cameras.md |
Beta Was this translation helpful? Give feedback.
0 replies
-
I also have a similar issue. any solutions? |
Beta Was this translation helpful? Give feedback.
0 replies
-
did this have solutions? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
hello, try to render mesh by PerspectiveCameras,but the result is same color.
this is my code:
import torch
import numpy as np
import matplotlib.pyplot as plt
from pytorch3d.io import load_obj
from pytorch3d.structures import Meshes
from pytorch3d.renderer import (
PerspectiveCameras,
RasterizationSettings, MeshRenderer, MeshRasterizer, BlendParams,
SoftSilhouetteShader
)
if torch.cuda.is_available():
device = torch.device("cuda:0")
torch.cuda.set_device(device)
else:
device = torch.device("cpu")
verts, faces_idx, _ = load_obj("./data/smpl1.obj")
faces = faces_idx.verts_idx
verts = verts * 1000
smpl_mesh = Meshes(verts=[verts.to(device)], faces=[faces.to(device)])
focal_length = torch.tensor([[577.137, 577.137]], device=device)
principal_point = torch.tensor([[321.874, 243.694]], device=device)
R = torch.tensor([[[1, 0, 0], [0, 1, 0], [0, 0, 1]]], device=device)
T = torch.tensor([[0, 0, 0]], device=device)
cameras = PerspectiveCameras(focal_length=focal_length,
principal_point=principal_point,
R=R,
T=T,
device=device
)
blend_params = BlendParams(sigma=1e-4, gamma=1e-4)
raster_settings = RasterizationSettings(
image_size=[480, 640],
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)
)
silhouette = silhouette_renderer(meshes_world=smpl_mesh)
silhouette = silhouette.cpu().numpy()
skt = silhouette.squeeze()[..., 3]
plt.figure(figsize=(10, 10))
plt.imshow(silhouette.squeeze()[..., 3])
plt.grid(False)
plt.show()
some of points in mesh like this:
v 0.19095382 -0.63784724 2.36624336
v 0.18782929 -0.62453818 2.35648489
v 0.19752663 -0.62003261 2.36658001
v 0.20136854 -0.62961197 2.37770987
v 0.19561735 -0.61190212 2.35865927
v 0.18636529 -0.61382329 2.35095119
v 0.20367119 -0.61277306 2.37667370
v 0.20711969 -0.61854726 2.38839769
v 0.21181732 -0.57649171 2.38347101
v 0.21480688 -0.57056987 2.39325476
v 0.21359174 -0.58262002 2.39287210
v 0.20959769 -0.58547872 2.38358545
v 0.21206786 -0.55020374 2.38399220
v 0.20713890 -0.54289997 2.37437510
v 0.20941487 -0.53281802 2.38327074
v 0.21310993 -0.53974956 2.39433289
v 0.17692581 -0.55943173 2.34842968
v 0.18259536 -0.55283284 2.34954000
v 0.18584865 -0.55930161 2.35169315
v 0.17977718 -0.56495500 2.35053730
v 0.16799158 -0.57012534 2.34174085
v 0.16867708 -0.57448936 2.34582734
v 0.16423194 -0.57906401 2.34025574
v 0.16457398 -0.57396770 2.33498240
v 0.17229365 -0.55443263 2.34643221
v 0.17860942 -0.54718447 2.34760237
v 0.17212476 -0.56533957 2.34667325
v 0.17059043 -0.56155694 2.34336567
v 0.16987452 -0.55765593 2.33099699
v 0.17081188 -0.56217968 2.33318520
v 0.16834566 -0.56386817 2.32591319
v 0.16717462 -0.55851430 2.32592106
v 0.17156522 -0.55517679 2.34110594
v 0.17206945 -0.55887848 2.33848882
v 0.17030457 -0.55547982 2.33541369
v 0.16870804 -0.55250055 2.33834958
v 0.16814694 -0.56643689 2.33782148
v 0.16593423 -0.56943667 2.33039045
v 0.16287780 -0.57174528 2.32257652
v 0.16481996 -0.56418616 2.31812334
v 0.19343680 -0.53859717 2.35593534
v 0.18853624 -0.54589862 2.35186768
Beta Was this translation helpful? Give feedback.
All reactions