2020-08-20 02:10:42 +02:00
|
|
|
export const FACE_EXPRESSION_LABELS = ['neutral', 'happy', 'sad', 'angry', 'fearful', 'disgusted', 'surprised'];
|
|
|
|
export class FaceExpressions {
|
2020-08-18 14:04:33 +02:00
|
|
|
constructor(probabilities) {
|
|
|
|
if (probabilities.length !== 7) {
|
|
|
|
throw new Error(`FaceExpressions.constructor - expected probabilities.length to be 7, have: ${probabilities.length}`);
|
|
|
|
}
|
2020-08-20 02:10:42 +02:00
|
|
|
FACE_EXPRESSION_LABELS.forEach((expression, idx) => {
|
2020-08-18 14:04:33 +02:00
|
|
|
this[expression] = probabilities[idx];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
asSortedArray() {
|
2020-08-20 02:10:42 +02:00
|
|
|
return FACE_EXPRESSION_LABELS
|
2020-08-18 14:04:33 +02:00
|
|
|
.map(expression => ({ expression, probability: this[expression] }))
|
|
|
|
.sort((e0, e1) => e1.probability - e0.probability);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//# sourceMappingURL=FaceExpressions.js.map
|