| 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 detectShapesOnImageUrl(detector, url) { |
| 14 img.src = url; | 14 var detector = eval('new ' + detector + '()'); |
| 15 console.log(detector); |
| 15 img.onload = function() { | 16 img.onload = function() { |
| 16 var detector = new FaceDetector(); | 17 console.log('image loaded'); |
| 17 var results = ""; | 18 var results = ""; |
| 18 detector.detect(img) | 19 detector.detect(img) |
| 19 .then(detectedFaces => { | 20 .then(detectedObjects => { |
| 20 for (var i = 0; i < detectedFaces.length; i++) { | 21 console.log('something detected'); |
| 21 var boundingBox = detectedFaces[i].boundingBox; | 22 for (var i = 0; i < detectedObjects.length; i++) { |
| 23 var boundingBox = detectedObjects[i].boundingBox; |
| 22 var result = boundingBox.x + "," + boundingBox.y + "," + | 24 var result = boundingBox.x + "," + boundingBox.y + "," + |
| 23 boundingBox.width + "," + boundingBox.height; | 25 boundingBox.width + "," + boundingBox.height; |
| 24 results += result + "#"; | 26 results += result + "#"; |
| 25 } | 27 } |
| 26 window.domAutomationController.send(results); | 28 window.domAutomationController.send(results); |
| 27 }) | 29 }) |
| 28 .catch(error => { | 30 .catch(error => { |
| 29 error = new Error("Error during detection:" + error.message); | 31 console.error(error.mesage); |
| 30 window.domAutomationController.send(error.message); | 32 window.domAutomationController.send(error.message); |
| 31 }); | 33 }); |
| 32 } | 34 } |
| 35 img.src = url; |
| 33 } | 36 } |
| 34 </script> | 37 </script> |
| 35 </html> | 38 </html> |
| OLD | NEW |