MtcnnOptions.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. var MtcnnOptions = /** @class */ (function () {
  2. function MtcnnOptions(_a) {
  3. var _b = _a === void 0 ? {} : _a, minFaceSize = _b.minFaceSize, scaleFactor = _b.scaleFactor, maxNumScales = _b.maxNumScales, scoreThresholds = _b.scoreThresholds, scaleSteps = _b.scaleSteps;
  4. this._name = 'MtcnnOptions';
  5. this._minFaceSize = minFaceSize || 20;
  6. this._scaleFactor = scaleFactor || 0.709;
  7. this._maxNumScales = maxNumScales || 10;
  8. this._scoreThresholds = scoreThresholds || [0.6, 0.7, 0.7];
  9. this._scaleSteps = scaleSteps;
  10. if (typeof this._minFaceSize !== 'number' || this._minFaceSize < 0) {
  11. throw new Error(this._name + " - expected minFaceSize to be a number > 0");
  12. }
  13. if (typeof this._scaleFactor !== 'number' || this._scaleFactor <= 0 || this._scaleFactor >= 1) {
  14. throw new Error(this._name + " - expected scaleFactor to be a number between 0 and 1");
  15. }
  16. if (typeof this._maxNumScales !== 'number' || this._maxNumScales < 0) {
  17. throw new Error(this._name + " - expected maxNumScales to be a number > 0");
  18. }
  19. if (!Array.isArray(this._scoreThresholds)
  20. || this._scoreThresholds.length !== 3
  21. || this._scoreThresholds.some(function (th) { return typeof th !== 'number'; })) {
  22. throw new Error(this._name + " - expected scoreThresholds to be an array of numbers of length 3");
  23. }
  24. if (this._scaleSteps
  25. && (!Array.isArray(this._scaleSteps) || this._scaleSteps.some(function (th) { return typeof th !== 'number'; }))) {
  26. throw new Error(this._name + " - expected scaleSteps to be an array of numbers");
  27. }
  28. }
  29. Object.defineProperty(MtcnnOptions.prototype, "minFaceSize", {
  30. get: function () { return this._minFaceSize; },
  31. enumerable: true,
  32. configurable: true
  33. });
  34. Object.defineProperty(MtcnnOptions.prototype, "scaleFactor", {
  35. get: function () { return this._scaleFactor; },
  36. enumerable: true,
  37. configurable: true
  38. });
  39. Object.defineProperty(MtcnnOptions.prototype, "maxNumScales", {
  40. get: function () { return this._maxNumScales; },
  41. enumerable: true,
  42. configurable: true
  43. });
  44. Object.defineProperty(MtcnnOptions.prototype, "scoreThresholds", {
  45. get: function () { return this._scoreThresholds; },
  46. enumerable: true,
  47. configurable: true
  48. });
  49. Object.defineProperty(MtcnnOptions.prototype, "scaleSteps", {
  50. get: function () { return this._scaleSteps; },
  51. enumerable: true,
  52. configurable: true
  53. });
  54. return MtcnnOptions;
  55. }());
  56. export { MtcnnOptions };
  57. //# sourceMappingURL=MtcnnOptions.js.map