MCPcopy
hub / github.com/tensorflow/tfjs / create

Method create

tfjs-data/src/iterators/webcam_iterator.ts:68–93  ·  view source on GitHub ↗
(
      webcamVideoElement?: HTMLVideoElement, webcamConfig: WebcamConfig = {})

Source from the content-addressed store, hash-verified

66
67 // Construct a WebcamIterator and start it's video stream.
68 static async create(
69 webcamVideoElement?: HTMLVideoElement, webcamConfig: WebcamConfig = {}) {
70 if (!env().get('IS_BROWSER')) {
71 throw new Error(
72 'tf.data.webcam is only supported in browser environment.');
73 }
74
75 if (!webcamVideoElement) {
76 // If webcam video element is not provided, create a hidden video element
77 // with provided width and height.
78 webcamVideoElement = document.createElement('video');
79 if (!webcamConfig.resizeWidth || !webcamConfig.resizeHeight) {
80 throw new Error(
81 'Please provide webcam video element, or resizeWidth and ' +
82 'resizeHeight to create a hidden video element.');
83 }
84 webcamVideoElement.width = webcamConfig.resizeWidth;
85 webcamVideoElement.height = webcamConfig.resizeHeight;
86 }
87 const webcamIterator = new WebcamIterator(webcamVideoElement, webcamConfig);
88
89 // Call async function to initialize the video stream.
90 await webcamIterator.start();
91
92 return webcamIterator;
93 }
94
95 // Async function to start video stream.
96 async start(): Promise<void> {

Callers

nothing calls this directly

Calls 3

startMethod · 0.95
envFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected