Home > Blockchain >  Javascript Video Capture
Javascript Video Capture

Time:09-27

I have the following code. It displays filter video at top and original video at bottom.

How to hide the video at the top?

Thanks

// https://editor.p5js.org/

function setup() {
   createCanvas(320, 260);
   video = createCapture(VIDEO);
   video.size(width,height);
 }
 let video;
 function draw() {
 image(video,0,0,width,height);
 // filter(THRESHOLD); 
//  filter(GRAY);
filter(INVERT);
}

CodePudding user response:

On the documenation page, it says to do video.hide() to hide the webcam capture.

And if you don't want the filter, then don't call filter(...)

So your code will look like this:

let video;

function setup() {
  createCanvas(320, 260);
  video = createCapture(VIDEO);
  video.size(width, height);
  video.hide();
}

function draw() {
  image(video,0,0,width,height);
  // rest of code
}

If you ever want to reshow the original video, just run video.show().

  • Related