Created
June 30, 2019 03:26
-
-
Save mariotacke/deadf22ce0dda920f8a7cbd8e93bbf16 to your computer and use it in GitHub Desktop.
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 characters
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