face-api/src/classes/FaceMatch.ts

26 lines
578 B
TypeScript
Raw Normal View History

2020-12-19 17:46:41 +01:00
import { round } from '../utils/index';
2020-08-18 13:54:53 +02:00
export interface IFaceMatch {
label: string
distance: number
}
export class FaceMatch implements IFaceMatch {
private _label: string
2020-12-23 17:26:55 +01:00
2020-08-18 13:54:53 +02:00
private _distance: number
constructor(label: string, distance: number) {
2020-12-23 17:26:55 +01:00
this._label = label;
this._distance = distance;
2020-08-18 13:54:53 +02:00
}
2020-12-23 17:26:55 +01:00
public get label(): string { return this._label; }
public get distance(): number { return this._distance; }
2020-08-18 13:54:53 +02:00
public toString(withDistance: boolean = true): string {
2020-12-23 17:26:55 +01:00
return `${this.label}${withDistance ? ` (${round(this.distance)})` : ''}`;
2020-08-18 13:54:53 +02:00
}
2020-12-23 17:26:55 +01:00
}