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

faceLandmarksWorker.ts 712B

12345678910111213141516171819202122232425262728
  1. import { FaceLandmarksHelper, HumanHelper } from './FaceLandmarksHelper';
  2. import { DETECT_FACE, INIT_WORKER } from './constants';
  3. let helper: FaceLandmarksHelper;
  4. onmessage = async function(message: MessageEvent<any>) {
  5. switch (message.data.type) {
  6. case DETECT_FACE: {
  7. if (!helper || helper.getDetectionInProgress()) {
  8. return;
  9. }
  10. const detections = await helper.detect(message.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(message.data);
  18. break;
  19. }
  20. }
  21. };