ml5js/ml5-next-gen

BodySegmentation errors when flipped option is set to true

Opened this issue · 0 comments

Issue Type

Broken API/Method

ml5.js Version

1.2.0 and 1.2.1

Development Environment

p5.js Web Editor

Browser & Operating System

Chrome 131.0.6778.108 on Windows 11

Issue Description

Screenshot 2024-12-04 231919

It is expected that the BodySegmentation starts outputting flipped masks without any error. However no masks predicted and the error in the above screenshot is produced.

Minimal Reproducible Example

// This is the same code from ml5 example sketch
// I just added flipped = true
let bodySegmentation;
let video;
let segmentation;

let options = {
  maskType: "person",
  flipped: true
};

function preload() {
  bodySegmentation = ml5.bodySegmentation("SelfieSegmentation", options);
}

function setup() {
  createCanvas(640, 480);
  // Create the video
  video = createCapture(VIDEO);
  video.size(640, 480);
  video.hide();

  bodySegmentation.detectStart(video, gotResults);
}

function draw() {
  background(0, 255, 0);

  if (segmentation) {
    video.mask(segmentation.mask);
    image(video, 0, 0);
  }
}

// callback function for body segmentation
function gotResults(result) {
  segmentation = result;
}

Thank you @demizhou8 for surfacing this bug!

Code of Conduct

  • I agree to follow this project's Code of Conduct