browser_client/examples/example4_posenet_curves_simple/sketch.js
// Draw a curved shape with the posenet points
Draw a curved shape with the posenet points
Draw a curved shape with the posenet points
function drawCurvedBody(pose, clr) {
  if (pose.length === 0) return;
  fill(clr);
  stroke(clr);
  beginShape();
  for (let i = 0; i < pose.length + 3; i++) {
    let index = i;
    if (i >= pose.length) {
      index = i % pose.length;
    }
    curveVertex(pose[index].position.x, pose[index].position.y);
  }
  endShape();
}
function drawCurvedBody ( pose , clr ) { if ( pose . length === 0 ) return ; fill ( clr ) ; stroke ( clr ) ; beginShape ( ) ; for ( let i = 0 ; i < pose . length + 3 ; i ++ ) { let index = i ; if ( i >= pose . length ) { index = i % pose . length ; } curveVertex ( pose [ index ] . position . x , pose [ index ] . position . y ) ; } endShape ( ) ; }
Draw a curved shape with the posenet points
Draw a curved shape with the posenet points
// Make sure we have points in the pose array // Use the given color to draw the pose // Begin drawing the shape // See p5 reference https://p5js.org/reference/#/p5/beginShape // Go through all of the keypoints in the array // Add 3 extra points to complete the curved shaped // Get the index // If the index is beyond the length of the array // Use modulo to iterate through the additional points needed to complete the curve // Add the curve vertex to the shape // Close and draw the shape