Skip to content

Instantly share code, notes, and snippets.

@mariotacke
Created June 30, 2019 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariotacke/deadf22ce0dda920f8a7cbd8e93bbf16 to your computer and use it in GitHub Desktop.
Save mariotacke/deadf22ce0dda920f8a7cbd8e93bbf16 to your computer and use it in GitHub Desktop.
const video = document.querySelector('#camera-stream');
const hiddenCanvas = document.querySelector('#hidden-canvas');
const outputCanvas = document.querySelector('#output-canvas');
const hiddenContext = hiddenCanvas.getContext('2d');
const outputContext = outputCanvas.getContext('2d');
const processFrame = () => {
const { videoWidth: width, videoHeight: height } = video;
if (width && height) {
hiddenCanvas.width = width;
hiddenCanvas.height = height;
outputCanvas.width = width;
outputCanvas.height = height;
hiddenContext.drawImage(video, 0, 0, width, height);
// get frame from hiddenContext
// apply filter
// draw outputContext
}
window.requestAnimationFrame(processFrame);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment