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.
Optional
options: 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
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 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
Returns all PointTrackers from a particular sender
for (const pt of poses.getFromSender(`mobile`)) {
// Do something with tracker...
}
Id of sender
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.
Name or index of landmark to get tracker for
Get a raw landmark by name across all poses
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
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: