Git Product home page Git Product logo

glaphi / fork-quickpose-ios-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from quickpose/quickpose-ios-sdk

0.0 0.0 0.0 205.6 MB

Quickly add MediaPipe Pose Estimation and Detection to your iOS app. Enable powerful features in your app powered by the body or hand.

Home Page: https://quickpose.github.io/quickpose-ios-sdk/

License: Apache License 2.0

C 1.69% Objective-C 42.99% Swift 55.32%

fork-quickpose-ios-sdk's Introduction

quickpose-ios-sdk

Swift Package Manager

QuickPose provides developer-oriented cutting edge ML features of MediaPipe and BlazePose, with easy integration and production ready code. Dramatically improving the speed of implementation of MediaPipe and BlazePose's pose estimation and skeleton tracking features into mobile applications.

Register an SDK Key

Get your free SDK key on https://dev.quickpose.ai, usage limits may apply. SDK Keys are linked to your bundle ID, please check Key before distributing to the App Store.

How it works

QuickPose process a video frame and makes it easy for developers to perform complex AI features to the image, such as overlaying markings to the output image to highlight the user's pose.

+----------+          +-------------+          +-----------------+
|          |          |             |          |  Overlay Image  |
|  Camera  |--------->|  QuickPose  |--------->|        +        |
|          |          |             |          |     Results     |
+----------+          +-------------+          +-----------------+

Features

Feature Example Supported
MediaPipe Landmarks MediaPipe Landmarks v0.1

Overlays

Whole Body

Upper Body

Lower Body

Shoulder

Left Arm

Right Arm

Left Leg

Right Leg

Whole Body Overlay Upper Body Overlay Lower Body Overlay Shoulders Overlay Left Leg Overlay Right Leg Overlay v0.1

Health - Range Of Motion

Left Shoulder

Right Shoulder

Left Hip

Right Hip

Left Knee

Right Knee

Back

Neck

health-shoulder-right-rom health-shoulder-rom health-hip-rom health-knee-rom health-back-rom health-neck-rom v0.3

Fitness - Exercise Detection & Counter

Squat

Sumo Squat

Jumping Jack

Push Up

Plank

Cobra Wings

Left Leg Lunge

Right Leg Lunge

fitness-pushup fitness-plank fitness-cobra-wings fitness-left-leg-lunges fitness-squats fitness-sumo-squats fitness-jumping-jacks v0.8

Input

Raised Finger Detection & Count

finger-counter-left finger-counter-right v0.5

Input

Thumbs Up Detection, Thumbs up and down detection

thumbs-up thumbs-up-and-down v0.6

Meta Features

Feature Example Supported
Stacked Feature Styling shoulder-conditional-image
Bike Side View Video by Tariq Ali
v0.4
Conditional Styling knee-conditional-image shoulder-conditional-image v0.4

Fitness - Guidance

Body Position

Named Leg or Arm not visible

fitness-body-guidance fitness-arm-guidance fitness-leg-guidance v0.8

Supported Platforms

iOS Device Silicon Mac (M1, M2, etc) iOS Simulator x86_64 iOS Simulator arm64
✅ Runs ✅ Runs ⚙ Compiles ⚙ Known Issue

Requirements

  • iOS 14.0+
  • Xcode 10.0+

Installing the SDK

Swift Package Manager

Step 1: Click on Xcode project file

Step 2: Click on Swift Packages and click on the plus to add a package

Step 3: Enter the following repository url https://github.com/quickpose/quickpose-ios-sdk.git and click next

Import Package

Step 4: Choose all modules and click add package.

Module Description
QuickPoseCore Core SDK (required)
QuickPoseMP Mediapipe Library (required)
QuickPoseCamera Utility Class for Integration (optional, recommended)
QuickPoseSwiftUI Utility Classes for SwiftUI Integration (optional, recommended)

Getting Started

See code examples below or download our Sample Apps.

Getting Started with Newer Macs M1/M2

Step 1: Download/Clone Repo

Step 2: Open Basic Demo

Step 3: Choose Build Target "My Mac (Designed For iPad/iPhone)"

Step 4: Run

Getting Started With Mac Picture

Step 5: Explore the features and returned results

quickPose.start(features: [.overlay(.upperBody)], onFrame: { status, image, features, guidance, landmarks in
    if case .success(_) = status {
        overlayImage = image
    }
})

Getting Started with Older Intel Macs

Step 1: Download/Clone Repo

Step 2: Open Basic Demo

Step 3: Choose Build Target as your physical device

Step 5: You will need to change the bundleid and register with apple if you haven't already.

Step 5: Run

Step 6: Explore the features and returned results

quickPose.start(features: [.overlay(.upperBody)], onFrame: { status, image, features,  guidance, landmarks in
    if case .success(_) = status {
        overlayImage = image
    }
})

Integrating into SwiftUI App

For reference docs see https://quickpose.github.io/quickpose-ios-sdk

Device Camera only

import SwiftUI
import QuickPoseCore
import QuickPoseSwiftUI

....

struct QuickPoseBasicView: View {
    
    private var quickPose = QuickPose(sdkKey: "YOUR SDK KEY HERE") // register for your free key at https://dev.quickpose.ai
    @State private var overlayImage: UIImage?
    
