Class

ARBodyAnchor

An object that tracks the movement in 3D space of a body that ARKit recognizes in the camera feed.

Declaration

@interface ARBodyAnchor : ARAnchor

Overview

This ARAnchor subclass tracks the movement of a single person. You enable body tracking by running your session using ARBodyTrackingConfiguration.

When ARKit recognizes a person in the back camera feed, it calls your delegate's session:didAddAnchors: function with ARBodyAnchor. A body anchor's transform position defines the world position of the body's hip joint.

You can also check within the frame's anchors for a body that ARKit is tracking.

Place a Skeleton on a Surface

Because a body anchor's origin maps to the hip joint, you calculate the current offset of the feet to the hip to place the body's skeleton on a surface. By passing the foot joint index to jointModelTransforms, you get the foot's offset from skeleton's origin.

static var hipToFootOffset: Float {
    // Get an index for a foot. 
    let footIndex = ARSkeletonDefinition.defaultBody3D.index(forJointName: .leftFoot)
    // Get the foot's world-space offset from the hip. 
    let footTransform = ARSkeletonDefinition.defaultBody3D.neutralBodySkeleton3D!.jointModelTransforms[footIndex]
    // Return the height by getting just the y-value. 
    let distanceFromHipOnY = abs(footTransform.columns.3.y) 
    return distanceFromHipOnY
}

Topics

Interpreting 3D Motion

skeleton

The tracked body in 3D.

ARSkeleton3D

The skeleton of a human body that ARKit tracks in 3D space.

ARSkeleton

The interface for the skeleton of a tracked body.

Getting Screen Position

ARBody2D

The screen-space representation of a person ARKit recognizes in the camera feed.

Getting Scale Information

estimatedScaleFactor

A factor that relates the body's default height with the height ARKit estimates at runtime.

Relationships

Inherits From

Conforms To

See Also

People

Capturing Body Motion in 3D

Track a person in the physical environment and visualize their motion by applying the same body movements to a virtual puppet.

ARBodyTrackingConfiguration

A configuration you use to track a person's motion in 3D space.

Beta
ARBody2D

The screen-space representation of a person ARKit recognizes in the camera feed.

Beta

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software