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

Keyframe animation with camera support #626

Closed

Conversation

m-agour
Copy link
Contributor

@m-agour m-agour commented Jul 13, 2022

This is the no-shader version of the animation system that consists of:

  1. The Timeline
  2. PlaybackPanel
  3. Interpolators

I also included some tutorials. They are located at tutorials/01_introductory and their file name starts with viz_keyframe_animation.

Docs are not complete. Will write them and the tests along this week.

Below is a record of tutorial viz_keyframe_animation_camera.py

  • Rotation is not supported yet. Will be implemented this weak along with slerp.
2022-07-13.15-15-49.mp4

@pep8speaks
Copy link

pep8speaks commented Jul 13, 2022

Hello @m-agour! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 351:72: W291 trailing whitespace
Line 361:1: W293 blank line contains whitespace
Line 373:1: W293 blank line contains whitespace

Comment last updated at 2022-07-30 18:00:42 UTC

Copy link
Contributor

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

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

Hi @m-agour,

Thank you for this PR.

See below for some basic comments.

Overall, this is missing unit tests (as you mentioned). Also, I wonder if the interpolator should be function-based instead of class-based. All the functions can be independent and I do not see the value of all this inheritance apart from complexifying the codebase. I will be happy to discuss it.

Concerning your use of a dictionary, I recommend using more dict.get instead of dict[] to avoid strange errors when a key is missing.

The last point is to increase your use of propertydecorator to be more pythonic.

I would recommend focusing on this PR in the next few days. It will be great if it can follow the standard and get merged. After that, we could go to more advanced features.

Thank you.

fury/colormap.py Outdated
@@ -623,3 +624,335 @@ def hex_to_rgb(color):
b = int("0x" + color[4: 6], 0) / 255

return(np.array([r, g, b]))


# Implementation of this function is taken from scikit-image package.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not the right place. you should add a note section in your docsting:

Notes
------
Original Implementation from scikit-image package. it can be found at https://....
this implementation might have been modified.

fury/colormap.py Outdated
return out


# Implementation of this function is taken from scikit-image package.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not the right place. you should add a note section in your docsting:

Notes
------
Original Implementation from scikit-image package. it can be found at https://....
this implementation might have been modified.

fury/colormap.py Outdated
rgb_from_xyz = linalg.inv(xyz_from_rgb)


# Implementation of this function is taken from scikit-image package.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not the right place. you should add a note section in your docsting:

Notes
------
Original Implementation from scikit-image package. it can be found at https://....
this implementation might have been modified.

fury/colormap.py Outdated
return arr


# Implementation of this function is taken from scikit-image package.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not the right place. you should add a note section in your docsting:

Notes
------
Original Implementation from scikit-image package. it can be found at https://....
this implementation might have been modified.

fury/colormap.py Outdated
'R': (1.0, 1.0, 1.0)}}


# Implementation of this function is taken from scikit-image package.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not the right place. you should add a note section in your docsting:

Notes
------
Original Implementation from scikit-image package. it can be found at https://....
this implementation might have been modified.

from fury.actor import Container
from fury.colormap import rgb2hsv, hsv2rgb, rgb2lab, lab2rgb, xyz2rgb, rgb2xyz
from fury.ui.elements import PlaybackPanel
from vtkmodules.vtkRenderingCore import vtkActor
Copy link
Contributor

Choose a reason for hiding this comment

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

from fury.lib import Actor instead

Comment on lines 58 to 75
@staticmethod
def _lerp(v1, v2, t1, t2, t):
if t1 == t2:
return v1
v = v2 - v1
dt = (t - t1) / (t2 - t1)
return dt * v + v1

@staticmethod
def _get_time_delta(t, t1, t2):
return 0 if t <= t1 else 1 if t >= t2 else (t - t1) / (t2 - t1)
Copy link
Contributor

Choose a reason for hiding this comment

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

staticmethod and protected? strange. can you explain?

from vtkmodules.vtkRenderingCore import vtkActor


class Interpolator(object):
Copy link
Contributor

Choose a reason for hiding this comment

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

no need of object since python 3.

math.sqrt((x[1] - y[1]) * (x[1] - y[1]) +
(x[0] - y[0]) * (x[0] - y[0])))

def get_points(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this function is only for this interpolator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I needed the points to calculate the linear lengths only for spline interpolator.
Yeah, it was being used once, and it was simple, so I just added the implementation of it to the setup method directly.

self.id = 5


class Timeline(Container):
Copy link
Contributor

Choose a reason for hiding this comment

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

To be more pythonic, you need to use more the property decorator.

@m-agour
Copy link
Contributor Author

m-agour commented Jul 15, 2022

Hi @m-agour,

Thank you for this PR.

See below for some basic comments.

Overall, this is missing unit tests (as you mentioned). Also, I wonder if the interpolator should be function-based instead of class-based. All the functions can be independent and I do not see the value of all this inheritance apart from complexifying the codebase. I will be happy to discuss it.

Concerning your use of a dictionary, I recommend using more dict.get instead of dict[] to avoid strange errors when a key is missing.

The last point is to increase your use of propertydecorator to be more pythonic.

I would recommend focusing on this PR in the next few days. It will be great if it can follow the standard and get merged. After that, we could go to more advanced features.

Thank you.

Hi @skoudoro, thank you so much for your review.
Making the interpolators function-based is doable and the data (color keyframes in targeted space and spline interpolator) can be stored in the Timeline itself, methods also. I will make an example of this for the spline interpolator then we may discuss which way to proceed.

@codecov
Copy link

codecov bot commented Jul 27, 2022

Codecov Report

Merging #626 (e053926) into master (bca7b33) will decrease coverage by 1.59%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #626      +/-   ##
==========================================
- Coverage   52.04%   50.45%   -1.60%     
==========================================
  Files         108      113       +5     
  Lines       23812    25823    +2011     
  Branches     2631     2919     +288     
==========================================
+ Hits        12394    13028     +634     
- Misses      11013    12341    +1328     
- Partials      405      454      +49     
Impacted Files Coverage Δ
fury/actor.py 0.00% <0.00%> (ø)
fury/animation/interpolator.py 0.00% <0.00%> (ø)
fury/animation/timeline.py 0.00% <0.00%> (ø)
fury/colormap.py 0.00% <0.00%> (ø)
fury/ui/elements.py 0.00% <0.00%> (ø)
fury/ui/tests/test_elements.py 0.00% <0.00%> (ø)
fury/fury/tests/test_window.py 50.94% <0.00%> (-35.43%) ⬇️
fury/fury/ui/tests/test_containers.py 64.76% <0.00%> (-28.96%) ⬇️
fury/fury/window.py 72.85% <0.00%> (-10.41%) ⬇️
fury/fury/shaders/base.py 84.84% <0.00%> (-8.09%) ⬇️
... and 16 more

@skoudoro
Copy link
Contributor

skoudoro commented Aug 3, 2022

superseded by #647. Closing

@skoudoro skoudoro closed this Aug 3, 2022
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.

None yet

5 participants