Returns: point_cloud: PointCloud, (b=1, n), n: number of points ray: Ray, (b=1, q=n_target_img, ho, wo) target rays ray_gt_dict: ray_rgbs: (b=1, q=n_target_img, ho, wo, 3) ray_ts: (b=1, q=n
(self, i)
| 235 | return self.total |
| 236 | |
| 237 | def __getitem__(self, i) -> T.Dict[str, T.Any]: |
| 238 | """ |
| 239 | Returns: |
| 240 | point_cloud: |
| 241 | PointCloud, (b=1, n), n: number of points |
| 242 | ray: |
| 243 | Ray, (b=1, q=n_target_img, ho, wo) target rays |
| 244 | ray_gt_dict: |
| 245 | ray_rgbs: (b=1, q=n_target_img, ho, wo, 3) |
| 246 | ray_ts: (b=1, q=n_target_img, ho, wo) |
| 247 | surface_normals_w: (b=1, q=n_target_img, ho, wo, 3) |
| 248 | hit_map: (b=1, q=n_target_img, ho, wo) 1 if hit a surface, 0 otherwise |
| 249 | """ |
| 250 | |
| 251 | # read texture images |
| 252 | if self.texture_idxs is not None: |
| 253 | texture_imgs = [] |
| 254 | for tidx in range(len(self.texture_idxs[i])): |
| 255 | timeout_sec = 5 |
| 256 | try: |
| 257 | # time out for 5 seconds passed |
| 258 | img = func_timeout( |
| 259 | timeout_sec, imageio.v3.imread, args=(self.texture_filenames[self.texture_idxs[i, tidx]],)) |
| 260 | except FunctionTimedOut: |
| 261 | print( |
| 262 | f"reading image {self.texture_filenames[self.texture_idxs[i, tidx]]}, time out after {timeout_sec} secs") |
| 263 | img = np.ones((500, 500, 3)) |
| 264 | except Exception as e: |
| 265 | print( |
| 266 | f"reading image {self.texture_filenames[self.texture_idxs[i, tidx]]}, failed") |
| 267 | img = np.ones((500, 500, 3)) |
| 268 | |
| 269 | if len(img.shape) == 2: |
| 270 | img = np.stack((img, img, img), axis=-1) |
| 271 | |
| 272 | if img.shape[-1] > 3: |
| 273 | img = img[..., :3] |
| 274 | |
| 275 | # crop image |
| 276 | h, w = img.shape[:2] |
| 277 | if self.texture_crop_method == 'full': |
| 278 | s = min(h, w) |
| 279 | elif isinstance(self.texture_crop_method, str): |
| 280 | # {min_s}-{max_s} |
| 281 | min_s, max_s = self.texture_crop_method.split('-', 1) |
| 282 | max_s = min(w, min(h, int(max_s))) |
| 283 | min_s = int(min_s) |
| 284 | min_s = max(1, min_s) |
| 285 | max_s = max(1, max_s) |
| 286 | min_s = min(min_s, max_s) |
| 287 | s = self.rng.randint(low=min_s, high=max_s + 1) |
| 288 | elif isinstance(self.texture_crop_method, int): |
| 289 | max_s = min(h, w) |
| 290 | min_s = min(max_s, self.texture_crop_method) |
| 291 | s = self.rng.randint(low=min_s, high=max_s + 1) |
| 292 | else: |
| 293 | raise NotImplementedError |
| 294 |
nothing calls this directly
no test coverage detected