Last active
February 6, 2017 05:19
-
-
Save ruanyf/d69c3cdeef8e8efd4fb043a0abb141db to your computer and use it in GitHub Desktop.
Shape Detection API 用法
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 条形码识别(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