@privateid/ultra-web-sdk-alpha
Version:
CryptoNets WebAssembly SDK
52 lines • 2.06 kB
JavaScript
import { printLogs } from '../../global/shared.utils';
import { CANVAS_CLEANUP_DIMENSION, MAX_DIMENSION } from './face.constants';
export function releaseCanvas(canvas) {
try {
printLogs('STARTING TO RELEASE CANVAS', '');
const canvasElement = canvas;
canvasElement.width = CANVAS_CLEANUP_DIMENSION;
canvasElement.height = CANVAS_CLEANUP_DIMENSION;
const ctx = canvasElement.getContext('2d', { willReadFrequently: true });
if (ctx) {
ctx.clearRect(0, 0, CANVAS_CLEANUP_DIMENSION, CANVAS_CLEANUP_DIMENSION);
}
printLogs('CANVAS RELEASED', '');
}
catch (e) {
printLogs(`CLEARING CANVAS: `, e, 'ERROR');
}
}
export function defineDimensionsForCanvas(videoElementDimensions) {
if (Math.max(videoElementDimensions.width, videoElementDimensions.height) < MAX_DIMENSION) {
return videoElementDimensions;
}
const downscale = MAX_DIMENSION / Math.max(videoElementDimensions.width, videoElementDimensions.height);
return {
width: Math.round(videoElementDimensions.width * downscale),
height: Math.round(videoElementDimensions.height * downscale),
};
}
export function getBaseEnrollConfig() {
return {
input_image_format: 'rgba',
angle_rotation_left_threshold: 20.0,
angle_rotation_right_threshold: 20.0,
threshold_high_vertical_enroll: 0.9,
threshold_down_vertical_enroll: 2.2,
anti_spoofing_threshold: 0.8,
threshold_profile_enroll: 0.66,
blur_threshold_enroll_pred: 40,
threshold_user_too_close: 0.52,
threshold_user_too_far: 0.165,
allow_only_one_face: true,
threshold_user_up: 0.15,
threshold_user_down: 0.9,
threshold_user_left: 0.8,
threshold_user_right: 0.2,
};
}
// TODO: check if isEnrollFlow andd imageData are still needed
export function callbackWithImageCreation(callback, _imageData, _isEnrollFlow) {
return (result) => callback(result);
}
//# sourceMappingURL=face.utils.js.map