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

Add triangulated 3d pose attribute #2082

Open
wants to merge 38 commits into
base: liezl/add-gui-elements-for-sessions
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
31ac7b6
Add attribute for 3d triangulation
Jvshen Jan 9, 2025
ba04209
Added projection bounds and excluded views inputs to update_points an…
Jvshen Jan 14, 2025
a32dbaa
Verify inputs
Jvshen Jan 14, 2025
3715a59
Fix shapes
Jvshen Jan 14, 2025
68e5746
Rename points_3d to points_reprojected
Jvshen Jan 14, 2025
f3bce0d
Change tests to match changes
Jvshen Jan 14, 2025
9ed8417
Set excluded_complete to False in tests
Jvshen Jan 15, 2025
b07e305
Add inputs for update_points in upsert_points
Jvshen Jan 23, 2025
49defef
Remove projection bounds logic in upsert_points
Jvshen Jan 23, 2025
c4db7b4
Lint
roomrys Jan 23, 2025
b0b9254
Add InstanceGroup.update_points_from_2d method
roomrys Jan 23, 2025
a342bcb
Lint
roomrys Jan 23, 2025
f84ddfb
Test InstanceGroup.update_points_from_2d
roomrys Jan 23, 2025
5f5ef66
Fix input validation for update_points_from_2d
roomrys Jan 23, 2025
026c78f
Move shape check to top of function
roomrys Jan 23, 2025
1e21539
Test that all out of bounds means no update
roomrys Jan 23, 2025
36fd472
Test with some out of bound and some in bound
roomrys Jan 23, 2025
ae2f317
Test some in and out of bounds with different bounds
roomrys Jan 23, 2025
37bca05
Remove old test code
roomrys Jan 23, 2025
64948f0
Update comments in test
roomrys Jan 23, 2025
956e110
Template for frame group upsert point
roomrys Jan 23, 2025
674538d
Pass 3D points in triangulate command
roomrys Jan 23, 2025
343ff0d
Add test for frame_group_upsert_points
Jvshen Jan 27, 2025
675964c
Update doctring for instance_groups input
Jvshen Jan 28, 2025
d9e2037
Add checks for correct shape of points
Jvshen Jan 28, 2025
0d959fe
Fix tests for upsert points
Jvshen Jan 28, 2025
895688b
Set triangulation attribute equal to points
Jvshen Jan 28, 2025
af9701a
Add test that our triangulation attribute equals points
Jvshen Jan 28, 2025
9206354
Squeeze points_3d to be of I x N x 3 dimension
Jvshen Jan 28, 2025
9623d29
black commands.py
Jvshen Jan 28, 2025
e39fb08
black cameras.py
Jvshen Jan 28, 2025
b861bbe
black test_cameras.py
Jvshen Jan 28, 2025
8afe46f
Change format
Jvshen Feb 4, 2025
c97c8a2
Add docstring for update_points_from_2d
Jvshen Feb 4, 2025
dbe9674
Change location of call
Jvshen Feb 4, 2025
e3ed548
Add tests for update_points when it fails
Jvshen Feb 4, 2025
ff65ab0
Add tests for update_points_from_2d when it fails
Jvshen Feb 4, 2025
eb069ec
Add tests for upsert_points when it fails
Jvshen Feb 4, 2025
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
Prev Previous commit
Next Next commit
Test some in and out of bounds with different bounds
roomrys committed Jan 23, 2025
commit ae2f317b30725f8029cbd670a2c1e3986c0f3d86
44 changes: 44 additions & 0 deletions tests/io/test_cameras.py
Original file line number Diff line number Diff line change
@@ -829,6 +829,50 @@ def test_instance_group_update_points_from_2d(
) # Not updated
assert np.all(instance_group_numpy[~oob_mask_1d_expanded] == value) # Updated

# Test `upsert_points` (between x,y bounds, some out of bound, some updated)
value = 300
points = np.full((n_cameras, n_nodes, n_coords), value)
# Reset the points to all in bounds
instance_group.update_points_from_2d(
points_reprojected=points,
projection_bounds=projection_bounds,
cams_to_include=cams_to_include,
exclude_complete=False,
)
assert np.all(instance_group.numpy(invisible_as_nan=False) == value)
# Add some out of bounds points
prev_value = value
value = 400
points = np.full((n_cameras, n_nodes, n_coords), value)
max_bound = projection_bounds.max()
oob_value = max_bound - 1
assert oob_value < max_bound and oob_value > min_bound
oob_mask = np.random.choice([True, False], size=(n_cameras, n_nodes, n_coords))
points[oob_mask] = oob_value
instance_group.update_points_from_2d(
points_reprojected=points,
projection_bounds=projection_bounds,
cams_to_include=cams_to_include,
exclude_complete=False,
)
# Get the logical or for either x or y being out of bounds
bound_x, bound_y = projection_bounds[:, 0].min(), projection_bounds[:, 1].min()
oob_mask_x = np.where(points[:, :, 0] > bound_x, True, False)
oob_mask_y = np.where(points[:, :, 1] > bound_y, True, False)
oob_mask_1d = np.logical_or(oob_mask_x, oob_mask_y)
oob_mask_1d_expanded = np.expand_dims(oob_mask_1d, axis=-1)
oob_mask_1d_expanded = np.broadcast_to(oob_mask_1d_expanded, oob_mask.shape)
instance_group_numpy = instance_group.numpy(invisible_as_nan=False)
assert np.any(instance_group_numpy[:, :, 0] > bound_x) == False
assert np.any(instance_group_numpy[:, :, 1] > bound_y) == False
assert np.all(
instance_group_numpy[oob_mask_1d_expanded] == prev_value
) # Not updated
oob_value_mask = np.logical_and(~oob_mask_1d_expanded, oob_mask)
value_mask = np.logical_and(~oob_mask_1d_expanded, ~oob_mask)
assert np.all(instance_group_numpy[oob_value_mask] == oob_value) # Updated to oob
assert np.all(instance_group_numpy[value_mask] == value) # Updated to value


def test_frame_group(
multiview_min_session_labels: Labels, multiview_min_session_frame_groups: Labels