586 lines
27 KiB
Diff
586 lines
27 KiB
Diff
From: Wengling Chen <feiyu2817@gmail.com>
|
|
Date: Fri, 1 Nov 2019 23:10:47 +0100
|
|
Subject: Remove dependency on com.google.android.gms.vision,
|
|
com.google.android.gms.clearcut, com.google.android.gms.phenotype
|
|
|
|
---
|
|
services/BUILD.gn | 4 -
|
|
services/shape_detection/BUILD.gn | 2 -
|
|
.../shape_detection/BarcodeDetectionImpl.java | 114 +---------------
|
|
.../BarcodeDetectionProviderImpl.java | 18 +--
|
|
.../FaceDetectionImplGmsCore.java | 122 +-----------------
|
|
.../shape_detection/TextDetectionImpl.java | 60 +--------
|
|
third_party/android_deps/BUILD.gn | 83 ------------
|
|
7 files changed, 10 insertions(+), 393 deletions(-)
|
|
|
|
diff --git a/services/BUILD.gn b/services/BUILD.gn
|
|
--- a/services/BUILD.gn
|
|
+++ b/services/BUILD.gn
|
|
@@ -105,8 +105,6 @@ if (is_android) {
|
|
deps = [
|
|
"$google_play_services_package:google_play_services_base_java",
|
|
"$google_play_services_package:google_play_services_basement_java",
|
|
- "$google_play_services_package:google_play_services_vision_common_java",
|
|
- "$google_play_services_package:google_play_services_vision_java",
|
|
"//base:base_java",
|
|
"//base:base_java_test_support",
|
|
"//base:base_junit_test_support",
|
|
@@ -136,8 +134,6 @@ if (is_android) {
|
|
deps = [
|
|
"$google_play_services_package:google_play_services_base_java",
|
|
"$google_play_services_package:google_play_services_basement_java",
|
|
- "$google_play_services_package:google_play_services_vision_common_java",
|
|
- "$google_play_services_package:google_play_services_vision_java",
|
|
"//base:base_java",
|
|
"//base:base_java_test_support",
|
|
"//mojo/public/java:base_java",
|
|
diff --git a/services/shape_detection/BUILD.gn b/services/shape_detection/BUILD.gn
|
|
--- a/services/shape_detection/BUILD.gn
|
|
+++ b/services/shape_detection/BUILD.gn
|
|
@@ -91,8 +91,6 @@ if (is_android) {
|
|
deps = [
|
|
"$google_play_services_package:google_play_services_base_java",
|
|
"$google_play_services_package:google_play_services_basement_java",
|
|
- "$google_play_services_package:google_play_services_vision_common_java",
|
|
- "$google_play_services_package:google_play_services_vision_java",
|
|
"//base:base_java",
|
|
"//mojo/public/java:base_java",
|
|
"//mojo/public/java:bindings_java",
|
|
diff --git a/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionImpl.java b/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionImpl.java
|
|
--- a/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionImpl.java
|
|
+++ b/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionImpl.java
|
|
@@ -8,10 +8,6 @@ import android.graphics.Point;
|
|
import android.graphics.Rect;
|
|
import android.util.SparseArray;
|
|
|
|
-import com.google.android.gms.vision.Frame;
|
|
-import com.google.android.gms.vision.barcode.Barcode;
|
|
-import com.google.android.gms.vision.barcode.BarcodeDetector;
|
|
-
|
|
import org.chromium.base.ContextUtils;
|
|
import org.chromium.base.Log;
|
|
import org.chromium.gfx.mojom.PointF;
|
|
@@ -28,50 +24,7 @@ import org.chromium.shape_detection.mojom.BarcodeFormat;
|
|
public class BarcodeDetectionImpl implements BarcodeDetection {
|
|
private static final String TAG = "BarcodeDetectionImpl";
|
|
|
|
- private BarcodeDetector mBarcodeDetector;
|
|
-
|
|
public BarcodeDetectionImpl(BarcodeDetectorOptions options) {
|
|
- int formats = Barcode.ALL_FORMATS;
|
|
- if (options.formats != null && options.formats.length > 0) {
|
|
- formats = 0;
|
|
- // Keep this list in sync with the constants defined in
|
|
- // com.google.android.gms.vision.barcode.Barcode and the list of
|
|
- // supported formats in BarcodeDetectionProviderImpl.
|
|
- for (int i = 0; i < options.formats.length; ++i) {
|
|
- if (options.formats[i] == BarcodeFormat.AZTEC) {
|
|
- formats |= Barcode.AZTEC;
|
|
- } else if (options.formats[i] == BarcodeFormat.CODE_128) {
|
|
- formats |= Barcode.CODE_128;
|
|
- } else if (options.formats[i] == BarcodeFormat.CODE_39) {
|
|
- formats |= Barcode.CODE_39;
|
|
- } else if (options.formats[i] == BarcodeFormat.CODE_93) {
|
|
- formats |= Barcode.CODE_93;
|
|
- } else if (options.formats[i] == BarcodeFormat.CODABAR) {
|
|
- formats |= Barcode.CODABAR;
|
|
- } else if (options.formats[i] == BarcodeFormat.DATA_MATRIX) {
|
|
- formats |= Barcode.DATA_MATRIX;
|
|
- } else if (options.formats[i] == BarcodeFormat.EAN_13) {
|
|
- formats |= Barcode.EAN_13;
|
|
- } else if (options.formats[i] == BarcodeFormat.EAN_8) {
|
|
- formats |= Barcode.EAN_8;
|
|
- } else if (options.formats[i] == BarcodeFormat.ITF) {
|
|
- formats |= Barcode.ITF;
|
|
- } else if (options.formats[i] == BarcodeFormat.PDF417) {
|
|
- formats |= Barcode.PDF417;
|
|
- } else if (options.formats[i] == BarcodeFormat.QR_CODE) {
|
|
- formats |= Barcode.QR_CODE;
|
|
- } else if (options.formats[i] == BarcodeFormat.UPC_A) {
|
|
- formats |= Barcode.UPC_A;
|
|
- } else if (options.formats[i] == BarcodeFormat.UPC_E) {
|
|
- formats |= Barcode.UPC_E;
|
|
- } else {
|
|
- Log.e(TAG, "Unsupported barcode format hint: " + options.formats[i]);
|
|
- }
|
|
- }
|
|
- }
|
|
- mBarcodeDetector = new BarcodeDetector.Builder(ContextUtils.getApplicationContext())
|
|
- .setBarcodeFormats(formats)
|
|
- .build();
|
|
}
|
|
|
|
@Override
|
|
@@ -80,47 +33,12 @@ public class BarcodeDetectionImpl implements BarcodeDetection {
|
|
// on the device; this happens "fast", but it might have not completed,
|
|
// bail in this case. Also, the API was disabled between and v.9.0 and
|
|
// v.9.2, see https://developers.google.com/android/guides/releases.
|
|
- if (!mBarcodeDetector.isOperational()) {
|
|
- Log.e(TAG, "BarcodeDetector is not operational");
|
|
- callback.call(new BarcodeDetectionResult[0]);
|
|
- return;
|
|
- }
|
|
-
|
|
- Frame frame = BitmapUtils.convertToFrame(bitmapData);
|
|
- if (frame == null) {
|
|
- Log.e(TAG, "Error converting Mojom Bitmap to Frame");
|
|
- callback.call(new BarcodeDetectionResult[0]);
|
|
- return;
|
|
- }
|
|
-
|
|
- final SparseArray<Barcode> barcodes = mBarcodeDetector.detect(frame);
|
|
-
|
|
- BarcodeDetectionResult[] barcodeArray = new BarcodeDetectionResult[barcodes.size()];
|
|
- for (int i = 0; i < barcodes.size(); i++) {
|
|
- barcodeArray[i] = new BarcodeDetectionResult();
|
|
- final Barcode barcode = barcodes.valueAt(i);
|
|
- barcodeArray[i].rawValue = barcode.rawValue;
|
|
- final Rect rect = barcode.getBoundingBox();
|
|
- barcodeArray[i].boundingBox = new RectF();
|
|
- barcodeArray[i].boundingBox.x = rect.left;
|
|
- barcodeArray[i].boundingBox.y = rect.top;
|
|
- barcodeArray[i].boundingBox.width = rect.width();
|
|
- barcodeArray[i].boundingBox.height = rect.height();
|
|
- final Point[] corners = barcode.cornerPoints;
|
|
- barcodeArray[i].cornerPoints = new PointF[corners.length];
|
|
- for (int j = 0; j < corners.length; j++) {
|
|
- barcodeArray[i].cornerPoints[j] = new PointF();
|
|
- barcodeArray[i].cornerPoints[j].x = corners[j].x;
|
|
- barcodeArray[i].cornerPoints[j].y = corners[j].y;
|
|
- }
|
|
- barcodeArray[i].format = toBarcodeFormat(barcode.format);
|
|
- }
|
|
- callback.call(barcodeArray);
|
|
+ Log.e(TAG, "BarcodeDetector is not operational");
|
|
+ callback.call(new BarcodeDetectionResult[0]);
|
|
}
|
|
|
|
@Override
|
|
public void close() {
|
|
- mBarcodeDetector.release();
|
|
}
|
|
|
|
@Override
|
|
@@ -129,34 +47,6 @@ public class BarcodeDetectionImpl implements BarcodeDetection {
|
|
}
|
|
|
|
private int toBarcodeFormat(int format) {
|
|
- switch (format) {
|
|
- case Barcode.CODE_128:
|
|
- return BarcodeFormat.CODE_128;
|
|
- case Barcode.CODE_39:
|
|
- return BarcodeFormat.CODE_39;
|
|
- case Barcode.CODE_93:
|
|
- return BarcodeFormat.CODE_93;
|
|
- case Barcode.CODABAR:
|
|
- return BarcodeFormat.CODABAR;
|
|
- case Barcode.DATA_MATRIX:
|
|
- return BarcodeFormat.DATA_MATRIX;
|
|
- case Barcode.EAN_13:
|
|
- return BarcodeFormat.EAN_13;
|
|
- case Barcode.EAN_8:
|
|
- return BarcodeFormat.EAN_8;
|
|
- case Barcode.ITF:
|
|
- return BarcodeFormat.ITF;
|
|
- case Barcode.QR_CODE:
|
|
- return BarcodeFormat.QR_CODE;
|
|
- case Barcode.UPC_A:
|
|
- return BarcodeFormat.UPC_A;
|
|
- case Barcode.UPC_E:
|
|
- return BarcodeFormat.UPC_E;
|
|
- case Barcode.PDF417:
|
|
- return BarcodeFormat.PDF417;
|
|
- case Barcode.AZTEC:
|
|
- return BarcodeFormat.AZTEC;
|
|
- }
|
|
return BarcodeFormat.UNKNOWN;
|
|
}
|
|
}
|
|
diff --git a/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionProviderImpl.java b/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionProviderImpl.java
|
|
--- a/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionProviderImpl.java
|
|
+++ b/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionProviderImpl.java
|
|
@@ -4,9 +4,6 @@
|
|
|
|
package org.chromium.shape_detection;
|
|
|
|
-import com.google.android.gms.common.ConnectionResult;
|
|
-import com.google.android.gms.common.GoogleApiAvailability;
|
|
-
|
|
import org.chromium.base.ContextUtils;
|
|
import org.chromium.base.Log;
|
|
import org.chromium.mojo.bindings.InterfaceRequest;
|
|
@@ -35,12 +32,6 @@ public class BarcodeDetectionProviderImpl implements BarcodeDetectionProvider {
|
|
// Keep this list in sync with the constants defined in
|
|
// com.google.android.gms.vision.barcode.Barcode and the format hints
|
|
// supported by BarcodeDetectionImpl.
|
|
- int[] supportedFormats = {BarcodeFormat.AZTEC, BarcodeFormat.CODE_128,
|
|
- BarcodeFormat.CODE_39, BarcodeFormat.CODE_93, BarcodeFormat.CODABAR,
|
|
- BarcodeFormat.DATA_MATRIX, BarcodeFormat.EAN_13, BarcodeFormat.EAN_8,
|
|
- BarcodeFormat.ITF, BarcodeFormat.PDF417, BarcodeFormat.QR_CODE, BarcodeFormat.UPC_A,
|
|
- BarcodeFormat.UPC_E};
|
|
- callback.call(supportedFormats);
|
|
}
|
|
|
|
@Override
|
|
@@ -50,12 +41,7 @@ public class BarcodeDetectionProviderImpl implements BarcodeDetectionProvider {
|
|
public void onConnectionError(MojoException e) {}
|
|
|
|
public static BarcodeDetectionProvider create() {
|
|
- if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
|
|
- ContextUtils.getApplicationContext())
|
|
- != ConnectionResult.SUCCESS) {
|
|
- Log.e(TAG, "Google Play Services not available");
|
|
- return null;
|
|
- }
|
|
- return new BarcodeDetectionProviderImpl();
|
|
+ Log.e(TAG, "Google Play Services not available");
|
|
+ return null;
|
|
}
|
|
}
|
|
diff --git a/services/shape_detection/android/java/src/org/chromium/shape_detection/FaceDetectionImplGmsCore.java b/services/shape_detection/android/java/src/org/chromium/shape_detection/FaceDetectionImplGmsCore.java
|
|
--- a/services/shape_detection/android/java/src/org/chromium/shape_detection/FaceDetectionImplGmsCore.java
|
|
+++ b/services/shape_detection/android/java/src/org/chromium/shape_detection/FaceDetectionImplGmsCore.java
|
|
@@ -7,11 +7,6 @@ package org.chromium.shape_detection;
|
|
import android.graphics.PointF;
|
|
import android.util.SparseArray;
|
|
|
|
-import com.google.android.gms.vision.Frame;
|
|
-import com.google.android.gms.vision.face.Face;
|
|
-import com.google.android.gms.vision.face.FaceDetector;
|
|
-import com.google.android.gms.vision.face.Landmark;
|
|
-
|
|
import org.chromium.base.ContextUtils;
|
|
import org.chromium.base.Log;
|
|
import org.chromium.gfx.mojom.RectF;
|
|
@@ -36,133 +31,20 @@ public class FaceDetectionImplGmsCore implements FaceDetection {
|
|
private static final int MAX_EULER_Z = 15;
|
|
private final int mMaxFaces;
|
|
private final boolean mFastMode;
|
|
- private final FaceDetector mFaceDetector;
|
|
|
|
FaceDetectionImplGmsCore(FaceDetectorOptions options) {
|
|
- FaceDetector.Builder builder =
|
|
- new FaceDetector.Builder(ContextUtils.getApplicationContext());
|
|
mMaxFaces = Math.min(options.maxDetectedFaces, MAX_FACES);
|
|
mFastMode = options.fastMode;
|
|
-
|
|
- try {
|
|
- builder.setMode(mFastMode ? FaceDetector.FAST_MODE : FaceDetector.ACCURATE_MODE);
|
|
- builder.setLandmarkType(FaceDetector.ALL_LANDMARKS);
|
|
- if (mMaxFaces == 1) {
|
|
- builder.setProminentFaceOnly(true);
|
|
- }
|
|
- } catch (IllegalArgumentException e) {
|
|
- Log.e(TAG, "Unexpected exception " + e);
|
|
- assert false;
|
|
- }
|
|
-
|
|
- mFaceDetector = builder.build();
|
|
}
|
|
|
|
@Override
|
|
public void detect(org.chromium.skia.mojom.Bitmap bitmapData, DetectResponse callback) {
|
|
- // The vision library will be downloaded the first time the API is used
|
|
- // on the device; this happens "fast", but it might have not completed,
|
|
- // bail in this case.
|
|
- if (!mFaceDetector.isOperational()) {
|
|
- Log.e(TAG, "FaceDetector is not operational");
|
|
-
|
|
- // Fallback to Android's FaceDetectionImpl.
|
|
- FaceDetectorOptions options = new FaceDetectorOptions();
|
|
- options.fastMode = mFastMode;
|
|
- options.maxDetectedFaces = mMaxFaces;
|
|
- FaceDetectionImpl detector = new FaceDetectionImpl(options);
|
|
- detector.detect(bitmapData, callback);
|
|
- return;
|
|
- }
|
|
-
|
|
- Frame frame = BitmapUtils.convertToFrame(bitmapData);
|
|
- if (frame == null) {
|
|
- Log.e(TAG, "Error converting Mojom Bitmap to Frame");
|
|
- callback.call(new FaceDetectionResult[0]);
|
|
- return;
|
|
- }
|
|
-
|
|
- final SparseArray<Face> faces = mFaceDetector.detect(frame);
|
|
-
|
|
- FaceDetectionResult[] faceArray = new FaceDetectionResult[faces.size()];
|
|
- for (int i = 0; i < faces.size(); i++) {
|
|
- faceArray[i] = new FaceDetectionResult();
|
|
- final Face face = faces.valueAt(i);
|
|
-
|
|
- final List<Landmark> landmarks = face.getLandmarks();
|
|
- ArrayList<org.chromium.shape_detection.mojom.Landmark> mojoLandmarks =
|
|
- new ArrayList<org.chromium.shape_detection.mojom.Landmark>(landmarks.size());
|
|
-
|
|
- int leftEyeIndex = -1;
|
|
- int rightEyeIndex = -1;
|
|
- int bottomMouthIndex = -1;
|
|
- for (int j = 0; j < landmarks.size(); j++) {
|
|
- final Landmark landmark = landmarks.get(j);
|
|
- final int landmarkType = landmark.getType();
|
|
- if (landmarkType != Landmark.LEFT_EYE && landmarkType != Landmark.RIGHT_EYE
|
|
- && landmarkType != Landmark.BOTTOM_MOUTH
|
|
- && landmarkType != Landmark.NOSE_BASE) {
|
|
- continue;
|
|
- }
|
|
-
|
|
- org.chromium.shape_detection.mojom.Landmark mojoLandmark =
|
|
- new org.chromium.shape_detection.mojom.Landmark();
|
|
- mojoLandmark.locations = new org.chromium.gfx.mojom.PointF[1];
|
|
- mojoLandmark.locations[0] = new org.chromium.gfx.mojom.PointF();
|
|
- mojoLandmark.locations[0].x = landmark.getPosition().x;
|
|
- mojoLandmark.locations[0].y = landmark.getPosition().y;
|
|
-
|
|
- if (landmarkType == Landmark.LEFT_EYE) {
|
|
- mojoLandmark.type = LandmarkType.EYE;
|
|
- leftEyeIndex = j;
|
|
- } else if (landmarkType == Landmark.RIGHT_EYE) {
|
|
- mojoLandmark.type = LandmarkType.EYE;
|
|
- rightEyeIndex = j;
|
|
- } else if (landmarkType == Landmark.BOTTOM_MOUTH) {
|
|
- mojoLandmark.type = LandmarkType.MOUTH;
|
|
- bottomMouthIndex = j;
|
|
- } else {
|
|
- assert landmarkType == Landmark.NOSE_BASE;
|
|
- mojoLandmark.type = LandmarkType.NOSE;
|
|
- }
|
|
- mojoLandmarks.add(mojoLandmark);
|
|
- }
|
|
- faceArray[i].landmarks = mojoLandmarks.toArray(
|
|
- new org.chromium.shape_detection.mojom.Landmark[mojoLandmarks.size()]);
|
|
-
|
|
- final PointF corner = face.getPosition();
|
|
- faceArray[i].boundingBox = new RectF();
|
|
- if (leftEyeIndex != -1 && rightEyeIndex != -1
|
|
- && Math.abs(face.getEulerZ()) < MAX_EULER_Z) {
|
|
- // Tighter calculation of the bounding box because the GMScore
|
|
- // and Android Face APIs give different results.
|
|
- final PointF leftEyePoint = landmarks.get(leftEyeIndex).getPosition();
|
|
- final PointF rightEyePoint = landmarks.get(rightEyeIndex).getPosition();
|
|
- final float eyesDistance = leftEyePoint.x - rightEyePoint.x;
|
|
- final float eyeMouthDistance = bottomMouthIndex != -1
|
|
- ? landmarks.get(bottomMouthIndex).getPosition().y - leftEyePoint.y
|
|
- : -1;
|
|
- final PointF midEyePoint =
|
|
- new PointF(corner.x + face.getWidth() / 2, leftEyePoint.y);
|
|
- faceArray[i].boundingBox.x = 2 * rightEyePoint.x - midEyePoint.x;
|
|
- faceArray[i].boundingBox.y = midEyePoint.y - eyesDistance;
|
|
- faceArray[i].boundingBox.width = 2 * eyesDistance;
|
|
- faceArray[i].boundingBox.height = eyeMouthDistance > eyesDistance
|
|
- ? eyeMouthDistance + eyesDistance
|
|
- : 2 * eyesDistance;
|
|
- } else {
|
|
- faceArray[i].boundingBox.x = corner.x;
|
|
- faceArray[i].boundingBox.y = corner.y;
|
|
- faceArray[i].boundingBox.width = face.getWidth();
|
|
- faceArray[i].boundingBox.height = face.getHeight();
|
|
- }
|
|
- }
|
|
- callback.call(faceArray);
|
|
+ Log.e(TAG, "FaceDetector is not operational");
|
|
+ callback.call(new FaceDetectionResult[0]);
|
|
}
|
|
|
|
@Override
|
|
public void close() {
|
|
- mFaceDetector.release();
|
|
}
|
|
|
|
@Override
|
|
diff --git a/services/shape_detection/android/java/src/org/chromium/shape_detection/TextDetectionImpl.java b/services/shape_detection/android/java/src/org/chromium/shape_detection/TextDetectionImpl.java
|
|
--- a/services/shape_detection/android/java/src/org/chromium/shape_detection/TextDetectionImpl.java
|
|
+++ b/services/shape_detection/android/java/src/org/chromium/shape_detection/TextDetectionImpl.java
|
|
@@ -8,12 +8,6 @@ import android.graphics.Point;
|
|
import android.graphics.Rect;
|
|
import android.util.SparseArray;
|
|
|
|
-import com.google.android.gms.common.ConnectionResult;
|
|
-import com.google.android.gms.common.GoogleApiAvailability;
|
|
-import com.google.android.gms.vision.Frame;
|
|
-import com.google.android.gms.vision.text.TextBlock;
|
|
-import com.google.android.gms.vision.text.TextRecognizer;
|
|
-
|
|
import org.chromium.base.ContextUtils;
|
|
import org.chromium.base.Log;
|
|
import org.chromium.gfx.mojom.PointF;
|
|
@@ -29,58 +23,17 @@ import org.chromium.shape_detection.mojom.TextDetectionResult;
|
|
public class TextDetectionImpl implements TextDetection {
|
|
private static final String TAG = "TextDetectionImpl";
|
|
|
|
- private TextRecognizer mTextRecognizer;
|
|
-
|
|
public TextDetectionImpl() {
|
|
- mTextRecognizer = new TextRecognizer.Builder(ContextUtils.getApplicationContext()).build();
|
|
}
|
|
|
|
@Override
|
|
public void detect(org.chromium.skia.mojom.Bitmap bitmapData, DetectResponse callback) {
|
|
- // The vision library will be downloaded the first time the API is used
|
|
- // on the device; this happens "fast", but it might have not completed,
|
|
- // bail in this case. Also, the API was disabled between and v.9.0 and
|
|
- // v.9.2, see https://developers.google.com/android/guides/releases.
|
|
- if (!mTextRecognizer.isOperational()) {
|
|
- Log.e(TAG, "TextDetector is not operational");
|
|
- callback.call(new TextDetectionResult[0]);
|
|
- return;
|
|
- }
|
|
-
|
|
- Frame frame = BitmapUtils.convertToFrame(bitmapData);
|
|
- if (frame == null) {
|
|
- Log.e(TAG, "Error converting Mojom Bitmap to Frame");
|
|
- callback.call(new TextDetectionResult[0]);
|
|
- return;
|
|
- }
|
|
-
|
|
- final SparseArray<TextBlock> textBlocks = mTextRecognizer.detect(frame);
|
|
-
|
|
- TextDetectionResult[] detectedTextArray = new TextDetectionResult[textBlocks.size()];
|
|
- for (int i = 0; i < textBlocks.size(); i++) {
|
|
- detectedTextArray[i] = new TextDetectionResult();
|
|
- final TextBlock textBlock = textBlocks.valueAt(i);
|
|
- detectedTextArray[i].rawValue = textBlock.getValue();
|
|
- final Rect rect = textBlock.getBoundingBox();
|
|
- detectedTextArray[i].boundingBox = new RectF();
|
|
- detectedTextArray[i].boundingBox.x = rect.left;
|
|
- detectedTextArray[i].boundingBox.y = rect.top;
|
|
- detectedTextArray[i].boundingBox.width = rect.width();
|
|
- detectedTextArray[i].boundingBox.height = rect.height();
|
|
- final Point[] corners = textBlock.getCornerPoints();
|
|
- detectedTextArray[i].cornerPoints = new PointF[corners.length];
|
|
- for (int j = 0; j < corners.length; j++) {
|
|
- detectedTextArray[i].cornerPoints[j] = new PointF();
|
|
- detectedTextArray[i].cornerPoints[j].x = corners[j].x;
|
|
- detectedTextArray[i].cornerPoints[j].y = corners[j].y;
|
|
- }
|
|
- }
|
|
- callback.call(detectedTextArray);
|
|
+ Log.e(TAG, "TextDetector is not operational");
|
|
+ callback.call(new TextDetectionResult[0]);
|
|
}
|
|
|
|
@Override
|
|
public void close() {
|
|
- mTextRecognizer.release();
|
|
}
|
|
|
|
@Override
|
|
@@ -89,12 +42,7 @@ public class TextDetectionImpl implements TextDetection {
|
|
}
|
|
|
|
public static TextDetection create() {
|
|
- if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
|
|
- ContextUtils.getApplicationContext())
|
|
- != ConnectionResult.SUCCESS) {
|
|
- Log.e(TAG, "Google Play Services not available");
|
|
- return null;
|
|
- }
|
|
- return new TextDetectionImpl();
|
|
+ Log.e(TAG, "Google Play Services not available");
|
|
+ return null;
|
|
}
|
|
}
|
|
diff --git a/third_party/android_deps/BUILD.gn b/third_party/android_deps/BUILD.gn
|
|
--- a/third_party/android_deps/BUILD.gn
|
|
+++ b/third_party/android_deps/BUILD.gn
|
|
@@ -975,35 +975,6 @@ android_aar_prebuilt("google_play_services_tasks_java") {
|
|
strip_drawables = true
|
|
}
|
|
|
|
-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
-android_aar_prebuilt("google_play_services_vision_java") {
|
|
- aar_path = "libs/com_google_android_gms_play_services_vision/play-services-vision-15.0.1.aar"
|
|
- info_path = "libs/com_google_android_gms_play_services_vision/com_google_android_gms_play_services_vision.info"
|
|
- deps = [
|
|
- ":google_play_services_base_java",
|
|
- ":google_play_services_basement_java",
|
|
- ":google_play_services_vision_common_java",
|
|
- ]
|
|
-
|
|
- # Removing drawables from GMS .aars as they are unused bloat.
|
|
- strip_drawables = true
|
|
-}
|
|
-
|
|
-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
-android_aar_prebuilt("google_play_services_vision_common_java") {
|
|
- aar_path = "libs/com_google_android_gms_play_services_vision_common/play-services-vision-common-15.0.1.aar"
|
|
- info_path = "libs/com_google_android_gms_play_services_vision_common/com_google_android_gms_play_services_vision_common.info"
|
|
- deps = [
|
|
- ":google_play_services_base_java",
|
|
- ":google_play_services_basement_java",
|
|
- ":google_play_services_clearcut_java",
|
|
- ":google_play_services_flags_java",
|
|
- ]
|
|
-
|
|
- # Removing drawables from GMS .aars as they are unused bloat.
|
|
- strip_drawables = true
|
|
-}
|
|
-
|
|
# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
android_aar_prebuilt("com_google_android_material_material_java") {
|
|
aar_path = "libs/com_google_android_material_material/material-1.0.0-rc02.aar"
|
|
@@ -1738,60 +1709,6 @@ java_prebuilt("com_github_kevinstern_software_and_algorithms_java") {
|
|
visibility = [ ":*" ]
|
|
}
|
|
|
|
-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
-android_aar_prebuilt("google_play_services_clearcut_java") {
|
|
- aar_path = "libs/com_google_android_gms_play_services_clearcut/play-services-clearcut-15.0.1.aar"
|
|
- info_path = "libs/com_google_android_gms_play_services_clearcut/com_google_android_gms_play_services_clearcut.info"
|
|
-
|
|
- # To remove visibility constraint, add this dependency to
|
|
- # //third_party/android_deps/build.gradle.
|
|
- visibility = [ ":*" ]
|
|
- deps = [
|
|
- ":google_play_services_base_java",
|
|
- ":google_play_services_basement_java",
|
|
- ":google_play_services_phenotype_java",
|
|
- ":google_play_services_tasks_java",
|
|
- ]
|
|
-
|
|
- # Removing drawables from GMS .aars as they are unused bloat.
|
|
- strip_drawables = true
|
|
-}
|
|
-
|
|
-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
-android_aar_prebuilt("google_play_services_flags_java") {
|
|
- aar_path = "libs/com_google_android_gms_play_services_flags/play-services-flags-15.0.1.aar"
|
|
- info_path = "libs/com_google_android_gms_play_services_flags/com_google_android_gms_play_services_flags.info"
|
|
-
|
|
- # To remove visibility constraint, add this dependency to
|
|
- # //third_party/android_deps/build.gradle.
|
|
- visibility = [ ":*" ]
|
|
- deps = [
|
|
- ":google_play_services_base_java",
|
|
- ":google_play_services_basement_java",
|
|
- ]
|
|
-
|
|
- # Removing drawables from GMS .aars as they are unused bloat.
|
|
- strip_drawables = true
|
|
-}
|
|
-
|
|
-# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
-android_aar_prebuilt("google_play_services_phenotype_java") {
|
|
- aar_path = "libs/com_google_android_gms_play_services_phenotype/play-services-phenotype-15.0.1.aar"
|
|
- info_path = "libs/com_google_android_gms_play_services_phenotype/com_google_android_gms_play_services_phenotype.info"
|
|
-
|
|
- # To remove visibility constraint, add this dependency to
|
|
- # //third_party/android_deps/build.gradle.
|
|
- visibility = [ ":*" ]
|
|
- deps = [
|
|
- ":google_play_services_base_java",
|
|
- ":google_play_services_basement_java",
|
|
- ":google_play_services_tasks_java",
|
|
- ]
|
|
-
|
|
- # Removing drawables from GMS .aars as they are unused bloat.
|
|
- strip_drawables = true
|
|
-}
|
|
-
|
|
# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
|
|
android_aar_prebuilt("google_play_services_places_placereport_java") {
|
|
aar_path = "libs/com_google_android_gms_play_services_places_placereport/play-services-places-placereport-15.0.1.aar"
|
|
--
|
|
2.17.1
|
|
|