menpowidgets 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- menpowidgets/__init__.py +22 -0
- menpowidgets/_version.py +24 -0
- menpowidgets/abstract.py +140 -0
- menpowidgets/base.py +3062 -0
- menpowidgets/checks.py +28 -0
- menpowidgets/items.py +103 -0
- menpowidgets/js/webcam.js +81 -0
- menpowidgets/logos/menpoproject_danger.png +0 -0
- menpowidgets/logos/menpoproject_info.png +0 -0
- menpowidgets/logos/menpoproject_minimal.png +0 -0
- menpowidgets/logos/menpoproject_success.png +0 -0
- menpowidgets/logos/menpoproject_warning.png +0 -0
- menpowidgets/menpofitwidgets/__init__.py +19 -0
- menpowidgets/menpofitwidgets/base.py +2392 -0
- menpowidgets/options.py +6708 -0
- menpowidgets/style.py +91 -0
- menpowidgets/test/__init__.py +0 -0
- menpowidgets/test/animation_test.py +145 -0
- menpowidgets/test/conftest.py +17 -0
- menpowidgets/test/helpers.py +122 -0
- menpowidgets/test/menpofit_widgets_test.py +129 -0
- menpowidgets/test/webcam_test.py +38 -0
- menpowidgets/test/widgets3d_test.py +105 -0
- menpowidgets/test/widgets_test.py +127 -0
- menpowidgets/tools.py +5181 -0
- menpowidgets/utils.py +1079 -0
- menpowidgets-0.5.0.dist-info/METADATA +64 -0
- menpowidgets-0.5.0.dist-info/RECORD +32 -0
- menpowidgets-0.5.0.dist-info/WHEEL +5 -0
- menpowidgets-0.5.0.dist-info/licenses/AUTHORS.txt +14 -0
- menpowidgets-0.5.0.dist-info/licenses/LICENSE.txt +30 -0
- menpowidgets-0.5.0.dist-info/top_level.txt +1 -0
menpowidgets/__init__.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from .items import view_widget
|
|
2
|
+
from .base import (
|
|
3
|
+
visualize_patches,
|
|
4
|
+
webcam_widget,
|
|
5
|
+
plot_graph,
|
|
6
|
+
save_matplotlib_figure,
|
|
7
|
+
visualize_patch_appearance_model,
|
|
8
|
+
visualize_images,
|
|
9
|
+
visualize_shapes_2d,
|
|
10
|
+
visualize_shapes_3d,
|
|
11
|
+
visualize_landmarks_2d,
|
|
12
|
+
visualize_landmarks_3d,
|
|
13
|
+
visualize_shape_model_2d,
|
|
14
|
+
visualize_appearance_model,
|
|
15
|
+
visualize_meshes_3d,
|
|
16
|
+
save_mayavi_figure,
|
|
17
|
+
visualize_shape_model_3d,
|
|
18
|
+
visualize_morphable_model,
|
|
19
|
+
)
|
|
20
|
+
from .menpofitwidgets import *
|
|
21
|
+
|
|
22
|
+
from ._version import __version__
|
menpowidgets/_version.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '0.5.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 5, 0)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = 'g48a924625'
|
menpowidgets/abstract.py
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
from ipywidgets import Box, Layout
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class MenpoWidget(Box):
|
|
5
|
+
r"""
|
|
6
|
+
Base class for defining a Menpo widget.
|
|
7
|
+
|
|
8
|
+
The widget has a `selected_values` trait that can be used in order to
|
|
9
|
+
inspect any changes that occur to its children. It also has functionality
|
|
10
|
+
for adding, removing, replacing or calling the handler callback function of
|
|
11
|
+
the `selected_values` trait.
|
|
12
|
+
|
|
13
|
+
Parameters
|
|
14
|
+
----------
|
|
15
|
+
children : `list` of `ipywidgets`
|
|
16
|
+
The `list` of `ipywidgets` objects to be set as children in the
|
|
17
|
+
`ipywidgets.Box`.
|
|
18
|
+
trait : `traitlets.TraitType` subclass
|
|
19
|
+
The type of the `selected_values` object that gets added as a trait
|
|
20
|
+
in the widget. Possible options from `traitlets` are {``Int``, ``Float``,
|
|
21
|
+
``Dict``, ``List``, ``Tuple``}.
|
|
22
|
+
trait_initial_value : `int` or `float` or `dict` or `list` or `tuple`
|
|
23
|
+
The initial value of the `selected_values` trait.
|
|
24
|
+
render_function : `callable` or ``None``, optional
|
|
25
|
+
The render function that behaves as a callback handler of the
|
|
26
|
+
`selected_values` trait for the `change` event. Its signature can be
|
|
27
|
+
``render_function()`` or ``render_function(change)``, where ``change``
|
|
28
|
+
is a `dict` with the following keys:
|
|
29
|
+
|
|
30
|
+
- ``owner`` : the `HasTraits` instance
|
|
31
|
+
- ``old`` : the old value of the modified trait attribute
|
|
32
|
+
- ``new`` : the new value of the modified trait attribute
|
|
33
|
+
- ``name`` : the name of the modified trait attribute.
|
|
34
|
+
- ``type`` : ``'change'``
|
|
35
|
+
|
|
36
|
+
If ``None``, then nothing is added.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
def __init__(self, children, trait, trait_initial_value, render_function=None):
|
|
40
|
+
# Create box object
|
|
41
|
+
super(MenpoWidget, self).__init__(children=children)
|
|
42
|
+
|
|
43
|
+
# Add trait for selected values
|
|
44
|
+
selected_values = trait(default_value=trait_initial_value)
|
|
45
|
+
selected_values_trait = {"selected_values": selected_values}
|
|
46
|
+
self.add_traits(**selected_values_trait)
|
|
47
|
+
self.selected_values = trait_initial_value
|
|
48
|
+
|
|
49
|
+
# Set render function
|
|
50
|
+
self._render_function = None
|
|
51
|
+
self.add_render_function(render_function)
|
|
52
|
+
|
|
53
|
+
def add_render_function(self, render_function):
|
|
54
|
+
r"""
|
|
55
|
+
Method that adds the provided `render_function()` as a callback handler
|
|
56
|
+
to the `selected_values` trait of the widget. The given function is
|
|
57
|
+
also stored in `self._render_function`.
|
|
58
|
+
|
|
59
|
+
Parameters
|
|
60
|
+
----------
|
|
61
|
+
render_function : `callable` or ``None``, optional
|
|
62
|
+
The render function that behaves as a callback handler of the
|
|
63
|
+
`selected_values` trait for the `change` event. Its signature can be
|
|
64
|
+
``render_function()`` or ``render_function(change)``, where
|
|
65
|
+
``change`` is a `dict` with the following keys:
|
|
66
|
+
|
|
67
|
+
- ``owner`` : the `HasTraits` instance
|
|
68
|
+
- ``old`` : the old value of the modified trait attribute
|
|
69
|
+
- ``new`` : the new value of the modified trait attribute
|
|
70
|
+
- ``name`` : the name of the modified trait attribute.
|
|
71
|
+
- ``type`` : ``'change'``
|
|
72
|
+
|
|
73
|
+
If ``None``, then nothing is added.
|
|
74
|
+
"""
|
|
75
|
+
self._render_function = render_function
|
|
76
|
+
if self._render_function is not None:
|
|
77
|
+
self.observe(self._render_function, names="selected_values", type="change")
|
|
78
|
+
|
|
79
|
+
def remove_render_function(self):
|
|
80
|
+
r"""
|
|
81
|
+
Method that removes the current `self._render_function()` as a callback
|
|
82
|
+
handler to the `selected_values` trait of the widget and sets
|
|
83
|
+
``self._render_function = None``.
|
|
84
|
+
"""
|
|
85
|
+
if self._render_function is not None:
|
|
86
|
+
self.unobserve(
|
|
87
|
+
self._render_function, names="selected_values", type="change"
|
|
88
|
+
)
|
|
89
|
+
self._render_function = None
|
|
90
|
+
|
|
91
|
+
def replace_render_function(self, render_function):
|
|
92
|
+
r"""
|
|
93
|
+
Method that replaces the current `self._render_function()` with the
|
|
94
|
+
given `render_function()` as a callback handler to the `selected_values`
|
|
95
|
+
trait of the widget.
|
|
96
|
+
|
|
97
|
+
Parameters
|
|
98
|
+
----------
|
|
99
|
+
render_function : `callable` or ``None``, optional
|
|
100
|
+
The render function that behaves as a callback handler of the
|
|
101
|
+
`selected_values` trait for the `change` event. Its signature can be
|
|
102
|
+
``render_function()`` or ``render_function(change)``, where
|
|
103
|
+
``change`` is a `dict` with the following keys:
|
|
104
|
+
|
|
105
|
+
- ``owner`` : the `HasTraits` instance
|
|
106
|
+
- ``old`` : the old value of the modified trait attribute
|
|
107
|
+
- ``new`` : the new value of the modified trait attribute
|
|
108
|
+
- ``name`` : the name of the modified trait attribute.
|
|
109
|
+
- ``type`` : ``'change'``
|
|
110
|
+
|
|
111
|
+
If ``None``, then nothing is added.
|
|
112
|
+
"""
|
|
113
|
+
# remove old function
|
|
114
|
+
self.remove_render_function()
|
|
115
|
+
|
|
116
|
+
# add new function
|
|
117
|
+
self.add_render_function(render_function)
|
|
118
|
+
|
|
119
|
+
def call_render_function(self, old_value, new_value, type_value="change"):
|
|
120
|
+
r"""
|
|
121
|
+
Method that calls the existing `render_function()` callback handler.
|
|
122
|
+
|
|
123
|
+
Parameters
|
|
124
|
+
----------
|
|
125
|
+
old_value : `int` or `float` or `dict` or `list` or `tuple`
|
|
126
|
+
The old `selected_values` value.
|
|
127
|
+
new_value : `int` or `float` or `dict` or `list` or `tuple`
|
|
128
|
+
The new `selected_values` value.
|
|
129
|
+
type_value : `str`, optional
|
|
130
|
+
The trait event type.
|
|
131
|
+
"""
|
|
132
|
+
if self._render_function is not None:
|
|
133
|
+
change_dict = {
|
|
134
|
+
"type": "change",
|
|
135
|
+
"old": old_value,
|
|
136
|
+
"name": type_value,
|
|
137
|
+
"new": new_value,
|
|
138
|
+
"owner": self.__str__(),
|
|
139
|
+
}
|
|
140
|
+
self._render_function(change_dict)
|