LabeledFaceDescriptors.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. var LabeledFaceDescriptors = /** @class */ (function () {
  2. function LabeledFaceDescriptors(label, descriptors) {
  3. if (!(typeof label === 'string')) {
  4. throw new Error('LabeledFaceDescriptors - constructor expected label to be a string');
  5. }
  6. if (!Array.isArray(descriptors) || descriptors.some(function (desc) { return !(desc instanceof Float32Array); })) {
  7. throw new Error('LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array');
  8. }
  9. this._label = label;
  10. this._descriptors = descriptors;
  11. }
  12. Object.defineProperty(LabeledFaceDescriptors.prototype, "label", {
  13. get: function () { return this._label; },
  14. enumerable: true,
  15. configurable: true
  16. });
  17. Object.defineProperty(LabeledFaceDescriptors.prototype, "descriptors", {
  18. get: function () { return this._descriptors; },
  19. enumerable: true,
  20. configurable: true
  21. });
  22. LabeledFaceDescriptors.prototype.toJSON = function () {
  23. return {
  24. label: this.label,
  25. descriptors: this.descriptors.map(function (d) { return Array.from(d); })
  26. };
  27. };
  28. LabeledFaceDescriptors.fromJSON = function (json) {
  29. var descriptors = json.descriptors.map(function (d) {
  30. return new Float32Array(d);
  31. });
  32. return new LabeledFaceDescriptors(json.label, descriptors);
  33. };
  34. return LabeledFaceDescriptors;
  35. }());
  36. export { LabeledFaceDescriptors };
  37. //# sourceMappingURL=LabeledFaceDescriptors.js.map