MCPcopy Index your code
hub / github.com/tensorflow/tfjs / next

Method next

tfjs-data/src/iterators/webcam_iterator.ts:148–171  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

146 }
147
148 async next(): Promise<IteratorResult<Tensor3D>> {
149 if (this.isClosed) {
150 return {value: null, done: true};
151 }
152
153 let img;
154 try {
155 img = browser.fromPixels(this.webcamVideoElement);
156 } catch (e) {
157 throw new Error(
158 `Error thrown converting video to pixels: ${JSON.stringify(e)}`);
159 }
160 if (this.resize) {
161 try {
162 return {value: this.cropAndResizeFrame(img), done: false};
163 } catch (e) {
164 throw new Error(`Error thrown cropping the video: ${e.message}`);
165 } finally {
166 img.dispose();
167 }
168 } else {
169 return {value: img, done: false};
170 }
171 }
172
173 private needToResize() {
174 // If resizeWidth and resizeHeight are provided, and different from the

Callers 1

captureMethod · 0.95

Calls 2

cropAndResizeFrameMethod · 0.95
disposeMethod · 0.45

Tested by

no test coverage detected