(size: int)
| 120 | |
| 121 | |
| 122 | def create_pan_cameras(size: int) -> DifferentiableProjectiveCamera: |
| 123 | origins = [] |
| 124 | xs = [] |
| 125 | ys = [] |
| 126 | zs = [] |
| 127 | for theta in np.linspace(0, 2 * np.pi, num=20): |
| 128 | z = np.array([np.sin(theta), np.cos(theta), -0.5]) |
| 129 | z /= np.sqrt(np.sum(z**2)) |
| 130 | origin = -z * 4 |
| 131 | x = np.array([np.cos(theta), -np.sin(theta), 0.0]) |
| 132 | y = np.cross(z, x) |
| 133 | origins.append(origin) |
| 134 | xs.append(x) |
| 135 | ys.append(y) |
| 136 | zs.append(z) |
| 137 | return DifferentiableProjectiveCamera( |
| 138 | origin=torch.from_numpy(np.stack(origins, axis=0)).float(), |
| 139 | x=torch.from_numpy(np.stack(xs, axis=0)).float(), |
| 140 | y=torch.from_numpy(np.stack(ys, axis=0)).float(), |
| 141 | z=torch.from_numpy(np.stack(zs, axis=0)).float(), |
| 142 | width=size, |
| 143 | height=size, |
| 144 | x_fov=0.7, |
| 145 | y_fov=0.7, |
| 146 | shape=(1, len(xs)), |
| 147 | ) |
no test coverage detected