face-api/src/ssdMobilenetv1/SsdMobilenetv1Options.ts

30 lines
881 B
TypeScript
Raw Normal View History

2020-08-26 00:24:48 +02:00
export interface ISsdMobilenetv1Options {
minConfidence?: number
maxResults?: number
}
export class SsdMobilenetv1Options {
protected _name: string = 'SsdMobilenetv1Options'
private _minConfidence: number
2020-12-23 17:26:55 +01:00
2020-08-26 00:24:48 +02:00
private _maxResults: number
constructor({ minConfidence, maxResults }: ISsdMobilenetv1Options = {}) {
2020-12-23 17:26:55 +01:00
this._minConfidence = minConfidence || 0.5;
this._maxResults = maxResults || 100;
2020-08-26 00:24:48 +02:00
if (typeof this._minConfidence !== 'number' || this._minConfidence <= 0 || this._minConfidence >= 1) {
2020-12-23 17:26:55 +01:00
throw new Error(`${this._name} - expected minConfidence to be a number between 0 and 1`);
2020-08-26 00:24:48 +02:00
}
if (typeof this._maxResults !== 'number') {
2020-12-23 17:26:55 +01:00
throw new Error(`${this._name} - expected maxResults to be a number`);
2020-08-26 00:24:48 +02:00
}
}
2020-12-23 17:26:55 +01:00
get minConfidence(): number { return this._minConfidence; }
get maxResults(): number { return this._maxResults; }
}