Skip to content

Refactor for skeleton display implementation - #119

Draft
C-Achard wants to merge 8 commits into
cy/fix-double-throttlingfrom
cy/skeleton-final
Draft

Refactor for skeleton display implementation#119
C-Achard wants to merge 8 commits into
cy/fix-double-throttlingfrom
cy/skeleton-final

Conversation

@C-Achard

@C-Achard C-Achard commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Brings back the skeleton display implementation from #60, and refactors:

  • Config
  • Display code
  • Inference API

to be more flexible and accommodate upcoming implementations of skeleton display in #120 and POET model in #121

@C-Achard C-Achard self-assigned this Aug 27, 2026
@C-Achard C-Achard added enhancement New feature or request config Related to user configs, oading, saving, etc labels Aug 27, 2026
@C-Achard
C-Achard requested a balanced review from Copilot August 27, 2026 13:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors display and inference APIs and introduces reusable skeleton-rendering foundations for upcoming GUI/model integrations.

Changes:

  • Moves display utilities into a dedicated package.
  • Extracts shared inference contracts from the DLC processor.
  • Adds skeleton metadata, configuration, resolution, and rendering utilities.

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/utils/test_display.py Updates display imports.
tests/services/test_dlc_processor.py Updates inference contract imports.
dlclivegui/utils/stats.py Uses extracted processor statistics type.
dlclivegui/services/inference/base.py Defines shared inference contracts and skeleton metadata.
dlclivegui/services/inference/__init__.py Creates the inference package.
dlclivegui/services/dlc_processor.py Adopts extracted inference contracts.
dlclivegui/gui/main_window.py Uses the relocated display package.
dlclivegui/display/skeleton.py Implements skeleton resolution and rendering.
dlclivegui/display/display.py Houses existing display utilities.
dlclivegui/display/__init__.py Exposes display utility APIs.
dlclivegui/config.py Adds skeleton style configuration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +241 to +251
def draw_skeleton(
frame: np.ndarray,
poses: np.ndarray | None,
skeleton: ResolvedSkeleton,
style: SkeletonStyle,
*,
p_cutoff: float,
offset: tuple[int, int] = (0, 0),
scale: tuple[float, float] = (1.0, 1.0),
keypoint_colors: tuple[BGR, ...] | None = None,
) -> SkeletonRenderResult:
Comment thread dlclivegui/config.py
visible: bool = False
color_mode: SkeletonColorMode = SkeletonColorMode.SOLID
color_bgr: BGR = (0, 255, 255) # default if SOLID
thickness: int = Field(defalt=2, ge=1, le=20) # base thickness in pixels
@C-Achard
C-Achard changed the base branch from master to cy/fix-double-throttling August 28, 2026 13:10
Update `SkeletonStyle` to support explicit visibility and clearer naming (`color_mode`, `color_bgr`), and switch numeric styling options to constrained `Field` definitions for validated thickness and gradient step ranges.
Introduce typed skeleton resolution primitives (`SkeletonEdge`, `SkeletonDefinition`, `ResolvedSkeleton`) and a `resolve_skeleton` helper that validates keypoint inputs, detects duplicates/missing names, and raises `SkeletonResolutionError` with clear messages. Also align rendering with renamed style fields (`mode` -> `color_mode`, `color` -> `color_bgr`) so initialization and draw paths use the updated `SkeletonStyle` API, and fix the module path header comment.
Move pose-related enums and dataclasses (PoseBackends, WorkerState, PoseSource, PosePacket, PoseResult) out of `dlc_processor.py` into a new `services/inference/base.py` module and import them back into the processor. This centralizes inference contracts for reuse and extends `PosePacket` with optional skeleton metadata fields (`skeleton_id`, `skeleton_edges`).
Reworks `display/skeleton.py`. It replaces the old `Skeleton` runtime/model loading stack with immutable skeleton definition/resolution dataclasses, adds validated metadata-to-definition construction, and introduces a standalone `draw_skeleton(...)` path that supports both single and multi-individual poses. Rendering now returns a structured `SkeletonRenderResult` with clearer status codes (including no-pose, invalid shape, keypoint mismatch, and gradient color mismatch) and tracks drawn edge count.
Move `ProcessorStats` from `dlc_processor` into `services.inference.base` so it can be imported as a shared inference type, and update dependent imports/tests accordingly. Add a typed `SkeletonPacket` protocol plus `resolve_packet_skeleton()` to consistently resolve packet-provided skeleton metadata into a `ResolvedSkeleton` only when required fields are present.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Related to user configs, oading, saving, etc enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants