Class PoseTracker

PoseTracker keeps track of a landmarks for a single pose. This is useful for tracking the movement of a pose or its landmarks over time. It does this by making a PointTracker for each keypoint of a pose.

// Create a tracker (fromId is the id of sender, poseId is the id of the pose)
const pt = new PoseTracker(fromId, poseId, options);
// ...and whenever there is data, call .seen()
pt.seen(pose);

When creating, the most useful tuning options are sampleLimit which governs how many of the most recent samples to keep, and storeIntermediate (true/false) to store intermediate data.

You can get the raw keypoint data from the pose

// Get a single point
const nosePoint = pose.keypointValue(`nose`); // { x, y, score, name }
// Get all points
for (const kp of poses.getRawValues()) {
// { x, y, score, name }
}

But the real power comes from getting the PointTracker for a keypoint, since it keeps track of not just the last data, but a whole trail of historical data for a given keypoint.

const noseTracker = pose.keypoint(`nose`); // PointTracker

Once we have the PointTracker, there are a lot of things to access:

Constructors

Properties

points: TrackedPointMap

Accessors

  • get box(): RectPositioned | Readonly<{
        height: 0;
        width: 0;
        x: 0;
        y: 0;
    }>
  • Gets the bounding box of the pose, computed by 'landmarks'.

    pose.box; // { x, y, width, height }
    

    Returns an empty rectangle if there's no data

    Returns RectPositioned | Readonly<{
        height: 0;
        width: 0;
        x: 0;
        y: 0;
    }>

  • get centroid(): Point
  • Returns the centroid of all the pose points

    pose.centroid; // { x, y }
    

    Returns {0.5,0.5} is data is missing

    Returns Point

  • get middle(): {
        x: number;
        y: number;
    }
  • Returns the middle of the pose bounding box

    pose.middle; // { x, y }
    

    Returns {
        x: number;
        y: number;
    }

    • x: number
    • y: number
  • get poseId(): string
  • Returns the original pose id from TFjs Warning: this may not be unique if there are multiple senders

    Returns string

Methods

  • Returns all the PointTrackers (ie. landmark) for this pose.

    for (const pt of pose.getPointTrackers()) {
    // Do something with 'pt' (which tracks one individual landmark)
    }

    Returns Generator<PointTracker, void, undefined>

  • Returns the raw landmarks

    for (const kp of pose.getRawValues()) {
    // { x, y, z?, score, name }
    }

    Returns Generator<TimestampedObject<Point>, void, unknown>

  • Returns a PointTracker for a given landmark by name or index.

    // Eg. get tracker for the 'nose' landmark
    const nose = pose.landmark(`nose`);

    // Get the angle of nose movement since the start
    const a = nose.angleFromStart();

    // Get the distance of nose since start
    const d = nose.distanceFromStart();

    Parameters

    Returns undefined | TrackerBase<Point, PointTrackerResults>

  • Returns the last position for a given landmark.

    const pos = pose.landmarkValue(`nose`); // { x, y }
    

    Throws an error if nameOrIndex does not exist.

    Parameters

    Returns Point