drawDetections.js 881 B

12345678910111213141516171819
  1. import { Box } from '../classes';
  2. import { FaceDetection } from '../classes/FaceDetection';
  3. import { isWithFaceDetection } from '../factories/WithFaceDetection';
  4. import { round } from '../utils';
  5. import { DrawBox } from './DrawBox';
  6. export function drawDetections(canvasArg, detections) {
  7. var detectionsArray = Array.isArray(detections) ? detections : [detections];
  8. detectionsArray.forEach(function (det) {
  9. var score = det instanceof FaceDetection
  10. ? det.score
  11. : (isWithFaceDetection(det) ? det.detection.score : undefined);
  12. var box = det instanceof FaceDetection
  13. ? det.box
  14. : (isWithFaceDetection(det) ? det.detection.box : new Box(det));
  15. var label = score ? "" + round(score) : undefined;
  16. new DrawBox(box, { label: label }).draw(canvasArg);
  17. });
  18. }
  19. //# sourceMappingURL=drawDetections.js.map