wicgで議論になっている「Face detection API」の仕様が「Shape Detection in Images」としてwicgのリポジトリで公開されている。
https://wicg.github.io/shape-detection-api/
Shape Detection in Images
HTMLImageElement、HTMLCanvasElement、ImageDataといった画像のデータを与えることで、顔領域の矩形が得られるようである。
現状は、顔を検出する「Face Detection API」と、バーコードを検出する「Barcode Detection API」が定義されている。
具体的にはexampleを見るとわかりやすい
let faceDetector = new FaceDetector({fastMode: true, maxDetectedFaces: 1});
// Assuming |theImage| is e.g. a <img> content, or a Blob.
faceDetector.detect(theImage)
.then(detectedFaces => {
for (const face of detectedFaces) {
console.log(' Face @ (${face.boundingBox.x}, ${face.boundingBox.y}),' +
' size ${face.boundingBox.width}x${face.boundingBox.height}');
}
}).catch(() => {
console.error("Face Detection failed, boo.");
})