MtcnnOptions.js 2.8 KB

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