You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

faceLandmarksWorker.ts 612B

1234567891011121314151617181920212223242526
  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) {
  12. self.postMessage(detections);
  13. }
  14. break;
  15. }
  16. case INIT_WORKER: {
  17. helper = new HumanHelper(data);
  18. break;
  19. }
  20. }
  21. };