    var body: some View {
        GeometryReader { geometry in
            ZStack(alignment: .top) {
                QuickPoseCameraView(useFrontCamera: true, delegate: quickPose)
                QuickPoseOverlayView(overlayImage: $overlayImage)
            }
            .frame(width: geometry.size.width)
            .edgesIgnoringSafeArea(.all)
            .onAppear {
                quickPose.start(features: [.overlay(.userLeftArm)], onFrame: { status, image, features,  guidance, landmarks in
                    if case .success(_) = status {
                        overlayImage = image
                    }
                })
            }.onDisappear {
                quickPose.stop()
            }
            
        }
    }
}

Device Camera and Running Video on Mac (Recommended)

import SwiftUI
import QuickPoseCore
import QuickPoseSwiftUI
...
struct QuickPoseBasicView: View {

    private var quickPose = QuickPose(sdkKey: "YOUR SDK KEY HERE") // register for your free key at https://dev.quickpose.ai
    @State private var overlayImage: UIImage?
    
    var body: some View {
        GeometryReader { geometry in
            ZStack(alignment: .top) {
                if ProcessInfo.processInfo.isiOSAppOnMac, let url = Bundle.main.url(forResource: "happy-dance", withExtension: "mov") {
                    QuickPoseSimulatedCameraView(useFrontCamera: true, delegate: quickPose, video: url)
                } else {
                    QuickPoseCameraView(useFrontCamera: true, delegate: quickPose)
                }
                QuickPoseOverlayView(overlayImage: $overlayImage)
            }
            .frame(width: geometry.size.width)
            .edgesIgnoringSafeArea(.all)
            .onAppear {
                quickPose.start(features: [.overlay(.upperBody)], onFrame: { status, image, features,  guidance, landmarks in
                    if case .success(_) = status {
                        overlayImage = image
                    }
                })
            }.onDisappear {
                quickPose.stop()
            }
            
        }
    }

Integrating into UIKit App

Device Camera only

import QuickPoseCore
import QuickPoseCamera
...

class ViewController: UIViewController {
    
    var camera: QuickPoseCamera?
    var quickPose = QuickPose(sdkKey: "YOUR SDK KEY HERE") // register for your free key at https://dev.quickpose.ai
    
    @IBOutlet var cameraView: UIView!
    @IBOutlet var overlayView: UIImageView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // setup camera
        camera = QuickPoseCamera(useFrontCamera: true)
        try? camera?.start(delegate: quickPose)
        
        let customPreviewLayer = AVCaptureVideoPreviewLayer(session: camera!.session!)
        customPreviewLayer.videoGravity = .resizeAspectFill
        customPreviewLayer.frame.size = view.frame.size
        cameraView.layer.addSublayer(customPreviewLayer)
        
        // setup overlay
        overlayView.contentMode = .scaleAspectFill // keep overlays in same scale as camera output
        overlayView.frame.size = view.frame.size
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        
        quickPose.start(features: [.overlay(.userLeftArm)], onFrame: { status, image, features, guidance, landmarks in
            if case .success(_) = status {
                DispatchQueue.main.async {
                    self.overlayView.image = image
                }
            }
        })
    }
    
    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        camera?.stop()
        quickPose.stop()
    }
}

Device Camera and Running Video on Mac (Recommended)

import QuickPoseCore
import QuickPoseCamera
...
class ViewController: UIViewController {
    
    var camera: QuickPoseCamera?
    var simulatedCamera: QuickPoseSimulatedCamera?
    var quickPose = QuickPose(sdkKey: "YOUR SDK KEY HERE") // register for your free key at https://dev.quickpose.ai
    
    @IBOutlet var cameraView: UIView!
    @IBOutlet var overlayView: UIImageView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        if ProcessInfo.processInfo.isiOSAppOnMac, let url = Bundle.main.url(forResource: "happy-dance", withExtension: "mov") {
            simulatedCamera = QuickPoseSimulatedCamera(useFrontCamera: true, asset: AVAsset(url: url)) // setup simulated camera
            try? simulatedCamera?.start(delegate: quickPose)
            
            let customPreviewLayer = AVPlayerLayer(player: simulatedCamera?.player)
            customPreviewLayer.videoGravity = .resizeAspectFill
            customPreviewLayer.frame.size = view.frame.size
            cameraView.layer.addSublayer(customPreviewLayer)
        } else {
            camera = QuickPoseCamera(useFrontCamera: true) // setup camera
            try? camera?.start(delegate: quickPose)
            
            let customPreviewLayer = AVCaptureVideoPreviewLayer(session: camera!.session!)
            customPreviewLayer.videoGravity = .resizeAspectFill
            customPreviewLayer.frame.size = view.frame.size
            cameraView.layer.addSublayer(customPreviewLayer)
        }
        
        
        // setup overlay
        overlayView.contentMode = .scaleAspectFill // keep overlays in same scale as camera output
        overlayView.frame.size = view.frame.size
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        
        quickPose.start(features: [.overlay(.upperBody)], onFrame: { status, image, features,  guidance, landmarks in
            if case .success(_) = status {
                DispatchQueue.main.async {
                    self.overlayView.image = image
                }
            }
        })
    }
    
    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        camera?.stop()
        simulatedCamera?.stop()
        quickPose.stop()
    }
}

Troubleshooting

No Such Module

Xcode reports error no such module QuickPoseCore or no such module QuickPoseSwiftUI

This happens when the linker cannot find the provided XCFrameworks. These needs to be added to your build Target.

xcode troubleshooting no such module error

xcode troubleshooting no such module guide

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.