Skip to main content

UIKit

Basic integration

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(.arm(side: .left))], onFrame: { status, image, features, feedback, 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()
}
}```