WICG / shape-detection-api

Detection of shapes (faces, QR codes) in images
https://wicg.github.io/shape-detection-api
Other
304 stars 35 forks source link

Support face tracking in live streams #8

Closed huningxin closed 7 years ago

huningxin commented 8 years ago

Use Cases

Camera2 CaptureRequest Event-Driven Pipeline for Face Tracking

iOS

Tracking Faces in Video

Rough sketch of MediaStreamFaceDetector

[Constructor(MediaStream stream, optional FaceDetectorOptions faceDetectorOptions)]
interface MediaStreamFaceDetector: EventTarget {
    readonly        attribute MediaStream       stream;
                    attribute EventHandler      onerror;
                    attribute EventHandler      onfacedetected;
};

[Constructor(DOMString type, FaceDetectionEventInit eventInitDict)]
interface FaceDetectionEvent : Event {
  readonly attribute <sequence<DetectedFace>> faces;
};

dictionary FaceDetectionEventInit : EventInit {
  <sequence<DetectedFace>> faces;
};

Usage

navigator.mediaDevices.getUserMedia(constraints).then(stream => {
  var msfd = new MediaStreamFaceDetector(stream, {fastMode: true, maxDetectedFaces: 1});

  msfd.onfacedetected = function(event) {
    for (const face of event.faces) {
      console.log(`Face ${face.id} detected at (${face.x}, ${face.y}) with size ${face.width}x${face.height}`);
    }
  }
});
yellowdoge commented 7 years ago

This looks cool but is more tracking than detection, which is the concern of this Spec. Perhaps we could throw it back at the wicg discuss as a separate but related idea?

huningxin commented 7 years ago

It makes sense to me. Thanks!