Skip to content

Commit 30ad0fa

Browse files
committed
improving docs for 0.2
1 parent 5aa0889 commit 30ad0fa

File tree

8 files changed

+210
-215
lines changed

8 files changed

+210
-215
lines changed

README.md

Lines changed: 157 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![License](https://img.shields.io/github/license/quickpose/quickpose-ios-sdk)](https://raw.githubusercontent.com/quickpose/quickpose-ios-sdk/main/LICENSE)
55
[![Swift Package Manager](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)
66

7-
QuickPose provides developer-oriented cutting edge ML features of MediaPipe and BlazePose. with easy integration, production ready code. Dramatically improving the speed of implementation of MediaPipe and BlazePose into mobile applications.
7+
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.
88

99
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
1010
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
@@ -23,6 +23,19 @@ QuickPose provides developer-oriented cutting edge ML features of MediaPipe and
2323
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
2424

2525

26+
How it works
27+
------------------
28+
29+
QuickPose process's a camera's or video's output frame and make 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.
30+
31+
```swift
32+
+----------+ +-------------+ +-----------------+
33+
| | | | | Overlay Image |
34+
| Camera |--------->| QuickPose |--------->| + |
35+
| | | | | Results |
36+
+----------+ +-------------+ +-----------------+
37+
```
38+
2639
Features
2740
------------------
2841

@@ -72,8 +85,53 @@ Getting Started
7285

7386
See code examples below or download our [Sample Apps](/SampleApps).
7487

88+
### Getting Started with Newer Macs M1/M2
89+
90+
__Step 1__: Download/Clone Repo
91+
92+
__Step 2__: Open Basic Demo
93+
94+
__Step 3__: Choose Build Target "My Mac (Designed For iPad/iPhone)"
95+
96+
__Step 4__: Run
97+
98+
![Getting Started With Mac Picture](docs/img/silicon-mac-get-started-upperbody.png)
99+
100+
__Step 5__: Explore the features and returned results
101+
102+
```swift
103+
quickPose.start(features: [.overlay(.upperBody)], onFrame: { status, image, features, landmarks in
104+
if case .success(_) = status {
105+
overlayImage = image
106+
}
107+
})
108+
```
109+
110+
### Getting Started with Older Intel Macs
111+
112+
__Step 1__: Download/Clone Repo
113+
114+
__Step 2__: Open Basic Demo
115+
116+
__Step 3__: Choose Build Target as your physical device
117+
118+
__Step 5__: You will need to change the bundleid and register with apple if you haven't already.
119+
120+
__Step 5__: Run
121+
122+
__Step 6__: Explore the features and returned results
123+
124+
```swift
125+
quickPose.start(features: [.overlay(.upperBody)], onFrame: { status, image, features, landmarks in
126+
if case .success(_) = status {
127+
overlayImage = image
128+
}
129+
})
130+
```
131+
75132
### Integrating into SwiftUI App
76133

134+
#### Device Camera only
77135
```swift
78136
import SwiftUI
79137
import QuickPoseCore
@@ -107,12 +165,46 @@ struct QuickPoseBasicView: View {
107165
}
108166
}
109167
}
110-
111-
112168
```
169+
#### Device Camera and Running Video on Mac (Recommended)
170+
```swift
171+
import SwiftUI
172+
import QuickPoseCore
173+
import QuickPoseSwiftUI
174+
...
175+
struct QuickPoseBasicView: View {
113176

177+
private var quickPose = QuickPose()
178+
@State private var overlayImage: UIImage?
179+
180+
var body: some View {
181+
GeometryReader { geometry in
182+
ZStack(alignment: .top) {
183+
if ProcessInfo.processInfo.isiOSAppOnMac, let url = Bundle.main.url(forResource: "happy-dance", withExtension: "mov") {
184+
QuickPoseSimulatedCameraView(useFrontCamera: true, delegate: quickPose, video: url)
185+
} else {
186+
QuickPoseCameraView(useFrontCamera: true, delegate: quickPose)
187+
}
188+
QuickPoseOverlayView(overlayImage: $overlayImage)
189+
}
190+
.frame(width: geometry.size.width)
191+
.edgesIgnoringSafeArea(.all)
192+
.onAppear {
193+
quickPose.start(features: [.overlay(.upperBody)], onFrame: { status, image, features, landmarks in
194+
if case .success(_) = status {
195+
overlayImage = image
196+
}
197+
})
198+
}.onDisappear {
199+
quickPose.stop()
200+
}
201+
202+
}
203+
}
204+
```
114205
### Integrating into UIKit App
115206

207+
#### Device Camera only
116208
```swift
117209
import QuickPoseCore
118210
import QuickPoseCamera
@@ -162,6 +254,68 @@ class ViewController: UIViewController {
162254
}
163255
}
164256
```
257+
#### Device Camera and Running Video on Mac (Recommended)
258+
```swift
259+
import QuickPoseCore
260+
import QuickPoseCamera
261+
...
262+
class ViewController: UIViewController {
263+
264+
var camera: QuickPoseCamera?
265+
var simulatedCamera: QuickPoseSimulatedCamera?
266+
var quickPose = QuickPose()
267+
268+
@IBOutlet var cameraView: UIView!
269+
@IBOutlet var overlayView: UIImageView!
270+
271+
override func viewDidLoad() {
272+
super.viewDidLoad()
273+
274+
if ProcessInfo.processInfo.isiOSAppOnMac, let url = Bundle.main.url(forResource: "happy-dance", withExtension: "mov") {
275+
simulatedCamera = QuickPoseSimulatedCamera(useFrontCamera: true, asset: AVAsset(url: url)) // setup simulated camera
276+
try? simulatedCamera?.start(delegate: quickPose)
277+
278+
let customPreviewLayer = AVPlayerLayer(player: simulatedCamera?.player)
279+
customPreviewLayer.videoGravity = .resizeAspectFill
280+
customPreviewLayer.frame.size = view.frame.size
281+
cameraView.layer.addSublayer(customPreviewLayer)
282+
} else {
283+
camera = QuickPoseCamera(useFrontCamera: true) // setup camera
284+
try? camera?.start(delegate: quickPose)
285+
286+
let customPreviewLayer = AVCaptureVideoPreviewLayer(session: camera!.session!)
287+
customPreviewLayer.videoGravity = .resizeAspectFill
288+
customPreviewLayer.frame.size = view.frame.size
289+
cameraView.layer.addSublayer(customPreviewLayer)
290+
}
291+
292+
293+
// setup overlay
294+
overlayView.contentMode = .scaleAspectFill // keep overlays in same scale as camera output
295+
overlayView.frame.size = view.frame.size
296+
}
297+
298+
override func viewDidAppear(_ animated: Bool) {
299+
super.viewDidAppear(animated)
300+
301+
quickPose.start(features: [.overlay(.upperBody)], onFrame: { status, image, features, landmarks in
302+
if case .success(_) = status {
303+
DispatchQueue.main.async {
304+
self.overlayView.image = image
305+
}
306+
}
307+
})
308+
}
309+
310+
override func viewDidDisappear(_ animated: Bool) {
311+
super.viewDidDisappear(animated)
312+
camera?.stop()
313+
simulatedCamera?.stop()
314+
quickPose.stop()
315+
}
316+
}
317+
318+
```
165319

166320

167321
Troubleshooting

SampleApps/SwiftUI/BasicDemo/QuickPose Demo/QuickPoseBasicView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct QuickPoseBasicView: View {
3434
.edgesIgnoringSafeArea(.all)
3535

3636
.onAppear {
37-
quickPose.start(features: [.overlay(.userLeftArm)], onFrame: { status, image, features, landmarks in
37+
quickPose.start(features: [.overlay(.upperBody)], onFrame: { status, image, features, landmarks in
3838
if case .success(_) = status {
3939
overlayImage = image
4040
}

SampleApps/SwiftUI/BasicDemo/QuickPose Demo/QuickPoseCamera.swift

Lines changed: 0 additions & 90 deletions
This file was deleted.

SampleApps/SwiftUI/PickerDemo/QuickPose Demo/QuickPoseCamera.swift

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)