首页 > 解决方案 > ml5 问题。不要以角度反映 ml5 uNet

问题描述

我尝试以角度应用uNet。我已经完成了打开我的摄像头。

但不要应用 uNet .. 只是凸轮视图

所以我猜这个问题。result.backgroundMask = 未定义

为什么 result.backgroundMask 未定义。我不知道...

请回答..

private createCanvas() {
    this.p5 = new p5(this.sketch.bind(this));
  }

  private sketch(p: any) {
    p.setup = () => {
      p.createCanvas(600, 600).parent('bodyPix-canvas');

      this.video = p.createCapture(p.VIDEO);
      this.video = this.video.position(0, 0);
      this.video.size(p.width, p.height);
      this.video.hide();
      this.segmentationImage = p.createImage(p.width, p.height);
      this.video.elt.onloadeddata = () => {
        this.uNet.segment(this.video, this.gotResult.bind(this));
      };
    };
  }

  gotResult(error, result) {
    // if there's an error return it
    if (error) {
      console.error(error);
      return;
    }
    // set the result to the global segmentation variable
    this.segmentationImage = result.image ? result.image : this.video;
    this.draw();
    // Continue asking for a segmentation image
    this.uNet.segment(this.video, this.gotResult.bind(this));
  }

  draw() {
    this.p5.background(0);
    this.p5.image(this.segmentationImage, 0, 0, this.p5.width, this.p5.height);
  }

标签: angulartypescriptp5.jsml5

解决方案


推荐阅读