Class PosesTracker

Tracks several poses (ie. bodies)

Events:

  • expired: Tracked pose has not been seen for a while
  • added: A new pose id

Hierarchy

  • EventTarget
    • PosesTracker

Constructors

Accessors

Methods

  • Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.

    The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.

    When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.

    When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in ยง 2.8 Observing event listeners.

    When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.

    If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.

    The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.

    MDN Reference

    Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optionaloptions: boolean | AddEventListenerOptions

    Returns void

  • Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.

    MDN Reference

    Parameters

    • event: Event

    Returns boolean

  • Enumerates each of the PoseTrackers, sorted by age. The most recent pose will be at position 0. (ie. one for each body). Use getRawPosesByAge() to enumerate raw pose data

    Returns Generator<PoseTracker, void, undefined>

  • Returns the PoseTracker for this pose id.

    const pose = poses.getByPoseId(`123`);
    pose.middle; // { x, y }

    Warning: Pose ids are not unique if there are multiple data sources. Prefer using guids.

    Parameters

    • id: string

      Id of pose

    Returns undefined | PoseTracker

  • Enumerates all PointTrackers for a given landmark id.

    eg. to get the PointTracker for 'nose' across all poses currently seen:

    for (const pt of poses.getPointTrackers(`nose`)) {
    // do something with tracker...
    }

    Throws an error if nameOrIndex is not found.

    Parameters

    • nameOrIndex: number | PoseLandmarks

      Name or index of landmark to get tracker for

    Returns Generator<undefined | TrackerBase<Point, PointTrackerResults>, void, unknown>

  • Get a raw landmark by name across all poses

    Parameters

    • nameOrIndex: string | number

    Returns Generator<NormalizedLandmark, void, unknown>

    for (const n of poses.getRawLandmarks(`nose`)) {
    // Yields: { x, y, z?, score, name }
    }
    ```

  • Returns the raw pose data for a unique id

    const pose = poses.getRawPoseByGuide(`123-123`);
    pose.landmark; // array of { x, y, z?, score, name }
    pose.score; // score of pose

    Alternatively: getByGuid to get a tracker for pose

    Parameters

    • id: string

      Combined sender-pose

    Returns undefined | PoseData

  • Returns the last raw pose data for this pose id.

    const pose = poses.getRawPoseByPoseId(`123`);
    pose.landmark; // array of landmarks { x, y, z?, score, name }
    pose.score; // score of this pose
    pose.box; // bounding box

    Warning: Pose ids are not unique if there are multiple data sources. Prefer using guids.

    Parameters

    • id: string

      Id of pose

    Returns undefined | PoseData

  • Enumerate the set of unique sender ids

    for (const sender of poses.getSenderIds()) {
    // Do something with sender (string)
    }

    Returns Generator<unknown, void, undefined>

  • Removes the event listener in target's event listener list with the same type, callback, and options.

    MDN Reference

    Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optionaloptions: boolean | EventListenerOptions

    Returns void

  • Track a pose. Fires added event if it is a new pose. Returns the globally-unique id for this pose

    Parameters

    • from: string

      Sender id

    • pose: PoseData

      New pose data

    Returns string