(
protected readonly webcamVideoElement: HTMLVideoElement,
protected readonly webcamConfig: WebcamConfig)
| 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`; |
nothing calls this directly
no test coverage detected