Skip to content

Instantly share code, notes, and snippets.

@ruanyf
Last active February 6, 2017 05:19
Show Gist options
  • Save ruanyf/d69c3cdeef8e8efd4fb043a0abb141db to your computer and use it in GitHub Desktop.
Save ruanyf/d69c3cdeef8e8efd4fb043a0abb141db to your computer and use it in GitHub Desktop.
Shape Detection API 用法
// 条形码识别(Chrome 56 支持)
var barcodeDetector = new BarcodeDetector();
barcodeDetector.detect(image)
.then(barcodes => {
barcodes.forEach(barcode => console.log(barcodes.rawValue))
})
.catch((e) => {
console.error("Boo, BarcodeDetection failed: " + e);
});
// 人脸识别(Chrome 56 支持)
var faceDetector = new FaceDetector();
faceDetector.detect(image)
.then(faces => faces.forEach(face => console.log(face)))
.catch(e => {
console.error("Boo, Face Detection failed: " + e);
});
// 文字识别(Chrome 56 还不支持)
var textDetector = new TextDetector();
textDetector.detect(image)
.then(boundingBoxes => {
for(let box of boundingBoxes) {
speechSynthesis.speak(new SpeechSynthesisUtterance(box.rawValue));
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment