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

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

Issue 2564163003: ShapeDetection: Add ShapeDetectionProvider (Closed)
Patch Set: 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..eea02f444bfb98583dca0d36cbd9fd93ec335de2 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,18 @@ 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 int mMaxFaces;
+
+ FaceDetectionImpl(FaceDetectorOptions options) {
+ mMaxFaces = options.maxDetectedFaces;
Reilly Grant (use Gerrit) 2016/12/10 01:18:22 Since this value is attacker controlled should we
xianglu 2016/12/10 02:22:19 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 +83,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.
final int numberOfFaces = detector.findFaces(unPremultipliedBitmap, detectedFaces);
FaceDetectionResult faceDetectionResult = new FaceDetectionResult();

Powered by Google App Engine
This is Rietveld 408576698