Skip to content

Instantly share code, notes, and snippets.

@iha2
Last active August 12, 2018 22:04
Show Gist options
  • Save iha2/74368c222ca8b4e72b7732fa898936d0 to your computer and use it in GitHub Desktop.
Save iha2/74368c222ca8b4e72b7732fa898936d0 to your computer and use it in GitHub Desktop.
An implementation of a webcam processed by an observable.
export function initializeWebcam(
videoElem: HTMLVideoElement,
canvasElement: HTMLCanvasElement
) {
return createWebcam(videoElem).pipe(
switchMap(_ =>
timer(0, 40).pipe(
map(() => drawImageOnCanvas(videoElem, canvasElement))
)
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment