diff --git a/android/build.gradle b/android/build.gradle index 4e9e193..3233fd7 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -32,7 +32,8 @@ rootProject.allprojects { apply plugin: 'com.android.library' android { - compileSdkVersion 31 + namespace "com.vladih.computer_vision.flutter_vision" + compileSdkVersion 35 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 diff --git a/android/src/main/java/com/vladih/computer_vision/flutter_vision/FlutterVisionPlugin.java b/android/src/main/java/com/vladih/computer_vision/flutter_vision/FlutterVisionPlugin.java index 5a71fa0..e1e9047 100644 --- a/android/src/main/java/com/vladih/computer_vision/flutter_vision/FlutterVisionPlugin.java +++ b/android/src/main/java/com/vladih/computer_vision/flutter_vision/FlutterVisionPlugin.java @@ -171,13 +171,20 @@ private void close_ocr_model(Result result) { } private void load_yolo_model(Map args) throws Exception { - final String model = this.assets.getAssetFilePathByName(args.get("model_path").toString()); - final Object is_asset_obj = args.get("is_asset"); + String model = ""; + final Object is_asset_obj = args.get("is_asset"); final boolean is_asset = is_asset_obj == null ? false : (boolean) is_asset_obj; + String label_path = ""; + if(is_asset){ + model = this.assets.getAssetFilePathByName(args.get("model_path").toString()); + label_path = this.assets.getAssetFilePathByName(args.get("label_path").toString()); + }else{ + model = args.get("model_path").toString(); + label_path = args.get("label_path").toString(); + } final int num_threads = (int) args.get("num_threads"); final boolean quantization = (boolean) args.get("quantization"); final boolean use_gpu = (boolean) args.get("use_gpu"); - final String label_path = this.assets.getAssetFilePathByName(args.get("label_path").toString()); final int rotation = (int) args.get("rotation"); final String version = args.get("model_version").toString(); switch (version) { diff --git a/lib/flutter_vision.dart b/lib/flutter_vision.dart index 993d8ca..9081d1f 100644 --- a/lib/flutter_vision.dart +++ b/lib/flutter_vision.dart @@ -94,6 +94,7 @@ abstract class FlutterVision { required String modelVersion, bool? quantization, int? numThreads, + bool? is_asset, bool? useGpu}); ///yoloOnFrame accept a byte List as input and diff --git a/lib/src/plugin/android.dart b/lib/src/plugin/android.dart index c13f298..eedd97f 100644 --- a/lib/src/plugin/android.dart +++ b/lib/src/plugin/android.dart @@ -87,11 +87,12 @@ class AndroidFlutterVision extends BaseFlutterVision implements FlutterVision { required String modelVersion, bool? quantization, int? numThreads, + bool? is_asset, bool? useGpu}) async { try { await channel.invokeMethod('loadYoloModel', { 'model_path': modelPath, - 'is_asset': true, + 'is_asset': is_asset ?? false, 'quantization': quantization ?? false, 'num_threads': numThreads ?? 1, 'use_gpu': useGpu ?? false, diff --git a/lib/src/plugin/base.dart b/lib/src/plugin/base.dart index 0245f4d..20808b5 100644 --- a/lib/src/plugin/base.dart +++ b/lib/src/plugin/base.dart @@ -70,6 +70,7 @@ abstract class BaseFlutterVision { bool? quantization, int? numThreads, bool? useGpu, + bool? is_asset, }); Future>> yoloOnFrame({ diff --git a/pubspec.yaml b/pubspec.yaml index e1cbb82..4fb4a9a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: flutter_vision description: Plugin for managing Yolov5, Yolov8 and Tesseract v5 accessing with TensorFlow Lite 2.x. Support object detection, segmentation and OCR on Android. iOS, Working in progress. -version: 1.1.4 +version: 1.1.6 homepage: https://github.com/vladiH/flutter_vision @@ -12,11 +12,11 @@ environment: dependencies: flutter: sdk: flutter - path: ^1.8.1 - path_provider: ^2.0.11 + path: ^1.9.0 + path_provider: ^2.1.4 dev_dependencies: - flutter_lints: ^2.0.1 + flutter_lints: ^5.0.0 flutter_test: sdk: flutter # For information on the generic Dart part of this file, see the