MCPcopy Create free account
hub / github.com/apple/ml-pointersect / generate_camera_rays

Method generate_camera_rays

pointersect/inference/structures.py:1758–1795  ·  view source on GitHub ↗

Generate camera rays: ray_origin is at pinhole and ray directions outward from a pixel location (somewhere withing a pixel pitch) to pinhole. Args: offsets: 'center' or 0, ray will be coming from the center of a pixel 'ran

(
            self,
            subsample: int = 1,
            offsets: str = 'center',
            device: torch.device = torch.device('cpu'),
    )

Source from the content-addressed store, hash-verified

1756 return rigid_motion.inv_homogeneous_tensors(self.H_c2w)
1757
1758 def generate_camera_rays(
1759 self,
1760 subsample: int = 1,
1761 offsets: str = 'center',
1762 device: torch.device = torch.device('cpu'),
1763 ) -> Ray:
1764 """
1765 Generate camera rays: ray_origin is at pinhole and
1766 ray directions outward from a pixel location (somewhere withing
1767 a pixel pitch) to pinhole.
1768
1769 Args:
1770 offsets:
1771 'center' or 0, ray will be coming from the center of a pixel
1772 'rand': random offset = [-0.5, 0.5)
1773
1774 Returns:
1775 camera ray: (b, q, h, w)
1776 """
1777
1778 *b_shape, _, _ = self.H_c2w.shape # (b, q, 4, 4)
1779
1780 ray_origins_w, ray_directions_w = utils.generate_camera_rays(
1781 cam_poses=self.H_c2w.reshape(-1, 4, 4),
1782 intrinsics=self.intrinsic.reshape(-1, 3, 3),
1783 width_px=self.width_px,
1784 height_px=self.height_px,
1785 subsample=subsample,
1786 offsets=offsets,
1787 device=device,
1788 ) # (bq, h, w, 3), (bq, h, w, 3)
1789
1790 bq, h, w, _ = ray_origins_w.shape
1791
1792 return Ray(
1793 origins_w=ray_origins_w.reshape(*b_shape, h, w, 3), # (b, q, h, w, 3)
1794 directions_w=ray_directions_w.reshape(*b_shape, h, w, 3), # (b, q, h, w, 3)
1795 )
1796
1797 def generate_random_patch_rays(
1798 self,

Callers 8

test_1Method · 0.80
__getitem__Method · 0.80
get_rgbd_imageMethod · 0.80
get_rgbd_imageMethod · 0.80
_rasterize_renderingMethod · 0.80

Calls 3

RayClass · 0.85
deviceMethod · 0.80
reshapeMethod · 0.45

Tested by 1

test_1Method · 0.64