posenet/demos/coco.js
function visualizeOutputs(
    partId, drawHeatmaps, drawOffsetVectors, drawDisplacements, ctx) {
  const {heatmapScores, offsets, displacementFwd, displacementBwd} =
      modelOutputs;
  const outputStride = +guiState.outputStride;

  const [height, width] = heatmapScores.shape;

  ctx.globalAlpha = 0;
  const heatmapScoresArr = heatmapScores.arraySync();
  const offsetsArr = offsets.arraySync();

  for (let y = 0; y < height; y++) {
    for (let x = 0; x < width; x++) {
      const score = heatmapScoresArr[y][x][partId];

      // to save on performance, don't draw anything with a low score.
      if (score < 0.05) continue;

      // set opacity of drawn elements based on the score
      ctx.globalAlpha = score;

      if (drawHeatmaps) {
        drawPoint(ctx, y * outputStride, x * outputStride, 2, 'yellow');
      }

      const offsetsVectorY = offsetsArr[y][x][partId];
      const offsetsVectorX = offsetsArr[y][x][partId + 17];

      if (drawOffsetVectors) {
        drawOffsetVector(
            ctx, y, x, outputStride, offsetsVectorY, offsetsVectorX);
      }

      if (drawDisplacements) {
        // exponentially affect the alpha of the displacements;
        ctx.globalAlpha *= score;

        drawDisplacementEdgesFrom(
            ctx, partId, displacementFwd, outputStride, parentToChildEdges, y,
            x, offsetsVectorY, offsetsVectorX);

        drawDisplacementEdgesFrom(
            ctx, partId, displacementBwd, outputStride, childToParentEdges, y,
            x, offsetsVectorY, offsetsVectorX);
      }
    }

    ctx.globalAlpha = 1;
  }
}
function visualizeOutputs(
    partId, drawHeatmaps, drawOffsetVectors, drawDisplacements, ctx) {
  const {heatmapScores, offsets, displacementFwd, displacementBwd} =
      modelOutputs;
  const outputStride = +guiState.outputStride;

  const [height, width] = heatmapScores.shape;

  ctx.globalAlpha = 0;
  const heatmapScoresArr = heatmapScores.arraySync();
  const offsetsArr = offsets.arraySync();

  for (let y = 0; y < height; y++) {
    for (let x = 0; x < width; x++) {
      const score = heatmapScoresArr[y][x][partId];

      // to save on performance, don't draw anything with a low score.
      if (score < 0.05) continue;

      // set opacity of drawn elements based on the score
      ctx.globalAlpha = score;

      if (drawHeatmaps) {
        drawPoint(ctx, y * outputStride, x * outputStride, 2, 'yellow');
      }

      const offsetsVectorY = offsetsArr[y][x][partId];
      const offsetsVectorX = offsetsArr[y][x][partId + 17];

      if (drawOffsetVectors) {
        drawOffsetVector(
            ctx, y, x, outputStride, offsetsVectorY, offsetsVectorX);
      }

      if (drawDisplacements) {
        // exponentially affect the alpha of the displacements;
        ctx.globalAlpha *= score;

        drawDisplacementEdgesFrom(
            ctx, partId, displacementFwd, outputStride, parentToChildEdges, y,
            x, offsetsVectorY, offsetsVectorX);

        drawDisplacementEdgesFrom(
            ctx, partId, displacementBwd, outputStride, childToParentEdges, y,
            x, offsetsVectorY, offsetsVectorX);
      }
    }

    ctx.globalAlpha = 1;
  }
}
function visualizeOutputs ( partId , drawHeatmaps , drawOffsetVectors , drawDisplacements , ctx ) { const { heatmapScores , offsets , displacementFwd , displacementBwd } = modelOutputs ; const outputStride = + guiState . outputStride ; const [ height , width ] = heatmapScores . shape ; ctx . globalAlpha = 0 ; const heatmapScoresArr = heatmapScores . arraySync ( ) ; const offsetsArr = offsets . arraySync ( ) ; for ( let y = 0 ; y < height ; y ++ ) { for ( let x = 0 ; x < width ; x ++ ) { const score = heatmapScoresArr [ y ] [ x ] [ partId ] ; // to save on performance, don't draw anything with a low score. if ( score < 0.05 ) continue ; // set opacity of drawn elements based on the score ctx . globalAlpha = score ; if ( drawHeatmaps ) { drawPoint ( ctx , y * outputStride , x * outputStride , 2 , 'yellow' ) ; } const offsetsVectorY = offsetsArr [ y ] [ x ] [ partId ] ; const offsetsVectorX = offsetsArr [ y ] [ x ] [ partId + 17 ] ; if ( drawOffsetVectors ) { drawOffsetVector ( ctx , y , x , outputStride , offsetsVectorY , offsetsVectorX ) ; } if ( drawDisplacements ) { // exponentially affect the alpha of the displacements; ctx . globalAlpha *= score ; drawDisplacementEdgesFrom ( ctx , partId , displacementFwd , outputStride , parentToChildEdges , y , x , offsetsVectorY , offsetsVectorX ) ; drawDisplacementEdgesFrom ( ctx , partId , displacementBwd , outputStride , childToParentEdges , y , x , offsetsVectorY , offsetsVectorX ) ; } } ctx . globalAlpha = 1 ; } }
Visualizes the outputs from the model which are used for decoding poses.
Limited to visualizing the outputs for a single part.

@param partId The id of the part to visualize
Visualizes the outputs from the model which are used for decoding poses . Limited to visualizing the outputs for a single part .