Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(959)

Unified Diff: third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp

Issue 2859413002: Shape Detection: add idl and mojom for face landmarks and wire for Mac (Closed)
Patch Set: service-worker's global-interface-listing-expected.txt updated Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp
diff --git a/third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp b/third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp
index 8f7f19bc9ebe4825ed846b913c52fd2d18d0dde6..e9390f47e68287e72c0c0cc00b3dd1a426b4ae47 100644
--- a/third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp
+++ b/third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp
@@ -7,8 +7,10 @@
#include "core/dom/DOMException.h"
#include "core/geometry/DOMRect.h"
#include "core/html/canvas/CanvasImageSource.h"
+#include "modules/imagecapture/Point2D.h"
#include "modules/shapedetection/DetectedFace.h"
#include "modules/shapedetection/FaceDetectorOptions.h"
+#include "modules/shapedetection/Landmark.h"
#include "public/platform/InterfaceProvider.h"
#include "public/platform/Platform.h"
#include "services/shape_detection/public/interfaces/facedetection_provider.mojom-blink.h"
@@ -57,16 +59,33 @@ ScriptPromise FaceDetector::DoDetect(
void FaceDetector::OnDetectFaces(
ScriptPromiseResolver* resolver,
- shape_detection::mojom::blink::FaceDetectionResultPtr
- face_detection_result) {
+ Vector<shape_detection::mojom::blink::FaceDetectionResultPtr>
+ face_detection_results) {
DCHECK(face_service_requests_.Contains(resolver));
face_service_requests_.erase(resolver);
HeapVector<Member<DetectedFace>> detected_faces;
- for (const auto& bounding_box : face_detection_result->bounding_boxes) {
+ for (const auto& face : face_detection_results) {
+ HeapVector<Landmark> landmarks;
+ for (const auto& landmark : face->landmarks) {
+ Point2D location;
+ location.setX(landmark->location->x);
+ location.setY(landmark->location->y);
+ Landmark web_landmark;
+ web_landmark.setLocation(location);
+ if (landmark->type == shape_detection::mojom::blink::LandmarkType::EYE) {
+ web_landmark.setType("eye");
+ } else if (landmark->type ==
+ shape_detection::mojom::blink::LandmarkType::MOUTH) {
+ web_landmark.setType("mouth");
+ }
+ landmarks.push_back(web_landmark);
+ }
+
detected_faces.push_back(DetectedFace::Create(
- DOMRect::Create(bounding_box->x, bounding_box->y, bounding_box->width,
- bounding_box->height)));
+ DOMRect::Create(face->bounding_box->x, face->bounding_box->y,
+ face->bounding_box->width, face->bounding_box->height),
+ landmarks));
}
resolver->Resolve(detected_faces);

Powered by Google App Engine
This is Rietveld 408576698