Page Summary
-
The
PoseDetectorclass enables body-pose estimation within images. -
It provides methods for asynchronous and synchronous pose detection.
-
You can configure the pose detector using
MLKCommonPoseDetectorOptions. -
Results include an array of
MLKPoseobjects representing detected poses. -
Avoid calling
results(in:)on the main thread to prevent UI blocking.
PoseDetector
class PoseDetector : NSObjectA detector for performing body-pose estimation.
-
Returns a pose detector with the given options.
Declaration
Swift
class func poseDetector(options: MLKCommonPoseDetectorOptions) -> SelfParameters
optionsOptions for configuring the pose detector.
Return Value
A pose detector configured with the given options.
-
Unavailable. Use the class methods.
-
Processes the given image for pose detection.
Declaration
Swift
func process(_ image: MLKitCompatibleImage) async throws -> [MLKPose]Parameters
imageThe image to process.
completionHandler to call back on the main thread with pose detected or error.
-
Returns the pose results in the given image. The pose detection is performed synchronously on the calling thread.
It is advised to call this method off the main thread to avoid blocking the UI. As a result, an
NSExceptionis raised if this method is called on the main thread.Declaration
Swift
func results(in image: MLKitCompatibleImage) throws -> [MLKPose]Parameters
imageThe image to get results in.
errorAn optional error parameter populated when there is an error getting results.
Return Value
The array of poses detected in the given image or
nilif there was an error. If no poses are detected, then an empty array will be returned.