Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(facial-recognition) avoid image data conversion

Saúl Ibarra Corretgéc2a3d2935370
diff --git a/react/features/facial-recognition/facialExpressionsWorker.js b/react/features/facial-recognition/facialExpressionsWorker.js
index d00eb4c9b2..7476cef4d1 100644
--- a/react/features/facial-recognition/facialExpressionsWorker.js
+++ b/react/features/facial-recognition/facialExpressionsWorker.js
@@ -58,7 +58,7 @@ onmessage = async function(message) {
}
case SET_TIMEOUT : {
- if (!message.data.imageData || !modelsURL) {
+ if (!message.data.imageBitmap || !modelsURL) {
self.postMessage({
type: FACIAL_EXPRESSION_MESSAGE,
value: null
@@ -72,7 +72,7 @@ onmessage = async function(message) {
modelsLoaded = true;
}
faceapi.tf.engine().startScope();
- const tensor = faceapi.tf.browser.fromPixels(message.data.imageData);
+ const tensor = faceapi.tf.browser.fromPixels(message.data.imageBitmap);
const detections = await faceapi.detectSingleFace(
tensor,
new faceapi.TinyFaceDetectorOptions()
diff --git a/react/features/facial-recognition/functions.js b/react/features/facial-recognition/functions.js
index 2c927e346d..1802868435 100644
--- a/react/features/facial-recognition/functions.js
+++ b/react/features/facial-recognition/functions.js
@@ -131,17 +131,8 @@ export async function sendDataToWorker(
return;
}
- const canvas = document.createElement('canvas');
- const context = canvas.getContext('2d');
-
- canvas.width = imageBitmap.width;
- canvas.height = imageBitmap.height;
- context.drawImage(imageBitmap, 0, 0);
-
- const imageData = context.getImageData(0, 0, imageBitmap.width, imageBitmap.height);
-
worker.postMessage({
type: SET_TIMEOUT,
- imageData
+ imageBitmap
});
}