diplomat.wx_gui.labeler_lib.PoseLabeler¶
- class diplomat.wx_gui.labeler_lib.PoseLabeler[source]¶
Bases:
ABCA PoseLabeler represents a labeling mode in the UI.
A pose labeler takes a user input at a given location in the video, and returns a new pose prediction based on the user input and additonal internal information. This allows for ‘smart’ labelers to be created.
- __init__()¶
Methods
__init__()Get the display name of the pose labeler as to be displayed in the UI.
Get the settings for this pose labeler.
pose_change(new_state)Finalize a user change, updating any internal state or frame storage to enforce the user labeling.
predict_location(frame_idx, bp_idx, x, y, ...)Predict the location of a user input, while not changing the internal state of the frames.
redo(data)Redo a pose change handled by this pose labeler.
Get if this pose labeler supports editing multiple parts at once...
undo(data)Undo a pose change handled by this pose labeler.
- get_display_name()[source]¶
Get the display name of the pose labeler as to be displayed in the UI.
- Returns:
The display name. The default implementation returns the class name with a space inserted before every capital letter.
- get_settings() SettingCollection | None[source]¶
Get the settings for this pose labeler. Should return None or a SettingCollection, which contains SettingWidgets. These will be automatically added to the UI when this labeling mode is selected.
- Returns:
A SettingCollection or None. The default implementation returns None, indication this plugin has no configurable settings to place into the UI.
- abstractmethod pose_change(new_state: Any) Any[source]¶
Finalize a user change, updating any internal state or frame storage to enforce the user labeling.
- Parameters:
new_state – The state returned by ‘predict_location’ to finalize.
- Returns:
Any data, information needed if the user ever want to undo this labeling, passed to the ‘undo’ method.
- abstractmethod predict_location(frame_idx: int, bp_idx: int, x: float, y: float, probability: float) Tuple[Any, Tuple[float, float, float]][source]¶
Predict the location of a user input, while not changing the internal state of the frames. Used to display the next location of the point as the user drags their mouse around the screen.
- Parameters:
frame_idx – The index of the current frame the pose labeling UI is on.
bp_idx – The index of the current body part the pose labeling UI is on.
x – The x location the user clicked in video coordinates, or None if the user indicated the body part is not in this frame.
y – The y location the user clicked in video, or None if the user indicated the body part is not in this frame.
probability – The probability of this prediction, 1 if the user selected a location in the video frame, None otherwise.
- Returns:
A tuple containing the following information:
Any data, representing the new state this pose labeler would set if this prediction is eventually finalized, is passed to the pose_change method on finalization.
A tuple of 3 floats, being the location (x, y) of the prediction in the video, and the probability. This is where the point is displayed in the UI. Must be floats, set the probability to 0 to avoid plotting a point.
- abstractmethod redo(data: Any) Any[source]¶
Redo a pose change handled by this pose labeler.
- Parameters:
data – Data returned from ‘undo’ to handle this redo event if it ever happened.
- Returns:
Any data, which will be passed to ‘undo’ if the user decides to undo this labeling in the UI.
- classmethod supports_multi_label() bool[source]¶
Get if this pose labeler supports editing multiple parts at once…
- Returns:
A boolean, true if this labeler wants to allow the user to manipulate multiple parts at once. Defaults to false.
- abstractmethod undo(data: Any) Any[source]¶
Undo a pose change handled by this pose labeler.
- Parameters:
data – Data returned from ‘pose_change’ or ‘redo’ to handle this undo event if it ever happened.
- Returns:
Any data, which will be passed to ‘redo’ if the user decides to redo this labeling in the UI.