drawDetections.js 1.1 KB

12345678910111213141516171819202122
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var classes_1 = require("../classes");
  4. var FaceDetection_1 = require("../classes/FaceDetection");
  5. var WithFaceDetection_1 = require("../factories/WithFaceDetection");
  6. var utils_1 = require("../utils");
  7. var DrawBox_1 = require("./DrawBox");
  8. function drawDetections(canvasArg, detections) {
  9. var detectionsArray = Array.isArray(detections) ? detections : [detections];
  10. detectionsArray.forEach(function (det) {
  11. var score = det instanceof FaceDetection_1.FaceDetection
  12. ? det.score
  13. : (WithFaceDetection_1.isWithFaceDetection(det) ? det.detection.score : undefined);
  14. var box = det instanceof FaceDetection_1.FaceDetection
  15. ? det.box
  16. : (WithFaceDetection_1.isWithFaceDetection(det) ? det.detection.box : new classes_1.Box(det));
  17. var label = score ? "" + utils_1.round(score) : undefined;
  18. new DrawBox_1.DrawBox(box, { label: label }).draw(canvasArg);
  19. });
  20. }
  21. exports.drawDetections = drawDetections;
  22. //# sourceMappingURL=drawDetections.js.map