ixfx
    Preparing search index...

    Function start

    • 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 } = await Camera.start();
      for await (const frame of Video.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 } = await Camera.start({
      facingMode: `environment`,
      max: { width: 640, height: 480 }
      });

      for await (const frame of Video.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);
      }

      An alternative to Video.frames is Video.capture.

      Parameters

      Returns Promise<Io.Camera.StartResult>

      Returns { videoEl, dispose }, where videoEl is the created VIDEO element, and dispose is a function for removing the element and stopping the video.