create_window ( width = w, height = h, visible = False ) vis. create_dense ( width = cubic_size, height = cubic_size, depth = cubic_size, voxel_size = cubic_size / voxel_resolution, origin =, color = ) # rescale geometry camera_sphere = preprocess ( camera_sphere ) mesh = preprocess ( mesh ) # setup visualizer to render depthmaps vis = o3d. read_triangle_mesh ( camera_path ) # setup dense voxel grid voxel_carving = o3d. compute_vertex_normals () camera_sphere = o3d. Vector3dVector ( vertices / scale ) return model def voxel_carving ( mesh, output_filename, camera_path, cubic_size, voxel_resolution, w = 300, h = 300, use_depth = True, surface_method = 'pointcloud' ): mesh.
norm ( max_bound - min_bound ) / 2.0 vertices = np. get_max_bound () center = min_bound + ( max_bound - min_bound ) / 2.0 scale = np. eye ( 4 ) trans = r trans = t return trans def preprocess ( model ): min_bound = model. dot ( rot_x ) def get_extrinsic ( xyz ): rvec = xyz_spherical ( xyz ) r = get_rotation_matrix ( rvec, rvec ) t = np.
arctan2 ( z, x ) return def get_rotation_matrix ( r_x, r_y ): rot_x = np. Def xyz_spherical ( xyz ): x = xyz y = xyz z = xyz r = np.