| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 </head> | 4 </head> |
| 5 | 5 |
| 6 <body> | 6 <body> |
| 7 <img id="myImage"> | 7 <img id="myImage"> |
| 8 </body> | 8 </body> |
| 9 | 9 |
| 10 <script> | 10 <script> |
| 11 var img = document.getElementById("myImage"); | 11 var img = document.getElementById("myImage"); |
| 12 | 12 |
| 13 function detectFacesOnImageUrl(url) { | 13 function detectFacesOnImageUrl(url) { |
| 14 img.src = url; | 14 img.src = url; |
| 15 img.onload = function() { | 15 img.onload = function() { |
| 16 var detector = new FaceDetector(); | 16 var detector = new FaceDetector(); |
| 17 var results = ""; | 17 var results = ""; |
| 18 detector.detect(img) | 18 detector.detect(img) |
| 19 .then(boundingBoxes => { | 19 .then(detectedFaces => { |
| 20 for (var i=0; i<boundingBoxes.length; i++) { | 20 for (var i = 0; i < detectedFaces.length; i++) { |
| 21 var boundingBox = boundingBoxes[i]; | 21 var boundingBox = detectedFaces[i].boundingBox; |
| 22 var result = boundingBox.x + "," + boundingBox.y + "," + | 22 var result = boundingBox.x + "," + boundingBox.y + "," + |
| 23 boundingBox.width + "," + boundingBox.height; | 23 boundingBox.width + "," + boundingBox.height; |
| 24 results += result + "#"; | 24 results += result + "#"; |
| 25 } | 25 } |
| 26 window.domAutomationController.send(results); | 26 window.domAutomationController.send(results); |
| 27 }) | 27 }) |
| 28 .catch(error => { | 28 .catch(error => { |
| 29 error = new Error("Error during detection:" + error); | 29 error = new Error("Error during detection:" + error); |
| 30 window.domAutomationController.send(error.stack); | 30 window.domAutomationController.send(error.stack); |
| 31 }); | 31 }); |
| 32 } | 32 } |
| 33 } | 33 } |
| 34 </script> | 34 </script> |
| 35 </html> | 35 </html> |
| OLD | NEW |