Skip to content

Conversation

@bipinkrish
Copy link
Contributor

@bipinkrish bipinkrish commented Mar 21, 2024

Issue for more info : #82

Copy link
Collaborator

@AmitMY AmitMY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Good work! Minor modifications required/should be discussed.

colors = [np.array(c[::-1]) for c in component.colors]

@lru_cache(maxsize=None)
def _point_color(p_i: int):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would add transparency=False, since it can be that we don't want it.

opacity = c[p_i + idx]
np_color = colors[p_i % len(component.colors)] * opacity + (1 - opacity) * background_color
np_color = colors[p_i % len(component.colors)] * opacity + (1 - opacity) * background_color[:3]
np_color = np.append(np_color, opacity * 255)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only when transparency==True

return img

def draw(self, background_color: Tuple[int, int, int] = (255, 255, 255), max_frames: int = None):
def draw(self, background_color: Tuple[int, int, int] = (255, 255, 255), max_frames: int = None, alpha: int = 0):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too I think we should have transparency, not alpha, because this will (IMO) break support for video exports

background_color += (alpha,)
int_frames = np.array(np.around(self.pose.body.data.data), dtype="int32")
background = np.full((self.pose.header.dimensions.height, self.pose.header.dimensions.width, 3),
background = np.full((self.pose.header.dimensions.height, self.pose.header.dimensions.width, 4),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and then I'd split this into two cases, transparent or not

duration=1000 / self.pose.body.fps,
loop=0)

def save_png(self, f_name: str, frames: Iterable[np.ndarray]):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think save_png and save_gif could be both using save_image(f_name: str, frames: ..., format="PNG", transparency=False) for example. right now the code is mostly duplicate

images[0].save(f_name,
format="GIF",
append_images=images,
append_images=images[1:],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch!

@bipinkrish
Copy link
Contributor Author

All the changes requested are fixed

Copy link
Collaborator

@AmitMY AmitMY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absolutely fantastic.

@AmitMY AmitMY merged commit 581d4ce into sign-language-processing:master Mar 21, 2024
@bipinkrish bipinkrish deleted the png branch March 21, 2024 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants