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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/shapedetection/FaceDetectionImpl.java

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: content/public/android/java/src/org/chromium/content/browser/shapedetection/FaceDetectionImpl.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/shapedetection/FaceDetectionImpl.java b/content/public/android/java/src/org/chromium/content/browser/shapedetection/FaceDetectionImpl.java
index dfb6fb63638d82a86283d92caf6676979b6991e8..674673e9b9f3b8edc936f8ffb2263ef91c971d34 100644
--- a/content/public/android/java/src/org/chromium/content/browser/shapedetection/FaceDetectionImpl.java
+++ b/content/public/android/java/src/org/chromium/content/browser/shapedetection/FaceDetectionImpl.java
@@ -43,14 +43,14 @@ public class FaceDetectionImpl implements FaceDetection {
// TODO(xianglu): https://crbug.com/670028 homogeneize overflow checking.
if (!frameData.isValid() || width <= 0 || height <= 0 || numPixels > (Long.MAX_VALUE / 4)) {
Log.d(TAG, "Invalid argument(s).");
- callback.call(new FaceDetectionResult());
+ callback.call(new FaceDetectionResult[0]);
return;
}
ByteBuffer imageBuffer = frameData.map(0, numPixels * 4, MapFlags.none());
if (imageBuffer.capacity() <= 0) {
Log.d(TAG, "Failed to map from SharedBufferHandle.");
- callback.call(new FaceDetectionResult());
+ callback.call(new FaceDetectionResult[0]);
return;
}
@@ -88,25 +88,25 @@ public class FaceDetectionImpl implements FaceDetection {
// findFaces() will stop at |mMaxFaces|.
final int numberOfFaces = detector.findFaces(unPremultipliedBitmap, detectedFaces);
- FaceDetectionResult faceDetectionResult = new FaceDetectionResult();
- faceDetectionResult.boundingBoxes = new RectF[numberOfFaces];
+ FaceDetectionResult[] faceArray = new FaceDetectionResult[numberOfFaces];
+
for (int i = 0; i < numberOfFaces; i++) {
+ faceArray[i] = new FaceDetectionResult();
+
final Face face = detectedFaces[i];
final PointF midPoint = new PointF();
face.getMidPoint(midPoint);
final float eyesDistance = face.eyesDistance();
- RectF boundingBox = new RectF();
- boundingBox.x = midPoint.x - eyesDistance;
- boundingBox.y = midPoint.y - eyesDistance;
- boundingBox.width = 2 * eyesDistance;
- boundingBox.height = 2 * eyesDistance;
-
+ faceArray[i].boundingBox = new RectF();
+ faceArray[i].boundingBox.x = midPoint.x - eyesDistance;
+ faceArray[i].boundingBox.y = midPoint.y - eyesDistance;
+ faceArray[i].boundingBox.width = 2 * eyesDistance;
+ faceArray[i].boundingBox.height = 2 * eyesDistance;
// TODO(xianglu): Consider adding Face.confidence and Face.pose.
- faceDetectionResult.boundingBoxes[i] = boundingBox;
}
- callback.call(faceDetectionResult);
+ callback.call(faceArray);
}
});
}

Powered by Google App Engine
This is Rietveld 408576698