Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix euclidean depth when as_point3d, better handle points behind camera #311

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions aloscene/depth.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def as_points3d(

y_points = y_points.reshape((-1,))
x_points = x_points.reshape((-1,))
z_points = self.as_tensor().reshape(target_shape)
z_points = z_points.reshape(target_shape)

points_3d_shape = tuple(list(target_shape)[:-1] + [self.H * self.W] + [3])
points_3d = torch.zeros(points_3d_shape, device=self.device)
Expand Down Expand Up @@ -296,9 +296,14 @@ def as_points3d(
)

# find points behind camera
behind = theta > (np.pi / 2)
xy = torch.zeros([*behind.shape[:-1], 2], dtype=torch.bool, device=behind.device)
behind = torch.cat([xy, behind], dim=-1)
behind = (theta > (np.pi / 2)).squeeze()
repeats = []
for name in intrinsic.names:
if name in ["B", "T"]:
behind = behind.unsqueeze(0)
repeats.append(1)
behind = behind.unsqueeze(-1).repeat(repeats + [1, 3])
behind[..., -1] = False

points_3d[..., 0] = x_points - principal_points[..., 0:1]
points_3d[..., 1] = y_points - principal_points[..., 1:]
Expand Down