MCPcopy
hub / github.com/NVlabs/imaginaire / rand_camera_pose_firstperson

Function rand_camera_pose_firstperson

imaginaire/model_utils/gancraft/camctl.py:450–477  ·  view source on GitHub ↗

r"""Generating random camera pose in the upper hemisphere, in the format of origin-direction-up

(voxel, border=128)

Source from the content-addressed store, hash-verified

448
449
450def rand_camera_pose_firstperson(voxel, border=128):
451 r"""Generating random camera pose in the upper hemisphere, in the format of origin-direction-up
452 """
453 r = np.random.rand(5)
454 r[0] *= voxel.voxel_t.size(1)-border-border
455 r[1] *= voxel.voxel_t.size(2)-border-border
456 r[0] = r[0] + border
457 r[1] = r[1] + border
458
459 y = get_neighbor_height(voxel.heightmap, r[0], r[1], 0) + np.random.rand(1) * 15
460
461 cam_ori = torch.tensor([y, r[0], r[1]], dtype=torch.float32)
462
463 rand_ang_h = r[2] * 2 * np.pi
464 cam_target = torch.tensor([0, cam_ori[1]+np.sin(rand_ang_h)*border*r[4], cam_ori[2] +
465 np.cos(rand_ang_h)*border*r[4]], dtype=torch.float32)
466 cam_target[0] = get_neighbor_height(voxel.heightmap, cam_target[1],
467 cam_target[2], 0, neighbor_size=1) - 2 + r[3] * 10
468
469 cam_dir = cam_target - cam_ori
470
471 cam_up = torch.tensor([1, 0, 0], dtype=torch.float32)
472
473 cam_ori = voxel.world2local(cam_ori)
474 cam_dir = voxel.world2local(cam_dir, is_vec=True)
475 cam_up = voxel.world2local(cam_up, is_vec=True)
476
477 return cam_ori, cam_dir, cam_up
478
479
480def rand_camera_pose_thridperson(voxel, border=96):

Callers

nothing calls this directly

Calls 2

get_neighbor_heightFunction · 0.85
world2localMethod · 0.80

Tested by

no test coverage detected