Jointly resize image + depthmap so that (W, H) >= output_resolution.
(image, depthmap, camera_intrinsics, output_resolution, force=True)
| 73 | # ---- Crop/resize functions ---- |
| 74 | |
| 75 | def rescale_image_depthmap(image, depthmap, camera_intrinsics, output_resolution, force=True): |
| 76 | """Jointly resize image + depthmap so that (W, H) >= output_resolution.""" |
| 77 | image = ImageList(image) |
| 78 | input_resolution = np.array(image.size) |
| 79 | output_resolution = np.array(output_resolution) |
| 80 | if depthmap is not None: |
| 81 | assert tuple(depthmap.shape[:2]) == image.size[::-1] |
| 82 | |
| 83 | assert output_resolution.shape == (2,) |
| 84 | scale_final = max(output_resolution / image.size) + 1e-8 |
| 85 | if scale_final >= 1 and not force: |
| 86 | return (image.to_pil(), depthmap, camera_intrinsics) |
| 87 | output_resolution = np.floor(input_resolution * scale_final).astype(int) |
| 88 | |
| 89 | image = image.resize(tuple(output_resolution), resample=lanczos if scale_final < 1 else bicubic) |
| 90 | if depthmap is not None: |
| 91 | depthmap = cv2.resize(depthmap, output_resolution, fx=scale_final, |
| 92 | fy=scale_final, interpolation=cv2.INTER_NEAREST) |
| 93 | |
| 94 | camera_intrinsics = camera_matrix_of_crop( |
| 95 | camera_intrinsics, input_resolution, output_resolution, scaling=scale_final) |
| 96 | |
| 97 | return image.to_pil(), depthmap, camera_intrinsics |
| 98 | |
| 99 | |
| 100 | def crop_image_depthmap(image, depthmap, camera_intrinsics, crop_bbox): |
no test coverage detected