MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / project_points

Function project_points

detrsmpl/utils/geometry.py:360–391  ·  view source on GitHub ↗

Perform orthographic projection of 3D points using the camera parameters, return projected 2D points in image plane. Notes: batch size: B point number: N Args: points_3d (Tensor([B, N, 3])): 3D points. camera (Tensor([B, 3])): camera parameters with the

(points_3d, camera, focal_length, img_res)

Source from the content-addressed store, hash-verified

358
359
360def project_points(points_3d, camera, focal_length, img_res):
361 """Perform orthographic projection of 3D points using the camera
362 parameters, return projected 2D points in image plane.
363
364 Notes:
365 batch size: B
366 point number: N
367 Args:
368 points_3d (Tensor([B, N, 3])): 3D points.
369 camera (Tensor([B, 3])): camera parameters with the
370 3 channel as (scale, translation_x, translation_y)
371 Returns:
372 points_2d (Tensor([B, N, 2])): projected 2D points
373 in image space.
374 """
375 batch_size = points_3d.shape[0]
376 device = points_3d.device
377 cam_t = torch.stack([
378 camera[:, 1], camera[:, 2], 2 * focal_length /
379 (img_res * camera[:, 0] + 1e-9)
380 ],
381 dim=-1)
382 camera_center = camera.new_zeros([batch_size, 2])
383 rot_t = torch.eye(3, device=device,
384 dtype=points_3d.dtype).unsqueeze(0).expand(
385 batch_size, -1, -1)
386 keypoints_2d = perspective_projection(points_3d,
387 rotation=rot_t,
388 translation=cam_t,
389 focal_length=focal_length,
390 camera_center=camera_center)
391 return keypoints_2d
392
393def project_points_new(points_3d, pred_cam, focal_length, camera_center):
394 """Perform orthographic projection of 3D points using the camera

Callers 3

Calls 1

perspective_projectionFunction · 0.70

Tested by

no test coverage detected