MCPcopy Create free account
hub / github.com/AiuniAI/Unique3D / get_camera

Function get_camera

scripts/project_mesh.py:16–25  ·  view source on GitHub ↗
(world_to_cam, fov_in_degrees=60, focal_length=1 / (2**0.5), cam_type='fov')

Source from the content-addressed store, hash-verified

14from pytorch3d.renderer import MeshRasterizer
15
16def get_camera(world_to_cam, fov_in_degrees=60, focal_length=1 / (2**0.5), cam_type='fov'):
17 # pytorch3d expects transforms as row-vectors, so flip rotation: https://github.com/facebookresearch/pytorch3d/issues/1183
18 R = world_to_cam[:3, :3].t()[None, ...]
19 T = world_to_cam[:3, 3][None, ...]
20 if cam_type == 'fov':
21 camera = FoVPerspectiveCameras(device=world_to_cam.device, R=R, T=T, fov=fov_in_degrees, degrees=True)
22 else:
23 focal_length = 1 / focal_length
24 camera = FoVOrthographicCameras(device=world_to_cam.device, R=R, T=T, min_x=-focal_length, max_x=focal_length, min_y=-focal_length, max_y=focal_length)
25 return camera
26
27def render_pix2faces_py3d(meshes, cameras, H=512, W=512, blur_radius=0.0, faces_per_pixel=1):
28 """

Callers 1

get_cameras_listFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected