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

Method constructor

tfjs-data/src/iterators/webcam_iterator.ts:35–61  ·  view source on GitHub ↗
(
      protected readonly webcamVideoElement: HTMLVideoElement,
      protected readonly webcamConfig: WebcamConfig)

Source from the content-addressed store, hash-verified

33 private cropBoxInd: Tensor1D;
34
35 private constructor(
36 protected readonly webcamVideoElement: HTMLVideoElement,
37 protected readonly webcamConfig: WebcamConfig) {
38 super();
39 if (this.needToResize()) {
40 this.resize = true;
41 this.cropSize =
42 [this.webcamConfig.resizeHeight, this.webcamConfig.resizeWidth];
43 this.cropBoxInd = tensor1d([0], 'int32');
44 if (this.webcamConfig.centerCrop) {
45 // Calculate the box based on resizing shape.
46 const widthCroppingRatio =
47 this.webcamConfig.resizeWidth * 1.0 / this.webcamVideoElement.width;
48 const heightCroppingRatio = this.webcamConfig.resizeHeight * 1.0 /
49 this.webcamVideoElement.height;
50 const widthCropStart = (1 - widthCroppingRatio) / 2;
51 const heightCropStart = (1 - heightCroppingRatio) / 2;
52 const widthCropEnd = widthCropStart + widthCroppingRatio;
53 const heightCropEnd = heightCroppingRatio + heightCropStart;
54 this.cropBox = tensor2d(
55 [heightCropStart, widthCropStart, heightCropEnd, widthCropEnd],
56 [1, 4]);
57 } else {
58 this.cropBox = tensor2d([0, 0, 1, 1], [1, 4]);
59 }
60 }
61 }
62
63 summary() {
64 return `webcam`;

Callers

nothing calls this directly

Calls 3

needToResizeMethod · 0.95
tensor1dFunction · 0.90
tensor2dFunction · 0.90

Tested by

no test coverage detected