Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

faceLandmarksWorker.ts 690B

123456789101112131415161718192021222324252627
  1. import { HumanHelper, IFaceLandmarksHelper } from './FaceLandmarksHelper';
  2. import { DETECT_FACE, INIT_WORKER } from './constants';
  3. let helper: IFaceLandmarksHelper;
  4. onmessage = async function({ data }: MessageEvent<any>) {
  5. switch (data.type) {
  6. case DETECT_FACE: {
  7. if (!helper || helper.getDetectionInProgress()) {
  8. return;
  9. }
  10. const detections = await helper.detect(data);
  11. if (detections && (detections.faceBox || detections.faceExpression || detections.faceCount)) {
  12. self.postMessage(detections);
  13. }
  14. break;
  15. }
  16. case INIT_WORKER: {
  17. helper = new HumanHelper(data);
  18. break;
  19. }
  20. }
  21. };