Constructor
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.
Optionaloptions: boolean | AddEventListenerOptionsEnumerate all PoseTracker instances
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
Enumerates PoseTrackers, sorting by the average Z value. Closest pose will be at position 0.
Returns poses in order of distance (as judged by their centroid property) from the given point. Since centroid is 2D, distance is also calculated using x,y only.
The point should be the same coordinates as poses.
Point to compare to
Get the PoseTracker for unique id (based on sender and pose)
const pt = poses.getByGuid(`123-123`);
pt.middle; // { x, y }
Alternatively: getRawPoseByGuid to get raw data
Combined id of sender-poseid
Enumerates PoseTrackers, sorting by the horizontal middle position. Leftmost pose will be at position 0.
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.
Id of pose
Enumerates PoseTrackers, sorting by the vertical middle position. Highest pose will be at position 0.
Returns the closest pose to point, as judged by its centroid property
Returns all PointTrackers from a particular sender
for (const pt of poses.getFromSender(`mobile`)) {
// Do something with tracker...
}
Id of sender
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
Combined sender-pose
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.
Id of pose
Get a raw landmark by name across all poses
Rest...namesOrIds: (number | PoseLandmarks)[]Enumerates all PointTrackers for a given landmark id.
// Return all landmarks for all poses
for (const pt of poses.landmarks()) {
}
eg. to get the PointTracker for 'nose' across all poses currently seen:
for (const pt of poses.landmarks(`nose`)) {
// do something with tracker...
}
Rest...namesOrIds: (number | PoseLandmarks)[]List of indexes or landmark names to filter by
Track a pose.
Fires added event if it is a new pose.
Returns the globally-unique id for this pose
Sender id
New pose data
Tracks several poses (ie. bodies)
Events: