Skip to content

Commit

Permalink
added suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrinath22 committed Oct 25, 2023
1 parent 6f73dfe commit 78560e1
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions sleap/gui/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2989,24 +2989,26 @@ def set_visible_nodes(

has_missing_nodes = False

#calculate scale factor for getting new x and y values
old_size_width = copy_instance.frame.video.shape[2]
old_size_height = copy_instance.frame.video.shape[1]
new_size_width = new_instance.frame.video.shape[2]
new_size_height = new_instance.frame.video.shape[1]
scale_width = new_size_width / old_size_width
scale_height = new_size_height / old_size_height

# go through each node in skeleton
for node in context.state["skeleton"].node_names:
# if we're copying from a skeleton that has this node
if node in copy_instance and not copy_instance[node].isnan():
# just copy x, y, and visible
# Ensure x, y inside current frame, then copy x, y, and visible
# we don't want to copy a PredictedPoint or score attribute
x_old = copy_instance[node].x
y_old = copy_instance[node].y
old_size_width= copy_instance.frame.video.shape[2]
old_size_height= copy_instance.frame.video.shape[1]
new_size_width= new_instance.frame.video.shape[2]
new_size_height= new_instance.frame.video.shape[1]
x_new = (x_old/old_size_width) * new_size_width
y_new = (y_old/old_size_height) * new_size_height
x_new = x_old * scale_width
y_new = y_old * scale_height

new_instance[node] = Point(
# x=copy_instance[node].x,
# y=copy_instance[node].y,
x = x_new,
y = y_new,
visible=copy_instance[node].visible,
Expand Down

0 comments on commit 78560e1

Please sign in to comment.