| 168 | } |
| 169 | |
| 170 | function drawSkeleton( |
| 171 | keypoints: Keypoint[], skeletonAdjacentPairs: number[][], |
| 172 | ctx: CanvasRenderingContext2D, color: string) { |
| 173 | ctx.fillStyle = color; |
| 174 | ctx.strokeStyle = color; |
| 175 | ctx.lineWidth = 2; |
| 176 | |
| 177 | for (const pair of skeletonAdjacentPairs) { |
| 178 | const [i, j] = pair; |
| 179 | const kp1 = keypoints[i]; |
| 180 | const kp2 = keypoints[j]; |
| 181 | |
| 182 | ctx.beginPath(); |
| 183 | ctx.moveTo(kp1.x, kp1.y); |
| 184 | ctx.lineTo(kp2.x, kp2.y); |
| 185 | ctx.stroke(); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | function draw( |
| 190 | keypoints: Keypoint[], ctx: CanvasRenderingContext2D, |