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

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

Issue 2564163003: ShapeDetection: Add ShapeDetectionProvider (Closed)
Patch Set: Fix layout tests, rebase Created 4 years 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 cd758f011fc5a5510946c00681ff14c2ceb588f4..584f977e677f32f4d148abfe35ae37e553230fcb 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
@@ -26,15 +26,20 @@ import java.nio.ByteBuffer;
*/
public class FaceDetectionImpl implements FaceDetection {
private static final String TAG = "FaceDetectionImpl";
- // By default, there is no limit in the number of faces detected.
- private static final int MAX_FACES = 10;
// Referred from
// https://cs.chromium.org/chromium/src/mojo/edk/system/broker_host.cc?l=24
private static final int MOJO_SHAREDBUFFER_MAX_BYTES = 16 * 1024 * 1024;
+ private final boolean mFastMode;
+ private final int mMaxFaces;
+
+ FaceDetectionImpl(FaceDetectorOptions options) {
+ mFastMode = options.fastMode;
+ mMaxFaces = Math.min(options.maxDetectedFaces, 32);
mcasas 2016/12/13 17:37:32 s/32/MAX_FACES/, with |MAX_FACES| as it was before
xianglu 2016/12/13 19:17:28 Done.
+ }
@Override
- public void detect(SharedBufferHandle frameData, int width, int height,
- FaceDetectorOptions options, DetectResponse callback) {
+ public void detect(
+ SharedBufferHandle frameData, int width, int height, DetectResponse callback) {
if (!frameData.isValid()) {
Log.d(TAG, "Invalid sharedBufferHandle.");
return;
@@ -80,9 +85,9 @@ public class FaceDetectionImpl implements FaceDetection {
Bitmap unPremultipliedBitmap =
Bitmap.createBitmap(pixels, width, height, Bitmap.Config.RGB_565);
- FaceDetector detector = new FaceDetector(width, height, MAX_FACES);
- Face[] detectedFaces = new Face[MAX_FACES];
- // findFaces() will stop at MAX_FACES.
+ FaceDetector detector = new FaceDetector(width, height, mMaxFaces);
+ Face[] detectedFaces = new Face[mMaxFaces];
+ // findFaces() will stop at mMaxFaces.
mcasas 2016/12/13 17:37:32 Escape variable names in comments: |mMaxFaces|
xianglu 2016/12/13 19:17:28 Done.
final int numberOfFaces = detector.findFaces(unPremultipliedBitmap, detectedFaces);
FaceDetectionResult faceDetectionResult = new FaceDetectionResult();

Powered by Google App Engine
This is Rietveld 408576698