diplomat.wx_gui.point_edit.PointViewNEdit¶
- class diplomat.wx_gui.point_edit.PointViewNEdit(*args: Any, **kwargs: Any)[source]¶
Bases:
VideoPlayer,BasicDataFieldss An extension of the VideoPlayer widget, which is also capable of display body part locations and allowing the user to edit them. This is one of the two components which makes up the Point Editor….
- __init__(parent, video_hdl: VideoCapture, crop_box: Tuple[int, int, int, int] | None, poses: Pose, skeleton_info: StorageGraph, colormap: str | list | Colormap = None, shape_list: Iterable[str] = None, plot_threshold: float = 0.1, point_radius: int = 5, point_alpha: float = 0.7, line_thickness: int = 1, ctrl_speed_divider=3, w_id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.BORDER_DEFAULT, validator=wx.DefaultValidator, name='VideoPlayer')[source]¶
Construct a new PointNViewEdit
- Parameters:
parent – The wx Control Parent.
video_hdl – The cv2 VideoCapture to play video from. One should avoid never manipulate the video capture once passed to this constructor, as the handle will be passed to another thread for fast video loading.
crop_box – A tuple of 4 integers being the x, y, width, and height of the cropped area of the video.
poses – The Pose object for the above video, used as initial point data.
colormap – The matplotlib colormap to use when coloring the points.
shape_list – The list of shapes to draw as ‘dots’ for each point. A list of strings or None.
plot_threshold – The probability threshold at which to not plot a points. Defaults to 0.1.
point_radius – Determines the size of the points. Defaults to 5.
point_alpha – Determines the alpha level of the points. Defaults to 0.7.
line_thickness – The thickness to draw occluded poses with. Defaults to 1.
ctrl_speed_divider – The initial slow down multiplier while labeling in fast mode. Defaults to 8.
w_id – The wx ID.
pos – The position of the widget.
size – The size of the widget.
style – The style of the widget.
validator – The widgets validator.
name – The name of the widget.
Methods
__init__(parent, video_hdl, crop_box, poses, ...)Construct a new PointNViewEdit
PRIVATE: Triggered when moving from frame-to-frame in fast labeling mode, increments the frame and finalizes
freeze()Freeze the video player, immediately pausing the video and making it unresponsive to play/pause/stop commands, and also frame changing methods.
Get the Poses of this PointViewNEdit.
get_colormap()Get the fast labeling mode speed multiplier.
get_heatmap_alpha()get_heatmap_colormap()get_heatmap_source()get_labeling_class(name)get_labeling_mode()get_line_thickness()Get the current frame index we are at in the video.
get_plot_threshold()get_point_alpha()get_point_radius()get_pose(frame, bodypart)Get the pose, or point data at the given frame and body part.
Get the selected body part.
get_selected_heatmap()get_shape_list()Get the total number of frames in this video.
init_class()Check whether this video is frozen.
Returns whether or not the video is currently playing.
move_back([amount])Move backward a given amount of frames.
move_forward([amount])Move forward a given amount of frames.
on_draw(dc)Called when redrawing the PointViewNEdit Control.
on_key_down(event)PRIVATE: Triggered on key press event.
on_mouse_exit(event)on_paint(event)Run on a paint event, redraws the widget.
on_right_click(event)PRIVATE: Executed on right click, makes the point disappear as if it isn't in this frame.
pause()Pause the video.
play()Play the video.
register_labeling_mode(pose_labeler)set_all_poses(poses)Set all of the poses(points) of this control to the new pose object.
set_colormap(value)Set the fast mode speed multiplier.
set_heatmap_alpha(value)set_heatmap_colormap(value)set_heatmap_source(func)set_keyboard_listener(window)Set the wx Window which will handle keyboard events for this Player.
set_labeling_mode(labeler_name)set_line_thickness(value)set_offset_frames(value)Set the current frame offset location into the video.
set_plot_threshold(value)set_point_alpha(value)set_point_radius(value)set_pose(frame, bodypart, value)Set the pose, or point data at the given frame and body part.
set_selected_bodyparts(value)Set the selected body part.
set_selected_heatmap(selected_heatmap)set_shape_list(value)stop()Stop the video.
unfreeze()Unfreeze the video, allowing controls to work again.
unregister_labeling_mode(labeler_name)Attributes
BACK_LOAD_AMTDEF_FAST_MODE_SPEED_FRACTIONDEF_MAPEVT_FRAME_CHANGEEVT_PLAY_STATE_CHANGEEVT_POINT_CHANGEEVT_POINT_ENDEVT_POINT_INITFAST_MODE_KEYFrameChangeEventJUMP_BACK_AMTJUMP_BACK_DELAYJUMP_BACK_KEYMAX_FAST_FORWARD_MODEMETHOD_LISTPlayStateChangeEventPointChangeEventPointEndEventPointInitEventZOOM_KEYvideo_transform- __del__()¶
Delete this video player, deleting its video reading thread.
- _get_mouse_loc_video(evt: wx.MouseEvent | Tuple[float | None, float | None]) Tuple[float | None, float | None][source]¶
PRIVATE: Get the mouse location in video coordinates given a mouse event.
- _get_mouse_no_evt() Tuple[float | None, float | None][source]¶
PRIVATE: Get the location of the mouse in video coordinates given no event.
- _get_selected_bodyparts() List[Tuple[float, float, float]][source]¶
PRIVATE: Get the currently selected body part in the video.
- _on_mouse_down(evt: wx.MouseEvent)[source]¶
PRIVATE: Executed whenever the mouse is pressed down, triggering a PointInitEvent.
- _on_mouse_move(evt: wx.MouseEvent, force_move=False)[source]¶
PRIVATE: Executed whenever the mouse is moved, simply displaying the new point location on screen.
- _on_mouse_up(evt: wx.MouseEvent)[source]¶
PRIVATE: Executed whenever the mouse is released, triggering a PointChangeEvent followed by a PointEndEvent.
- _point_prediction(x: float | None, y: float | None) Tuple[List[Any], List[Tuple[float, float, float]]][source]¶
PRIVATE: Makes a location prediction based on the user submitted point, and returns the submission data needed to force a full relocation for this labeler, and the predicted point location…
- _point_relocation(x: float | None, y: float | None) Tuple[List[Any], List[Tuple[float, float, float]]][source]¶
PRIVATE: Makes a location prediction using _point_prediction, and then submits a point relocation to the point labeler, updating the labelers internal state. Returns the history data required to undo this point relocation event.
- _push_point_change_event(part: int, new_point: Tuple[float, float, float], old_point: Tuple[float, float, float], labeler: PoseLabeler, labeler_data: Any)[source]¶
PRIVATE: Emits a PointChangeEvent from this widget with the provided values above.
- _push_point_init_event(old_points: List[Tuple[float, float, float]])[source]¶
PRIVATE: Emits a PointInitEvent from this widget with the provided values above.
- _push_time_change_event()¶
PRIVATE: Used to specify how long the event should
- _set_part(bp: int, x: float, y: float, probability: float)[source]¶
PRIVATE: Set the currently selected body part in the video to a new location.
- fast_mode_move_frame()[source]¶
- PRIVATE: Triggered when moving from frame-to-frame in fast labeling mode, increments the frame and finalizes
the point location.
- freeze()¶
Freeze the video player, immediately pausing the video and making it unresponsive to play/pause/stop commands, and also frame changing methods.
- get_all_poses() Pose[source]¶
Get the Poses of this PointViewNEdit.
- Returns:
A Pose object, being the Pose object of this PointViewNEdit.
- get_ctrl_speed_divider() int[source]¶
Get the fast labeling mode speed multiplier. The higher the value the slower the playback.
- Returns:
An integer between 0 and 1000, which is multiplied with the video frame rate to determine the frame changing speed.
- get_offset_count()¶
Get the current frame index we are at in the video.
- Returns:
An integer, the frame offset.
- get_pose(frame: int, bodypart: int) Tuple[float, float, float][source]¶
Get the pose, or point data at the given frame and body part.
- Parameters:
frame – An integer, the frame index to change.
bodypart – An integer, the body part index to change.
- Returns:
A Tuple of floats, being the x video coordinate, y video coordinate, and probability at the given location.
- get_selected_body_parts() ndarray[source]¶
Get the selected body part. The selected body part can be modified in the point editor.
- Returns:
An integer index, being the index of the selected body part.
- get_total_frames()¶
Get the total number of frames in this video.
- Returns:
An integer being the total frame count of the video.
- is_frozen() bool¶
Check whether this video is frozen.
- Returns:
True is this video is frozen and therefore will not respond to any play/pause/stop commands, or False otherwise.
- is_playing() bool¶
Returns whether or not the video is currently playing.
- move_back(amount: int = 1)¶
Move backward a given amount of frames.
- Parameters:
amount – A non-negative integer. Being how many frames to move backward. Defaults to 1. Can be 0, does nothing if so.
- move_forward(amount: int = 1)¶
Move forward a given amount of frames.
- Parameters:
amount – A non-negative integer. Being how many frames to move forward. Defaults to 1. Can be 0, does nothing if so.
- on_draw(dc: wx.DC)[source]¶
Called when redrawing the PointViewNEdit Control.
- Parameters:
dc – The wx.DC to draw to.
- on_key_down(event: wx.KeyEvent)[source]¶
PRIVATE: Triggered on key press event. Determines if we should enter fast labeling mode.
- on_paint(event)¶
Run on a paint event, redraws the widget.
- on_right_click(event: wx.MouseEvent)[source]¶
PRIVATE: Executed on right click, makes the point disappear as if it isn’t in this frame.
- pause()¶
Pause the video.
- play()¶
Play the video.
- set_all_poses(poses: Pose)[source]¶
Set all of the poses(points) of this control to the new pose object.
- Parameters:
poses – A Pose object. Not copied, so data can be manipulated…
- set_ctrl_speed_divider(val: int)[source]¶
Set the fast mode speed multiplier. The larger the slower.
- Parameters:
val – An integer between 0 and 1000, which is multiplied with the video frame rate to determine the frame changing speed.
- set_keyboard_listener(window: wx.Window)[source]¶
Set the wx Window which will handle keyboard events for this Player.
- Parameters:
window – A wx.Window to attach a listener to.
- set_offset_frames(value: int)¶
Set the current frame offset location into the video.
- Parameters:
value – An integer index, being the frame to move to in the video.
- set_pose(frame: int, bodypart: int, value: Tuple[float, float, float])[source]¶
Set the pose, or point data at the given frame and body part.
- Parameters:
frame – An integer, the frame index to change.
bodypart – An integer, the body part index to change.
value – A Tuple of floats, being the x video coordinate, y video coordinate, and probability to set the point data to.
- set_selected_bodyparts(value: List[int] | ndarray)[source]¶
Set the selected body part. The selected body part can be modified in the point editor.
- Parameters:
value – An integer index, being the index to set the selected body part to.
- stop()¶
Stop the video.
- unfreeze()¶
Unfreeze the video, allowing controls to work again.