Attempts to start a video-only stream from a camera into a hidden
VIDEO element for frame capture. The VIDEO element is created automatically.
import { Camera } from'https://unpkg.com/ixfx/dist/io.js' import { Video } from'https://unpkg.com/ixfx/dist/visual.js'
try { const { videoEl, dispose } = awaitCamera.start(); forawait (constframeofVideo.frames(videoEl)) { // Do something with pixels... } } catch (ex) { console.error(`Video could not be started`); }
Be sure to call the dispose() function to stop the video stream and remov
the created VIDEO element.
Constraints can be specified to select a camera and resolution:
import { Camera } from'https://unpkg.com/ixfx/dist/io.js' import { Video } from'https://unpkg.com/ixfx/dist/visual.js'
try { const { videoEl, dispose } = awaitCamera.start({ facingMode:`environment`, max: { width:640, height:480 } }); forawait (constframeofVideo.frames(videoEl)) { // Do something with pixels... } } catch (ex) { // Can happen if user cancels camera request, for example. console.error(`Video could not be started`, ex); }
Attempts to start a video-only stream from a camera into a hidden VIDEO element for frame capture. The VIDEO element is created automatically.
Be sure to call the dispose() function to stop the video stream and remov the created VIDEO element.
Constraints can be specified to select a camera and resolution:
An alternative to Video.frames is Video.capture.