• Create an iterator that generates Tensors from webcam video stream. This API only works in Browser environment when the device has webcam.

    Note: this code snippet only works when the device has a webcam. It will request permission to open the webcam when running.

    const videoElement = document.createElement('video');
    videoElement.width = 100;
    videoElement.height = 100;
    const cam = await tf.data.webcam(videoElement);
    const img = await cam.capture();
    img.print();
    cam.stop();

    Parameters

    • Optional webcamVideoElement: HTMLVideoElement

      A HTMLVideoElement used to play video from webcam. If this element is not provided, a hidden HTMLVideoElement will be created. In that case, resizeWidth and resizeHeight must be provided to set the generated tensor shape.

    • Optional webcamConfig: WebcamConfig

      A WebcamConfig object that contains configurations of reading and manipulating data from webcam video stream.

    Returns Promise<WebcamIterator>

    Doc

Generated using TypeDoc