I got this error when implemented face detection on video stream. I’v use webgl as a backend on tfjs
Uncaught (in promise) Error: Requested texture size [0x0] is invalid.
at Module.validateTextureSize (webgl_util.ts:210:1)
at createAndConfigureTexture (gpgpu_util.ts:57:1)
at Module.createUnsignedBytesMatrixTexture (gpgpu_util.ts:129:1)
at GPGPUContext.createUnsignedBytesMatrixTexture (gpgpu_context.ts:211:1)
at TextureManager.acquireTexture (texture_manager.ts:77:1)
at MathBackendWebGL.acquireTexture (backend_webgl.ts:1215:1)
at MathBackendWebGL.uploadToGPU (backend_webgl.ts:1187:1)
at MathBackendWebGL.getTexture (backend_webgl.ts:717:1)
at Object.fromPixels [as kernelFunc] (FromPixels.ts:81:1)
at kernelFunc (engine.ts:647:1)
The listener
// console.log('detector started')
if (this.detectorInterval === null) {
this.detectorInterval = setInterval(async () => {
await this.detect(video, canvas, onFaceDetected, onMultiFaceDetected);
}, 100);
}
and detect function
async detect(input, canvas, onFaceDetected, onMultiFaceDetected) {
const estimationConfig = { flipHorizontal: false };
const faces = await this.detector.estimateFaces(input, estimationConfig);
const ctx = canvas.getContext("2d");
// console.log(faces)
if (faces.length !== 0) onFaceDetected(true);
else onFaceDetected(false);
if (faces.length > 1) onMultiFaceDetected(true);
else onMultiFaceDetected(false);
requestAnimationFrame(() => drawFaces(faces, ctx));
}
The input
(video) param is always have hight and weight but got that error Error: Requested texture size [0x0] is invalid.
how to resolve the error? Thanks for your help