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

Function rasterize

plib/render.py:225–372  ·  view source on GitHub ↗

Use open3d's visualizer to render image and depth_map from the camera. Args: meshes: a list of meshes intrinsic_matrix: (3,3) intrinsic matrix shared among all cameras. or a list of (3, 3) intrinsic matrices of each cameras. We only suppo

(
        meshes: T.Union[o3d.geometry.TriangleMesh, T.List[o3d.geometry.TriangleMesh],
        o3d.geometry.PointCloud, T.List[o3d.geometry.PointCloud]],
        intrinsic_matrix: T.Union[np.ndarray, T.List[np.ndarray]],
        extrinsic_matrices: T.Union[np.ndarray, T.List[np.ndarray]],
        width_px: int,
        height_px: int,
        get_point_cloud: bool = True,
        pcd_subsample: int = 1,
        point_size: float = -1,
        show_backface=True,
        dtype: np.dtype = np.float32,
)

Source from the content-addressed store, hash-verified

223
224
225def rasterize(
226 meshes: T.Union[o3d.geometry.TriangleMesh, T.List[o3d.geometry.TriangleMesh],
227 o3d.geometry.PointCloud, T.List[o3d.geometry.PointCloud]],
228 intrinsic_matrix: T.Union[np.ndarray, T.List[np.ndarray]],
229 extrinsic_matrices: T.Union[np.ndarray, T.List[np.ndarray]],
230 width_px: int,
231 height_px: int,
232 get_point_cloud: bool = True,
233 pcd_subsample: int = 1,
234 point_size: float = -1,
235 show_backface=True,
236 dtype: np.dtype = np.float32,
237) -> T.Dict[str, T.Any]:
238 """
239 Use open3d's visualizer to render image and depth_map from the camera.
240
241 Args:
242 meshes: a list of meshes
243 intrinsic_matrix:
244 (3,3) intrinsic matrix shared among all cameras.
245 or a list of (3, 3) intrinsic matrices of each cameras.
246 We only support fx = fy
247
248 For example:
249 intrinsic_matrix=np.array([
250 [128, 0, 128],
251 [0, 128, 128],
252 [0, 0, 1],
253 ], dtype=np.float),
254
255 extrinsic_matrices:
256 a list of (4,4) homogeneous matrix (from world coordinate to camera coordinate)
257
258 For example:
259 extrinsic_matrix=np.array([
260 [1, 0, 0, 0,],
261 [0, 1, 0, 0,],
262 [0, 0, 1, 0,],
263 [0, 0, 0, 1.,],
264 ], dtype=np.float),, # world to camera (cV = H * wV)
265
266 width_px:
267 number of pixels of the sensor. ex: 256
268 height_px:
269 number of pixels of the sensor. ex: 256
270 get_point_cloud:
271 whether to construct a point cloud (in the world coordinate) from
272 the rendered images
273 pcd_subsample:
274 subsample the point cloud (1 point in every n pixel). >= 1
275 point_size:
276 new option when input is a point cloud, change the render size of points
277 Returns:
278 imgs: a list of (h, w, 3) rgb
279 z_maps: a list of (h, w) z of the scene points in the camera coordinate
280 pcds: a list of o3d.geometry.PointCloud in the world coordinate (one for each camera pose)
281 hit_maps: a list of (h, w) true: valid, false: not valid
282 """

Callers

nothing calls this directly

Calls 2

generate_pointFunction · 0.85

Tested by

no test coverage detected