Post Processing
QuickPose provides both real-time and lag-free post processing of existing videos. Post processing is required when the features you want cannot be applied by the device in real time, for example 4k 240fps, or when lag of real time processing impacts the results say in high performance sports.
Lag-free 240fps video rendering
The post processor is easier to setup, as it doesn't require a camera input, a view for rendering output or requesting permissions (unless you are asking for access to the user's personal photo library).
First, initialise a QuickPosePostProcessor
. This matches interface to the main real-time QuickPose class, but accepts a QuickPosePostProcessor.Request
for any post processing specific inputs.
let quickPosePP = QuickPosePostProcessor(sdkKey: "YOUR SDK KEY HERE") // register for your free key at https://dev.quickpose.ai
Setup a QuickPosePostProcessor.Request
with your file details:
let request = QuickPosePostProcessor.Request(
input: Bundle.main.url(forResource: "tennis_240fps.mov", withExtension: nil)!,
output: FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent("tennis_240fps.mov"),
outputType: .mov)
Specify a set of features to perform:
let features: [QuickPose.Feature] = [.rangeOfMotion(.shoulder(side: .right, clockwiseDirection: true), style: QuickPose.Style(relativeFontSize: 0.5, relativeArcSize: 0.5, relativeLineWidth: 0.5))]
print("Processing \(request.input.lastPathComponent) -> \(request.output)")
do {
try quickPosePP.process(features: features, isFrontCamera: true, request: request) { progress, time, _, _, features, _, _ in
let fileProcessingProgress = Int(progress * 100)
if let feature = features.first {
print("\(fileProcessingProgress!)%, \(feature.key.displayString) \(feature.value.stringValue)")
} else {
print("\(fileProcessingProgress!)%")
}
}
} catch {
print("\(request.input.lastPathComponent): file could not be processed: \(error)")
}