Skip to content

Add skeleton spritekit#204

Closed
asabri97 wants to merge 17 commits intomainfrom
add-skeleton-spritekit
Closed

Add skeleton spritekit#204
asabri97 wants to merge 17 commits intomainfrom
add-skeleton-spritekit

Conversation

@asabri97
Copy link
Contributor

@asabri97 asabri97 commented Oct 29, 2025

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Adds a new real-time, articulated “X-ray” skeleton visualization for pose results using SpriteKit, plus external display and model-loading reliability improvements. 🦴✨

📊 Key Changes

  • New skeleton rendering system
    • Introduces SkeletonUtilities (geometry, effects, texture loading) and SkeletonMask protocol.
    • Adds ArticulatedSkeletonMask to assemble body parts (head, torso, arms, legs, feet) from assets and pose keypoints.
    • Visual effects: vignette, tint-based X-ray look, pulsing alpha animation.
    • Converts normalized keypoints to SpriteKit coordinates and scales/rotates parts per bone angles.
  • PoseEstimator updates
    • New properties: useRealisticSkeleton (toggle), skeletonConfThreshold, skeletonType.
    • New methods to render skeleton overlays on CIImage/UIImage and live view.
  • YOLOView integration
    • Adds a transparent SKView overlay (skeletonView) for real-time skeleton scenes in Pose task.
    • Proper setup/teardown across mode switches and layout updates.
  • ViewController improvements
    • Automatically enables articulated skeleton mode for Pose models.
    • Main-thread safety and cleaner model-loading flow; improved external display coordination.
  • External display robustness
    • Adds hasExternalDisplay supporting iOS 16+ APIs with graceful fallback.
    • Safer logs and notification handling during model switches.
  • Assets added
    • Body part images for head, torso, pelvis, arms, forearms, hands, thighs, shins, feet (left/right).
  • Misc
    • Build version bumped (534 → 574).
    • Minor cleanups (removed unused var, tidied logs, small Plot cleanup).

🎯 Purpose & Impact

  • More engaging pose viz: Users get a visually rich, articulated “X-ray” skeleton that aligns to detected joints in real time. 🕺
  • Clarity and confidence control: Bones are shown based on keypoint confidence, reducing jitter/noise.
  • Better UX: Smooth SpriteKit overlay with subtle effects improves the app’s visual polish.
  • Developer flexibility: Simple toggle via PoseEstimator.useRealisticSkeleton and adjustable skeletonConfThreshold.
  • Stability with external displays: More reliable detection of screens and consistent model update behavior.
  • Backward compatible: Default behavior falls back to standard pose drawing unless skeleton mode is enabled, minimizing risk for existing flows.

@asabri97 asabri97 temporarily deployed to Release - TestFlight October 29, 2025 22:03 — with GitHub Actions Inactive
@UltralyticsAssistant UltralyticsAssistant added enhancement New feature or request pose Pose/keypoint estimation models labels Oct 29, 2025
@UltralyticsAssistant
Copy link
Member

👋 Hello @asabri97, thank you for submitting a ultralytics/yolo-ios-app 🚀 PR! This is an automated message; an engineer will review and assist shortly. To ensure a seamless integration of your work, please review the following checklist:

  • Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions.
  • Synchronize with Source: Confirm your PR is synchronized with the ultralytics/yolo-ios-app main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
  • Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues.
  • Update Documentation: Update the relevant documentation for any new or modified features.
  • Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
  • Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR by writing "I have read the CLA Document and I sign the CLA" in a new message.
  • Minimize Changes: Limit your changes to the minimum necessary for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀

Copy link
Member

@UltralyticsAssistant UltralyticsAssistant left a comment

Choose a reason for hiding this comment

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

🔍 PR Review

Made with ❤️ by Ultralytics Actions

The SpriteKit overlay looks great, but right now those two call sites rebuild the entire mask — and reload every texture — on each frame/inference. Reusing a single ArticulatedSkeletonMask (or its textures) will prevent the skeleton overlay from becoming the dominant performance cost.

💬 Posted 2 inline comments

📋 Skipped 15 files (lock files, minified, images, etc.)


// Ensure skeleton view is properly configured
skeletonView.frame = self.overlayLayer.frame

Choose a reason for hiding this comment

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

⚠️ HIGH: ArticulatedSkeletonMask() is recreated for every frame. Each initializer reloads all 15 textures from disk, so this path will be hit dozens of times per second and will quickly become the hottest point in the render loop. Please cache a single mask (or at least its textures) and reuse it instead of instantiating a new one here.


let imageSize = CGSize(width: ciImage.extent.width, height: ciImage.extent.height)

// Create articulated skeleton scene

Choose a reason for hiding this comment

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

⚠️ HIGH: ArticulatedSkeletonMask() is constructed on every inference pass (also in createRealisticSkeletonImage). The initializer reloads every texture from the asset catalog, so running pose on live video will thrash the main thread and I/O. Please cache one mask instance (or share its textures) on the estimator and reuse it across calls.

@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

❌ Patch coverage is 0% with 472 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
Sources/YOLO/ArticulatedSkeletonMask.swift 0.00% 283 Missing ⚠️
Sources/YOLO/PoseEstimator.swift 0.00% 83 Missing ⚠️
Sources/YOLO/0SkeletonUtilities.swift 0.00% 67 Missing ⚠️
Sources/YOLO/YOLOView.swift 0.00% 39 Missing ⚠️

📢 Thoughts on this report? Let us know!

@asabri97 asabri97 closed this Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request pose Pose/keypoint estimation models

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants