20220523_003_skeleton_sequencer/sketch.js
// A function to draw the body
A function to draw the body
A function to draw the body
function drawBody() {
  for (let i = 0; i < poses.length; i++) {
    let pose = poses[i].pose;
    let keypoint_ls = pose.keypoints[5];
    let keypoint_rs = pose.keypoints[6];
    let keypoint_lw = pose.keypoints[11];
    let keypoint_rw = pose.keypoints[12];
    if (keypoint_ls.score > 0.2 && keypoint_rs.score > 0.2
      && keypoint_lw.score > 0.2 && keypoint_rw.score > 0.2) {
      fill(255, 0, 0);
      noStroke();
      quad(
        keypoint_rs.position.x * scale_width,
        keypoint_rs.position.y * scale_height,
        keypoint_ls.position.x * scale_width,
        keypoint_ls.position.y * scale_height,
        keypoint_lw.position.x * scale_width,
        keypoint_lw.position.y * scale_height,
        keypoint_rw.position.x * scale_width,
        keypoint_rw.position.y * scale_height
      );
    }
  }
}
function drawBody ( ) { for ( let i = 0 ; i < poses . length ; i ++ ) { let pose = poses [ i ] . pose ; let keypoint_ls = pose . keypoints [ 5 ] ; let keypoint_rs = pose . keypoints [ 6 ] ; let keypoint_lw = pose . keypoints [ 11 ] ; let keypoint_rw = pose . keypoints [ 12 ] ; if ( keypoint_ls . score > 0.2 && keypoint_rs . score > 0.2 && keypoint_lw . score > 0.2 && keypoint_rw . score > 0.2 ) { fill ( 255 , 0 , 0 ) ; noStroke ( ) ; quad ( keypoint_rs . position . x * scale_width , keypoint_rs . position . y * scale_height , keypoint_ls . position . x * scale_width , keypoint_ls . position . y * scale_height , keypoint_lw . position . x * scale_width , keypoint_lw . position . y * scale_height , keypoint_rw . position . x * scale_width , keypoint_rw . position . y * scale_height ) ; } } }
A function to draw the body
A function to draw the body
// Loop through all the poses detected // A keypoint is an object describing a body part (head) // Only draw an ellipse is the pose probability is bigger than 0.2