Creates a PoseTracker
Defaults:
Data source for pose (ie device)
Id of pose from TFjs
Returns how long since pose was updated
Returns the id of the sender of this pose
Returns the globally unique id of this pose (fromId-poseId)
Returns height of bounding box (normalised coordinates)
Returns a CSS colour: hsl() based on the randomly-assigned hue
Returns the randomly-assigned hue (0..360)
Returns the middle of the pose bounding box using normalised coordinates
pose.middle; // { x, y }
Returns the id of the sender
Returns the original pose id from TFjs Warning: this may not be unique if there are multiple senders
Return width of bounding box (normalised coordinates)
Gets the min/max Z range of all landmarks (normalised)
Gets the min/max Z range of all landmarks (world coordinates)
Gets the bounding box of the pose, computed using the normalised landmarks.
pose.box(); // { x, y, width, height }
Returns an empty rectangle if there's no data.
You can also provide a list of landmark names/indexes to compute the bounding box for just those:
// Get bounding box of torso
pose.box(`left_shoulder`, `right_shoulder`, `left_hip`, `right_`hip`);
See also {@link boxWorld} for same behaviour but using world coordinates.
Rest...namesOrIds: (number | PoseLandmarks)[]Rest...namesOrIds: (number | PoseLandmarks)[]Returns the 2D centroid of all the pose points (uses normalised landmarks)
pose.centroid(); // { x, y }
Or you can pass in the names/indexes of landmarks:
pose.centroid(`left_shoulder`, `right_shoulder`);
Returns { x: 0.5, y: 0.5 } is data is missing
Rest...namesOrIds: (number | PoseLandmarks)[]Returns landmarks in order of distance from the given point.
The point should be the same coordinates as poses.
Point to compare to
If true, Z coordinate is ignored.
Returns the closest landmark to point
If true only x,y coordinates are used for distance calculation
Gets the furtherest (by camera frame coords) of any of the listed landmarks
Eg get whichever wrist is the furtherest in the camera frame
pose.getFurtherest(`left_wrist`,`right_wrist`);
Rest...namesOrIds: (number | PoseLandmarks)[]Gets the highest (by camera frame coords) of any of the listed landmarks
Eg get whichever wrist is the highest in the camera frame
pose.getHighest(`left_wrist`,`right_wrist`);
Rest...namesOrIds: (number | PoseLandmarks)[]Gets the leftmost (by camera frame coords) of any of the listed landmarks
Eg get whichever wrist is the most left of the camera frame
pose.getLeftmost(`left_wrist`,`right_wrist`);
Rest...namesOrIds: (number | PoseLandmarks)[]Gets the lowest (by camera frame coords) of any of the listed landmarks
Eg get whichever wrist is the lowest in the camera frame
pose.getLowest(`left_wrist`,`right_wrist`);
Rest...namesOrIds: (number | PoseLandmarks)[]Gets the nearest (by camera frame coords) of any of the listed landmarks
Eg get whichever wrist is the nearest in the camera frame
pose.getNearest(`left_wrist`,`right_wrist`);
Rest...namesOrIds: (number | PoseLandmarks)[]Gets the rightmost (by camera frame coords) of any of the listed landmarks
Eg get whichever wrist is the most right of the camera frame
pose.getRightmost(`left_wrist`,`right_wrist`);
Rest...namesOrIds: (number | PoseLandmarks)[]Returns PointTrackers, sorted by their last X value
Rest...namesOrIds: (number | PoseLandmarks)[]Returns PointTrackers, sorted by their last Y value
Rest...namesOrIds: (number | PoseLandmarks)[]Returns PointTrackers, sorted by their last Z value
Rest...namesOrIds: (number | PoseLandmarks)[]Returns a PointTracker for a given normalised 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();
Returns the last position for a given landmark.
const pos = pose.landmarkValue(`nose`); // { x, y }
Throws an error if nameOrIndex does not exist.
Returns the raw landmarks
for (const kp of pose.landmarkValues()) {
// { x, y, z?, score, name }
}
Rest...namesOrIds: (number | PoseLandmarks)[]Returns all the PointTrackers (ie. landmark) for this pose.
for (const pt of pose.landmarks()) {
// Do something with 'pt' (which tracks one individual landmark)
}
Or provide a list of landmark indexes or name:
// Get landmarks for right arm
for (const pt of pose.landmarks(11, 13, 15)) {
}
Rest...namesOrIds: (number | PoseLandmarks)[]Update this pose with new information
Returns a PointTracker for a given normalised 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();
Returns the last position for a given landmark.
const pos = pose.landmarkValue(`nose`); // { x, y }
Throws an error if nameOrIndex does not exist.
Rest...namesOrIds: (number | PoseLandmarks)[]Rest...namesOrIds: (number | PoseLandmarks)[]
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.
Note: You probably don't want to create this yourself! Rather, use a PosesTracker to access.
Example
When creating, the most useful tuning options are
sampleLimitwhich governs how many of the most recent samples to keep, andstoreIntermediate(true/false) to store intermediate data.Accessing keypoints
You can get the raw keypoint data from the pose
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.
Once we have the PointTracker, there are a lot of things to access: