Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mobile] Remove the legacy mobile_ocr dependency

laurenspriem21666b0d4b1c
diff --git a/mobile/apps/photos/android/app/build.gradle b/mobile/apps/photos/android/app/build.gradle
index a963ffcb28..1eb15bd90a 100644
--- a/mobile/apps/photos/android/app/build.gradle
+++ b/mobile/apps/photos/android/app/build.gradle
@@ -48,12 +48,6 @@ repositories {
}
}
-configurations.configureEach {
- // mobile_ocr also declares Microsoft's stock AAR. The custom AAR exposes
- // the same Java API and must be the sole source of libonnxruntime.so.
- exclude group: 'com.microsoft.onnxruntime', module: 'onnxruntime-android'
-}
-
android {
namespace = "io.ente.photos"
diff --git a/mobile/apps/photos/ios/Podfile.lock b/mobile/apps/photos/ios/Podfile.lock
index fc8336f4d8..db1f1acafe 100644
--- a/mobile/apps/photos/ios/Podfile.lock
+++ b/mobile/apps/photos/ios/Podfile.lock
@@ -156,8 +156,6 @@ PODS:
- Flutter
- media_kit_video (0.0.1):
- Flutter
- - mobile_ocr (0.0.1):
- - Flutter
- motionphoto (0.0.1):
- Flutter
- move_to_background (0.0.1):
@@ -279,7 +277,6 @@ DEPENDENCIES:
- local_auth_darwin (from `.symlinks/plugins/local_auth_darwin/darwin`)
- media_kit_libs_ios_video (from `.symlinks/plugins/media_kit_libs_ios_video/ios`)
- media_kit_video (from `.symlinks/plugins/media_kit_video/ios`)
- - mobile_ocr (from `.symlinks/plugins/mobile_ocr/ios`)
- motionphoto (from `.symlinks/plugins/motionphoto/ios`)
- move_to_background (from `.symlinks/plugins/move_to_background/ios`)
- native_video_editor (from `.symlinks/plugins/native_video_editor/ios`)
@@ -398,8 +395,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/media_kit_libs_ios_video/ios"
media_kit_video:
:path: ".symlinks/plugins/media_kit_video/ios"
- mobile_ocr:
- :path: ".symlinks/plugins/mobile_ocr/ios"
motionphoto:
:path: ".symlinks/plugins/motionphoto/ios"
move_to_background:
@@ -488,7 +483,6 @@ SPEC CHECKSUMS:
Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d
media_kit_libs_ios_video: 5a18affdb97d1f5d466dc79988b13eff6c5e2854
media_kit_video: 1746e198cb697d1ffb734b1d05ec429d1fcd1474
- mobile_ocr: bb5125a6810b4eead3c69778e6b7f3c61fb3c24d
motionphoto: 23e2aeb5c6380112f69468d71f970fa7438e5ed1
move_to_background: 7e3467dd2a1d1013e98c9c1cb93fd53cd7ef9d84
nanopb: fad817b59e0457d11a5dfbde799381cd727c1275
diff --git a/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj b/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj
index c57ea907f9..fd6a51425c 100644
--- a/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj
+++ b/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj
@@ -664,7 +664,6 @@
"${BUILT_PRODUCTS_DIR}/local_auth_darwin/local_auth_darwin.framework",
"${BUILT_PRODUCTS_DIR}/media_kit_libs_ios_video/media_kit_libs_ios_video.framework",
"${BUILT_PRODUCTS_DIR}/media_kit_video/media_kit_video.framework",
- "${BUILT_PRODUCTS_DIR}/mobile_ocr/mobile_ocr.framework",
"${BUILT_PRODUCTS_DIR}/motionphoto/motionphoto.framework",
"${BUILT_PRODUCTS_DIR}/move_to_background/move_to_background.framework",
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
@@ -760,7 +759,6 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/local_auth_darwin.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/media_kit_libs_ios_video.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/media_kit_video.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/mobile_ocr.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/motionphoto.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/move_to_background.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
diff --git a/mobile/apps/photos/lib/services/machine_learning/ocr/legacy_mobile_ocr_backend.dart b/mobile/apps/photos/lib/services/machine_learning/ocr/legacy_mobile_ocr_backend.dart
deleted file mode 100644
index 27746dee51..0000000000
--- a/mobile/apps/photos/lib/services/machine_learning/ocr/legacy_mobile_ocr_backend.dart
+++ /dev/null
@@ -1,102 +0,0 @@
-import "package:mobile_ocr/mobile_ocr.dart" as legacy;
-import "package:photos/services/machine_learning/ocr/ocr_backend.dart";
-import "package:photos/services/machine_learning/ocr/ocr_models.dart";
-
-class LegacyMobileOcrBackend implements OcrBackend {
- final legacy.MobileOcr _ocr = legacy.MobileOcr();
-
- @override
- Future<ModelPreparationStatus> prepareModels(
- Set<OcrModelComponent> components,
- ) {
- return _translate(() async {
- final status = await _ocr.prepareModels(
- components: components
- .map(
- (component) =>
- legacy.OcrModelComponent.values.byName(component.name),
- )
- .toSet(),
- );
- return ModelPreparationStatus(
- isReady: status.isReady,
- version: status.version,
- modelPath: status.modelPath,
- );
- });
- }
-
- @override
- Future<TextDetectionResult> detectText({
- required String imagePath,
- bool includeAllConfidenceScores = false,
- String? requestId,
- }) {
- return _translate(() async {
- final result = await _ocr.detectText(
- imagePath: imagePath,
- includeAllConfidenceScores: includeAllConfidenceScores,
- requestId: requestId,
- );
- return TextDetectionResult(
- blocks: result.blocks.map(_toTextBlock).toList(growable: false),
- imageSize: result.imageSize,
- );
- });
- }
-
- @override
- Future<TextRegionDetectionResult> detectTextRegions({
- required String imagePath,
- String? requestId,
- }) {
- return _translate(() async {
- final result = await _ocr.detectTextRegions(
- imagePath: imagePath,
- requestId: requestId,
- );
- return TextRegionDetectionResult(
- regions: result.regions.map(_toTextRegion).toList(growable: false),
- imageSize: result.imageSize,
- );
- });
- }
-
- @override
- Future<void> cancelRequest(String requestId) {
- return _translate(() => _ocr.cancelRequest(requestId));
- }
-
- @override
- Future<String> ensureDisplayablePath(String imagePath) {
- return legacy.DisplayImageHelper.ensureDisplayablePath(imagePath);
- }
-
- Future<T> _translate<T>(Future<T> Function() operation) async {
- try {
- return await operation();
- } on legacy.OcrException catch (error) {
- throw OcrException(
- code: error.code,
- message: error.message,
- details: error.details,
- );
- }
- }
-
- TextBlock _toTextBlock(legacy.TextBlock block) => TextBlock(
- text: block.text,
- confidence: block.confidence,
- points: block.points,
- characters: block.characters.map(_toCharacterBox).toList(growable: false),
- );
-
- CharacterBox _toCharacterBox(legacy.CharacterBox character) => CharacterBox(
- text: character.text,
- confidence: character.confidence,
- points: character.points,
- );
-
- TextRegion _toTextRegion(legacy.TextRegion region) =>
- TextRegion(confidence: region.confidence, points: region.points);
-}
diff --git a/mobile/apps/photos/pubspec.yaml b/mobile/apps/photos/pubspec.yaml
index 6812f67fff..dae990013c 100644
--- a/mobile/apps/photos/pubspec.yaml
+++ b/mobile/apps/photos/pubspec.yaml
@@ -149,10 +149,6 @@ dependencies:
media_kit_video: 2.0.0
mesh_gradient: 1.3.8
ml_linalg: 13.12.6
- mobile_ocr:
- git:
- url: https://github.com/ente/mobile_ocr
- ref: 0c68f88f20607cfcb10286422860350ccb024acd
modal_bottom_sheet: 3.0.0
motionphoto:
git:
diff --git a/mobile/pubspec.lock b/mobile/pubspec.lock
index bd5ebb379a..ebbcb651d6 100644
--- a/mobile/pubspec.lock
+++ b/mobile/pubspec.lock
@@ -1712,15 +1712,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "13.12.6"
- mobile_ocr:
- dependency: transitive
- description:
- path: "."
- ref: "0c68f88f20607cfcb10286422860350ccb024acd"
- resolved-ref: "0c68f88f20607cfcb10286422860350ccb024acd"
- url: "https://github.com/ente/mobile_ocr"
- source: git
- version: "1.0.0"
mockito:
dependency: transitive
description: