Created
June 30, 2019 03:26
-
-
Save mariotacke/deadf22ce0dda920f8a7cbd8e93bbf16 to your computer and use it in GitHub Desktop.
Revisions
-
mariotacke created this gist
Jun 30, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ 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); };