Skip to content

Instantly share code, notes, and snippets.

@nataliefreed
Created January 23, 2017 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nataliefreed/4b958ba0a840a2ba827097ce8b7b98b3 to your computer and use it in GitHub Desktop.
Save nataliefreed/4b958ba0a840a2ba827097ce8b7b98b3 to your computer and use it in GitHub Desktop.
//Modified from P5 example at: https://p5js.org/examples/dom-video-capture.html
var capture;
function setup() {
createCanvas(320, 240);
capture = createCapture(VIDEO);
capture.size(320, 240);
capture.hide();
}
function draw() {
image(capture, 0, 0, 320, 240);
loadPixels();
for(var i=0;i<pixels.length;i+=4) {
if(pixels[i] > 200) { //if amount of red in a pixel is high enough, add yellow highlights
pixels[i] = 255; //red
pixels[i+1] = 255; //green
pixels[i+2] = 0; //blue
};
}
updatePixels();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment