Showing preview only (4,253K chars total). Download the full file or copy to clipboard to get everything.
Repository: googlesamples/mlkit
Branch: master
Commit: 3bdf01826657
Files: 867
Total size: 3.9 MB
Directory structure:
gitextract_e0cwqdyw/
├── .github/
│ └── ISSUE_TEMPLATE/
│ ├── bug_report.md
│ └── feature_request.md
├── .gitignore
├── LICENSE
├── README.md
├── android/
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── android-snippets/
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── example/
│ │ │ │ └── mlkit/
│ │ │ │ ├── BarcodeScanningActivity.java
│ │ │ │ ├── FaceDetectionActivity.java
│ │ │ │ ├── ImageLabelingActivity.java
│ │ │ │ ├── LanguageIdentificationActivity.java
│ │ │ │ ├── MLKitVisionImage.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── ObjectDetectionActivity.java
│ │ │ │ ├── TextRecognitionActivity.java
│ │ │ │ └── kotlin/
│ │ │ │ ├── BarcodeScanningActivity.kt
│ │ │ │ ├── FaceDetectionActivity.kt
│ │ │ │ ├── ImageLabelingActivity.kt
│ │ │ │ ├── LanguageIdentificationActivity.kt
│ │ │ │ ├── MLKitVisionImage.kt
│ │ │ │ ├── MainActivity.kt
│ │ │ │ ├── ObjectDetectionActivity.kt
│ │ │ │ └── TextRecognitionActivity.kt
│ │ │ └── res/
│ │ │ ├── layout/
│ │ │ │ └── activity_main.xml
│ │ │ ├── values/
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ └── values-w820dp/
│ │ │ └── dimens.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── automl/
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── vision/
│ │ │ │ └── automl/
│ │ │ │ └── demo/
│ │ │ │ ├── BitmapUtils.java
│ │ │ │ ├── CameraImageGraphic.java
│ │ │ │ ├── CameraSource.java
│ │ │ │ ├── CameraSourcePreview.java
│ │ │ │ ├── CameraXLivePreviewActivity.java
│ │ │ │ ├── CameraXViewModel.java
│ │ │ │ ├── ChooserActivity.java
│ │ │ │ ├── FrameMetadata.java
│ │ │ │ ├── GraphicOverlay.java
│ │ │ │ ├── InferenceInfoGraphic.java
│ │ │ │ ├── LivePreviewActivity.java
│ │ │ │ ├── ScopedExecutor.java
│ │ │ │ ├── StillImageActivity.java
│ │ │ │ ├── VisionImageProcessor.java
│ │ │ │ ├── VisionProcessorBase.java
│ │ │ │ ├── automl/
│ │ │ │ │ ├── AutoMLImageLabelerProcessor.java
│ │ │ │ │ └── LabelGraphic.java
│ │ │ │ ├── object/
│ │ │ │ │ ├── ObjectDetectorProcessor.java
│ │ │ │ │ └── ObjectGraphic.java
│ │ │ │ └── preference/
│ │ │ │ ├── CameraXLivePreviewPreferenceFragment.java
│ │ │ │ ├── LivePreviewPreferenceFragment.java
│ │ │ │ ├── PreferenceUtils.java
│ │ │ │ ├── SettingsActivity.java
│ │ │ │ └── StillImagePreferenceFragment.java
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ └── logo_mlkit.xml
│ │ │ ├── drawable-hdpi/
│ │ │ │ └── ic_switch_camera_white_48dp.xml
│ │ │ ├── drawable-mdpi/
│ │ │ │ └── ic_switch_camera_white_48dp.xml
│ │ │ ├── drawable-xhdpi/
│ │ │ │ └── ic_switch_camera_white_48dp.xml
│ │ │ ├── drawable-xxhdpi/
│ │ │ │ └── ic_switch_camera_white_48dp.xml
│ │ │ ├── drawable-xxxhdpi/
│ │ │ │ └── ic_switch_camera_white_48dp.xml
│ │ │ ├── layout/
│ │ │ │ ├── activity_camerax_live_preview.xml
│ │ │ │ ├── activity_chooser.xml
│ │ │ │ ├── activity_live_preview.xml
│ │ │ │ ├── activity_settings.xml
│ │ │ │ ├── activity_still_image.xml
│ │ │ │ ├── settings_style.xml
│ │ │ │ ├── spinner_style.xml
│ │ │ │ └── toggle_style.xml
│ │ │ ├── layout-land/
│ │ │ │ ├── activity_camerax_live_preview.xml
│ │ │ │ └── activity_live_preview.xml
│ │ │ ├── menu/
│ │ │ │ └── camera_button_menu.xml
│ │ │ ├── values/
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ └── xml/
│ │ │ ├── preference_live_preview_automl.xml
│ │ │ └── preference_still_image.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── codescanner/
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── samples/
│ │ │ │ └── codescanner/
│ │ │ │ ├── EntryChoiceActivity.kt
│ │ │ │ ├── java/
│ │ │ │ │ └── MainActivity.java
│ │ │ │ └── kotlin/
│ │ │ │ └── MainActivity.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ └── logo_mlkit.xml
│ │ │ ├── layout/
│ │ │ │ └── activity_main.xml
│ │ │ └── values/
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── digitalink/
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── samples/
│ │ │ │ └── vision/
│ │ │ │ └── digitalink/
│ │ │ │ └── recognition/
│ │ │ │ ├── DigitalInkMainActivity.java
│ │ │ │ ├── DrawingView.java
│ │ │ │ ├── ModelManager.java
│ │ │ │ ├── RecognitionTask.java
│ │ │ │ ├── StatusTextView.java
│ │ │ │ ├── StrokeManager.java
│ │ │ │ └── kotlin/
│ │ │ │ ├── DigitalInkMainActivity.kt
│ │ │ │ ├── DrawingView.kt
│ │ │ │ ├── ModelManager.kt
│ │ │ │ ├── RecognitionTask.kt
│ │ │ │ ├── StatusTextView.kt
│ │ │ │ └── StrokeManager.kt
│ │ │ └── res/
│ │ │ ├── layout/
│ │ │ │ ├── activity_digital_ink_main.xml
│ │ │ │ └── activity_digital_ink_main_kotlin.xml
│ │ │ └── values/
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── documentscanner/
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── samples/
│ │ │ │ └── documentscanner/
│ │ │ │ ├── EntryChoiceActivity.kt
│ │ │ │ ├── java/
│ │ │ │ │ └── MainActivity.java
│ │ │ │ └── kotlin/
│ │ │ │ └── MainActivity.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ └── logo_mlkit.xml
│ │ │ ├── layout/
│ │ │ │ └── activity_main.xml
│ │ │ ├── values/
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ └── xml/
│ │ │ └── file_paths.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── entityextraction/
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── samples/
│ │ │ │ └── nl/
│ │ │ │ └── entityextraction/
│ │ │ │ ├── EntryChoiceActivity.kt
│ │ │ │ ├── java/
│ │ │ │ │ ├── MainActivityJava.java
│ │ │ │ │ └── ModelsActivityJava.java
│ │ │ │ └── kotlin/
│ │ │ │ ├── MainActivityKotlin.kt
│ │ │ │ └── ModelsActivityKotlin.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ ├── ic_baseline_delete_gray_32.xml
│ │ │ │ ├── ic_baseline_get_app_gray_32.xml
│ │ │ │ ├── ic_baseline_get_app_white_32.xml
│ │ │ │ └── logo_mlkit.xml
│ │ │ ├── layout/
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── activity_models.xml
│ │ │ │ └── list_item.xml
│ │ │ ├── menu/
│ │ │ │ └── menu_choose_model.xml
│ │ │ └── values/
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── build.gradle
│ │ ├── gradle.properties
│ │ └── settings.gradle
│ ├── genai/
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── genai/
│ │ │ │ └── demo/
│ │ │ │ ├── ContentAdapter.kt
│ │ │ │ ├── ContentItem.kt
│ │ │ │ ├── EntryChoiceActivity.kt
│ │ │ │ ├── GenerationConfigDialog.kt
│ │ │ │ ├── GenerationConfigUtils.kt
│ │ │ │ ├── java/
│ │ │ │ │ ├── BaseActivity.java
│ │ │ │ │ ├── ImageDescriptionActivity.java
│ │ │ │ │ ├── OpenPromptActivity.java
│ │ │ │ │ ├── ProofreadingActivity.java
│ │ │ │ │ ├── RewritingActivity.java
│ │ │ │ │ ├── SummarizationActivity.java
│ │ │ │ │ └── TextInputBaseActivity.java
│ │ │ │ └── kotlin/
│ │ │ │ ├── BaseActivity.kt
│ │ │ │ ├── ImageDescriptionActivity.kt
│ │ │ │ ├── OpenPromptActivity.kt
│ │ │ │ ├── ProofreadingActivity.kt
│ │ │ │ ├── RewritingActivity.kt
│ │ │ │ ├── SummarizationActivity.kt
│ │ │ │ └── TextInputBaseActivity.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ ├── edit_text_background_chat.xml
│ │ │ │ ├── ic_add_photo.xml
│ │ │ │ ├── ic_send.xml
│ │ │ │ ├── list_item_background.xml
│ │ │ │ ├── request_item_background.xml
│ │ │ │ └── response_item_background.xml
│ │ │ ├── layout/
│ │ │ │ ├── activity_entry_choice.xml
│ │ │ │ ├── activity_image_description.xml
│ │ │ │ ├── activity_openprompt.xml
│ │ │ │ ├── activity_proofreading.xml
│ │ │ │ ├── activity_rewrite.xml
│ │ │ │ ├── activity_summarization.xml
│ │ │ │ ├── dialog_generation_config.xml
│ │ │ │ ├── entry_choice_item.xml
│ │ │ │ ├── row_item_request_image.xml
│ │ │ │ ├── row_item_request_text.xml
│ │ │ │ ├── row_item_request_text_and_images.xml
│ │ │ │ └── row_item_response.xml
│ │ │ ├── menu/
│ │ │ │ └── menu_main.xml
│ │ │ └── values/
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── themes.xml
│ │ ├── build.gradle
│ │ ├── gradle.properties
│ │ └── settings.gradle
│ ├── internal/
│ │ ├── chooserx/
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── mlkit/
│ │ │ │ └── example/
│ │ │ │ └── internal/
│ │ │ │ ├── BaseEntryChoiceActivity.java
│ │ │ │ ├── Choice.java
│ │ │ │ └── ChoiceAdapter.java
│ │ │ └── res/
│ │ │ └── layout/
│ │ │ ├── activity_entry_choice.xml
│ │ │ └── item_choice.xml
│ │ ├── lint/
│ │ │ ├── build.gradle
│ │ │ ├── gradle/
│ │ │ │ └── wrapper/
│ │ │ │ ├── gradle-wrapper.jar
│ │ │ │ └── gradle-wrapper.properties
│ │ │ ├── gradlew
│ │ │ ├── gradlew.bat
│ │ │ └── src/
│ │ │ ├── main/
│ │ │ │ └── java/
│ │ │ │ └── com/
│ │ │ │ └── mlkit/
│ │ │ │ └── lint/
│ │ │ │ ├── HungarianNotationDetector.kt
│ │ │ │ ├── InvalidImportDetector.kt
│ │ │ │ └── QuickstartIssueRegistry.kt
│ │ │ └── test/
│ │ │ └── java/
│ │ │ └── com/
│ │ │ └── mlkit/
│ │ │ └── lint/
│ │ │ └── InvalidImportDetectorTest.kt
│ │ └── lintchecks/
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ ├── proguard-rules.pro
│ │ └── src/
│ │ └── main/
│ │ └── AndroidManifest.xml
│ ├── langid/
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── samples/
│ │ │ │ └── nl/
│ │ │ │ └── languageid/
│ │ │ │ ├── EntryChoiceActivity.kt
│ │ │ │ ├── java/
│ │ │ │ │ └── MainActivityJava.java
│ │ │ │ └── kotlin/
│ │ │ │ └── MainActivityKotlin.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ └── logo_mlkit.xml
│ │ │ ├── layout/
│ │ │ │ └── activity_main.xml
│ │ │ └── values/
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── material-showcase/
│ │ ├── .editorconfig
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── assets/
│ │ │ │ └── custom_models/
│ │ │ │ └── bird_classifier.tflite
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── md/
│ │ │ │ ├── CustomModelObjectDetectionActivity.kt
│ │ │ │ ├── InputInfo.kt
│ │ │ │ ├── LiveBarcodeScanningActivity.kt
│ │ │ │ ├── LiveObjectDetectionActivity.kt
│ │ │ │ ├── MainActivity.kt
│ │ │ │ ├── ScopedExecutor.kt
│ │ │ │ ├── StaticObjectDetectionActivity.kt
│ │ │ │ ├── TaskExt.kt
│ │ │ │ ├── Utils.kt
│ │ │ │ ├── barcodedetection/
│ │ │ │ │ ├── BarcodeConfirmingGraphic.kt
│ │ │ │ │ ├── BarcodeField.kt
│ │ │ │ │ ├── BarcodeFieldAdapter.kt
│ │ │ │ │ ├── BarcodeGraphicBase.kt
│ │ │ │ │ ├── BarcodeLoadingGraphic.kt
│ │ │ │ │ ├── BarcodeProcessor.kt
│ │ │ │ │ ├── BarcodeResultFragment.kt
│ │ │ │ │ └── BarcodeReticleGraphic.kt
│ │ │ │ ├── camera/
│ │ │ │ │ ├── CameraReticleAnimator.kt
│ │ │ │ │ ├── CameraSizePair.kt
│ │ │ │ │ ├── CameraSource.kt
│ │ │ │ │ ├── CameraSourcePreview.kt
│ │ │ │ │ ├── FrameMetadata.kt
│ │ │ │ │ ├── FrameProcessor.kt
│ │ │ │ │ ├── FrameProcessorBase.kt
│ │ │ │ │ ├── GraphicOverlay.kt
│ │ │ │ │ └── WorkflowModel.kt
│ │ │ │ ├── objectdetection/
│ │ │ │ │ ├── DetectedObjectInfo.kt
│ │ │ │ │ ├── MultiObjectProcessor.kt
│ │ │ │ │ ├── ObjectConfirmationController.kt
│ │ │ │ │ ├── ObjectConfirmationGraphic.kt
│ │ │ │ │ ├── ObjectDotAnimator.kt
│ │ │ │ │ ├── ObjectDotGraphic.kt
│ │ │ │ │ ├── ObjectGraphicInMultiMode.kt
│ │ │ │ │ ├── ObjectGraphicInProminentMode.kt
│ │ │ │ │ ├── ObjectReticleGraphic.kt
│ │ │ │ │ ├── ProminentObjectProcessor.kt
│ │ │ │ │ └── StaticObjectDotView.kt
│ │ │ │ ├── productsearch/
│ │ │ │ │ ├── BottomSheetScrimView.kt
│ │ │ │ │ ├── ImageDownloadTask.kt
│ │ │ │ │ ├── PreviewCardAdapter.kt
│ │ │ │ │ ├── Product.kt
│ │ │ │ │ ├── ProductAdapter.kt
│ │ │ │ │ ├── SearchEngine.kt
│ │ │ │ │ └── SearchedObject.kt
│ │ │ │ └── settings/
│ │ │ │ ├── PreferenceUtils.kt
│ │ │ │ ├── SettingsActivity.kt
│ │ │ │ └── SettingsFragment.kt
│ │ │ └── res/
│ │ │ ├── animator/
│ │ │ │ ├── bottom_prompt_chip_enter.xml
│ │ │ │ ├── search_button_enter.xml
│ │ │ │ └── static_image_dot_enter.xml
│ │ │ ├── drawable/
│ │ │ │ ├── barcode_field_box.xml
│ │ │ │ ├── camera_flash.xml
│ │ │ │ ├── ic_close_vd_white_24.xml
│ │ │ │ ├── ic_flash_off_vd_white_24.xml
│ │ │ │ ├── ic_flash_on_vd_white_24.xml
│ │ │ │ ├── ic_image_search_vd_black_24.xml
│ │ │ │ ├── ic_launcher_background.xml
│ │ │ │ ├── ic_photo_library_vd_white_24.xml
│ │ │ │ ├── ic_settings_vd_white_24.xml
│ │ │ │ ├── logo_mlkit.xml
│ │ │ │ └── top_action_bar_scrim.xml
│ │ │ ├── layout/
│ │ │ │ ├── activity_live_barcode.xml
│ │ │ │ ├── activity_live_object.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── activity_settings.xml
│ │ │ │ ├── activity_static_object.xml
│ │ │ │ ├── barcode_bottom_sheet.xml
│ │ │ │ ├── barcode_field.xml
│ │ │ │ ├── camera_preview_overlay.xml
│ │ │ │ ├── detection_mode_item.xml
│ │ │ │ ├── product_bottom_sheet.xml
│ │ │ │ ├── product_item.xml
│ │ │ │ ├── products_preview_card.xml
│ │ │ │ ├── top_action_bar_in_live_camera.xml
│ │ │ │ └── top_action_bar_in_static_image.xml
│ │ │ ├── values/
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ ├── values-v21/
│ │ │ │ └── styles.xml
│ │ │ └── xml/
│ │ │ └── preferences.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── smartreply/
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── samples/
│ │ │ │ └── nl/
│ │ │ │ └── smartreply/
│ │ │ │ ├── EntryChoiceActivity.kt
│ │ │ │ ├── java/
│ │ │ │ │ ├── MainActivityJava.java
│ │ │ │ │ ├── chat/
│ │ │ │ │ │ ├── ChatFragment.java
│ │ │ │ │ │ ├── ChatViewModel.java
│ │ │ │ │ │ ├── MessageListAdapter.java
│ │ │ │ │ │ └── ReplyChipAdapter.java
│ │ │ │ │ └── model/
│ │ │ │ │ └── Message.java
│ │ │ │ └── kotlin/
│ │ │ │ ├── MainActivityKotlin.kt
│ │ │ │ ├── chat/
│ │ │ │ │ ├── ChatFragment.kt
│ │ │ │ │ ├── ChatViewModel.kt
│ │ │ │ │ ├── MessageListAdapter.kt
│ │ │ │ │ └── ReplyChipAdapter.kt
│ │ │ │ └── model/
│ │ │ │ └── Message.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ ├── ic_camera_front_black_24dp.xml
│ │ │ │ ├── ic_launcher_background.xml
│ │ │ │ ├── ic_tag_faces_black_24dp.xml
│ │ │ │ ├── logo_mlkit.xml
│ │ │ │ ├── rounded_rectangle_blue.xml
│ │ │ │ ├── rounded_rectangle_gray.xml
│ │ │ │ └── rounded_rectangle_light_gray.xml
│ │ │ ├── drawable-v24/
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── layout/
│ │ │ │ ├── chat_fragment.xml
│ │ │ │ ├── item_message_local.xml
│ │ │ │ ├── item_message_remote.xml
│ │ │ │ ├── main_smartreply_activity.xml
│ │ │ │ └── smart_reply_chip.xml
│ │ │ ├── menu/
│ │ │ │ └── chat_fragment_actions.xml
│ │ │ └── values/
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── speech/
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── genai/
│ │ │ │ └── speech/
│ │ │ │ └── demo/
│ │ │ │ └── SpeechRecognitionActivity.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ ├── ic_launcher_background.xml
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── layout/
│ │ │ │ └── activity_speech_recognition.xml
│ │ │ ├── mipmap-anydpi/
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ └── values/
│ │ │ ├── arrays.xml
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── themes.xml
│ │ ├── build.gradle
│ │ ├── gradle.properties
│ │ └── settings.gradle
│ ├── translate/
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── samples/
│ │ │ │ └── nl/
│ │ │ │ └── translate/
│ │ │ │ ├── EntryChoiceActivity.kt
│ │ │ │ ├── java/
│ │ │ │ │ ├── MainActivity.java
│ │ │ │ │ ├── TranslateFragment.java
│ │ │ │ │ └── TranslateViewModel.java
│ │ │ │ └── kotlin/
│ │ │ │ ├── MainActivity.kt
│ │ │ │ ├── TranslateFragment.kt
│ │ │ │ └── TranslateViewModel.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ ├── ic_baseline_delete_24.xml
│ │ │ │ ├── ic_baseline_translate_32.xml
│ │ │ │ ├── ic_compare_arrows_black_24dp.xml
│ │ │ │ ├── ic_file_download_white_24dp.xml
│ │ │ │ └── logo_mlkit.xml
│ │ │ ├── layout/
│ │ │ │ ├── activity_translate_main.xml
│ │ │ │ └── translate_fragment.xml
│ │ │ └── values/
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── translate-showcase/
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── showcase/
│ │ │ │ └── translate/
│ │ │ │ ├── MainActivity.kt
│ │ │ │ ├── analyzer/
│ │ │ │ │ └── TextAnalyzer.kt
│ │ │ │ ├── main/
│ │ │ │ │ ├── MainFragment.kt
│ │ │ │ │ └── MainViewModel.kt
│ │ │ │ └── util/
│ │ │ │ ├── ImageUtils.kt
│ │ │ │ ├── Language.kt
│ │ │ │ ├── ResultOrError.kt
│ │ │ │ ├── ScopedExecutor.kt
│ │ │ │ └── SmoothedMutableLiveData.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ └── logo_mlkit.xml
│ │ │ ├── layout/
│ │ │ │ ├── main_fragment.xml
│ │ │ │ └── main_translateshowcase_activity.xml
│ │ │ └── values/
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ └── vision-quickstart/
│ ├── LICENSE
│ ├── README.md
│ ├── app/
│ │ ├── build.gradle
│ │ └── src/
│ │ └── main/
│ │ ├── AndroidManifest.xml
│ │ ├── assets/
│ │ │ ├── automl/
│ │ │ │ ├── dict.txt
│ │ │ │ ├── manifest.json
│ │ │ │ └── model.tflite
│ │ │ ├── custom_models/
│ │ │ │ ├── bird_classifier.tflite
│ │ │ │ └── object_labeler.tflite
│ │ │ └── pose/
│ │ │ └── fitness_pose_samples.csv
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── google/
│ │ │ └── mlkit/
│ │ │ └── vision/
│ │ │ └── demo/
│ │ │ ├── BitmapUtils.java
│ │ │ ├── CameraImageGraphic.java
│ │ │ ├── CameraSource.java
│ │ │ ├── CameraSourcePreview.java
│ │ │ ├── CameraXViewModel.java
│ │ │ ├── EntryChoiceActivity.kt
│ │ │ ├── FrameMetadata.java
│ │ │ ├── GraphicOverlay.java
│ │ │ ├── InferenceInfoGraphic.java
│ │ │ ├── ScopedExecutor.java
│ │ │ ├── TemperatureMonitor.java
│ │ │ ├── VisionImageProcessor.java
│ │ │ ├── java/
│ │ │ │ ├── CameraXLivePreviewActivity.java
│ │ │ │ ├── CameraXSourceDemoActivity.java
│ │ │ │ ├── ChooserActivity.java
│ │ │ │ ├── LivePreviewActivity.java
│ │ │ │ ├── StillImageActivity.java
│ │ │ │ ├── VisionProcessorBase.java
│ │ │ │ ├── barcodescanner/
│ │ │ │ │ ├── BarcodeGraphic.java
│ │ │ │ │ └── BarcodeScannerProcessor.java
│ │ │ │ ├── facedetector/
│ │ │ │ │ ├── FaceDetectorProcessor.java
│ │ │ │ │ └── FaceGraphic.java
│ │ │ │ ├── facemeshdetector/
│ │ │ │ │ ├── FaceMeshDetectorProcessor.java
│ │ │ │ │ └── FaceMeshGraphic.java
│ │ │ │ ├── labeldetector/
│ │ │ │ │ ├── LabelDetectorProcessor.java
│ │ │ │ │ └── LabelGraphic.java
│ │ │ │ ├── objectdetector/
│ │ │ │ │ ├── ObjectDetectorProcessor.java
│ │ │ │ │ └── ObjectGraphic.java
│ │ │ │ ├── posedetector/
│ │ │ │ │ ├── PoseDetectorProcessor.java
│ │ │ │ │ ├── PoseGraphic.java
│ │ │ │ │ └── classification/
│ │ │ │ │ ├── ClassificationResult.java
│ │ │ │ │ ├── EMASmoothing.java
│ │ │ │ │ ├── PoseClassifier.java
│ │ │ │ │ ├── PoseClassifierProcessor.java
│ │ │ │ │ ├── PoseEmbedding.java
│ │ │ │ │ ├── PoseSample.java
│ │ │ │ │ ├── RepetitionCounter.java
│ │ │ │ │ └── Utils.java
│ │ │ │ ├── segmenter/
│ │ │ │ │ ├── SegmentationGraphic.java
│ │ │ │ │ └── SegmenterProcessor.java
│ │ │ │ ├── subjectsegmenter/
│ │ │ │ │ ├── SubjectSegmentationGraphic.java
│ │ │ │ │ └── SubjectSegmenterProcessor.java
│ │ │ │ └── textdetector/
│ │ │ │ ├── TextGraphic.java
│ │ │ │ └── TextRecognitionProcessor.java
│ │ │ ├── kotlin/
│ │ │ │ ├── CameraXLivePreviewActivity.kt
│ │ │ │ ├── CameraXSourceDemoActivity.kt
│ │ │ │ ├── ChooserActivity.kt
│ │ │ │ ├── LivePreviewActivity.kt
│ │ │ │ ├── StillImageActivity.kt
│ │ │ │ ├── TaskExt.kt
│ │ │ │ ├── VisionProcessorBase.kt
│ │ │ │ ├── barcodescanner/
│ │ │ │ │ ├── BarcodeGraphic.kt
│ │ │ │ │ └── BarcodeScannerProcessor.kt
│ │ │ │ ├── facedetector/
│ │ │ │ │ ├── FaceDetectorProcessor.kt
│ │ │ │ │ └── FaceGraphic.kt
│ │ │ │ ├── facemeshdetector/
│ │ │ │ │ ├── FaceMeshDetectorProcessor.kt
│ │ │ │ │ └── FaceMeshGraphic.kt
│ │ │ │ ├── labeldetector/
│ │ │ │ │ ├── LabelDetectorProcessor.kt
│ │ │ │ │ └── LabelGraphic.kt
│ │ │ │ ├── objectdetector/
│ │ │ │ │ ├── ObjectDetectorProcessor.kt
│ │ │ │ │ └── ObjectGraphic.kt
│ │ │ │ ├── posedetector/
│ │ │ │ │ ├── PoseDetectorProcessor.kt
│ │ │ │ │ └── PoseGraphic.kt
│ │ │ │ ├── segmenter/
│ │ │ │ │ ├── SegmentationGraphic.kt
│ │ │ │ │ └── SegmenterProcessor.kt
│ │ │ │ ├── subjectsegmenter/
│ │ │ │ │ ├── SubjectSegmentationGraphic.kt
│ │ │ │ │ └── SubjectSegmenterProcessor.kt
│ │ │ │ └── textdetector/
│ │ │ │ ├── TextGraphic.kt
│ │ │ │ └── TextRecognitionProcessor.kt
│ │ │ └── preference/
│ │ │ ├── CameraXLivePreviewPreferenceFragment.java
│ │ │ ├── CameraXSourceDemoPreferenceFragment.java
│ │ │ ├── LivePreviewPreferenceFragment.java
│ │ │ ├── PreferenceUtils.java
│ │ │ ├── SettingsActivity.java
│ │ │ └── StillImagePreferenceFragment.java
│ │ └── res/
│ │ ├── drawable/
│ │ │ ├── list_item_background.xml
│ │ │ └── logo_mlkit.xml
│ │ ├── drawable-hdpi/
│ │ │ └── ic_switch_camera_white_48dp.xml
│ │ ├── drawable-mdpi/
│ │ │ └── ic_switch_camera_white_48dp.xml
│ │ ├── drawable-xhdpi/
│ │ │ └── ic_switch_camera_white_48dp.xml
│ │ ├── drawable-xxhdpi/
│ │ │ └── ic_switch_camera_white_48dp.xml
│ │ ├── drawable-xxxhdpi/
│ │ │ └── ic_switch_camera_white_48dp.xml
│ │ ├── layout/
│ │ │ ├── activity_chooser.xml
│ │ │ ├── activity_settings.xml
│ │ │ ├── activity_still_image.xml
│ │ │ ├── activity_vision_camerax_live_preview.xml
│ │ │ ├── activity_vision_cameraxsource_demo.xml
│ │ │ ├── activity_vision_entry_choice.xml
│ │ │ ├── activity_vision_live_preview.xml
│ │ │ ├── settings_style.xml
│ │ │ ├── spinner_style.xml
│ │ │ └── toggle_style.xml
│ │ ├── layout-land/
│ │ │ ├── activity_vision_camerax_live_preview.xml
│ │ │ ├── activity_vision_cameraxsource_demo.xml
│ │ │ └── activity_vision_live_preview.xml
│ │ ├── menu/
│ │ │ └── camera_button_menu.xml
│ │ ├── values/
│ │ │ ├── arrays.xml
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── xml/
│ │ ├── preference_live_preview_quickstart.xml
│ │ └── preference_still_image.xml
│ ├── build.gradle
│ ├── gradle/
│ │ └── wrapper/
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradle.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── ios/
│ ├── ios-snippets/
│ │ ├── Podfile
│ │ ├── mlkit-snippets.xcodeproj/
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace/
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ └── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ └── dfurlong.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ └── xcschememanagement.plist
│ │ ├── mlkit-snippets.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ └── dfurlong.xcuserdatad/
│ │ │ └── xcdebugger/
│ │ │ └── Breakpoints_v2.xcbkptlist
│ │ ├── objc-snippets/
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ ├── AutoMLVision.m
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── ImagePreparation.m
│ │ │ ├── Info.plist
│ │ │ ├── ModelManagement.m
│ │ │ ├── ViewController.h
│ │ │ ├── ViewController.m
│ │ │ └── main.m
│ │ └── swift-snippets/
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets/
│ │ │ ├── AppIcon.appiconset/
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ ├── AutoMLVision.swift
│ │ ├── Base.lproj/
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── ImagePreparation.swift
│ │ ├── Info.plist
│ │ ├── ModelManagement.swift
│ │ └── ViewController.swift
│ ├── quickstarts/
│ │ ├── automl/
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Contents.json
│ │ │ │ ├── cloud_download.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── delete.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── photo_camera.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── photo_library.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── switch_camera.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── video_camera.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── AutoMLExample/
│ │ │ │ ├── AppDelegate.swift
│ │ │ │ ├── Base.lproj/
│ │ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ │ └── Main.storyboard
│ │ │ │ ├── CameraViewController.swift
│ │ │ │ ├── Info.plist
│ │ │ │ ├── MLKitExtensions.swift
│ │ │ │ ├── UIUtilities.swift
│ │ │ │ └── ViewController.swift
│ │ │ ├── AutoMLExample.xcodeproj/
│ │ │ │ └── project.pbxproj
│ │ │ ├── AutoMLExampleObjC/
│ │ │ │ ├── AppDelegate.h
│ │ │ │ ├── AppDelegate.m
│ │ │ │ ├── CameraViewController.h
│ │ │ │ ├── CameraViewController.m
│ │ │ │ ├── UIImage+VisionDetection.h
│ │ │ │ ├── UIImage+VisionDetection.m
│ │ │ │ ├── UIUtilities.h
│ │ │ │ ├── UIUtilities.m
│ │ │ │ ├── ViewController.h
│ │ │ │ ├── ViewController.m
│ │ │ │ └── main.m
│ │ │ ├── Podfile
│ │ │ ├── README.md
│ │ │ └── Resources/
│ │ │ ├── automl_labeler_labels.txt
│ │ │ ├── automl_labeler_manifest.json
│ │ │ └── automl_labeler_model.tflite
│ │ ├── digitalinkrecognition/
│ │ │ ├── DigitalInkRecognitionExample/
│ │ │ │ ├── AppDelegate.swift
│ │ │ │ ├── Info.plist
│ │ │ │ ├── RecognizedInk.swift
│ │ │ │ ├── SceneDelegate.swift
│ │ │ │ ├── StrokeManager.swift
│ │ │ │ └── ViewController.swift
│ │ │ ├── DigitalInkRecognitionExample.xcodeproj/
│ │ │ │ └── project.pbxproj
│ │ │ ├── DigitalInkRecognitionExampleObjC/
│ │ │ │ ├── AppDelegate.h
│ │ │ │ ├── AppDelegate.m
│ │ │ │ ├── Assets.xcassets/
│ │ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ │ └── Contents.json
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Base.lproj/
│ │ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ │ └── Main.storyboard
│ │ │ │ ├── RecognizedInk.h
│ │ │ │ ├── RecognizedInk.m
│ │ │ │ ├── SceneDelegate.h
│ │ │ │ ├── SceneDelegate.m
│ │ │ │ ├── StrokeManager.h
│ │ │ │ ├── StrokeManager.m
│ │ │ │ ├── ViewController.h
│ │ │ │ ├── ViewController.m
│ │ │ │ └── main.m
│ │ │ ├── Podfile
│ │ │ └── README.md
│ │ ├── entityextraction/
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── cloud_download_24pt.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── delete_24pt.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── EntityExtractionExample/
│ │ │ │ ├── AppDelegate.swift
│ │ │ │ ├── Base.lproj/
│ │ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ │ └── Main.storyboard
│ │ │ │ ├── EntityExtractionModelIdentifierExtensions.swift
│ │ │ │ ├── EntityViewController.swift
│ │ │ │ ├── Info.plist
│ │ │ │ └── ModelManagementViewController.swift
│ │ │ ├── EntityExtractionExample.xcodeproj/
│ │ │ │ └── project.pbxproj
│ │ │ ├── EntityExtractionExampleObjC/
│ │ │ │ ├── AppDelegate.h
│ │ │ │ ├── AppDelegate.m
│ │ │ │ ├── EntityViewController.h
│ │ │ │ ├── EntityViewController.m
│ │ │ │ ├── MLKEntityExtractionModelIdentifier+Extensions.h
│ │ │ │ ├── MLKEntityExtractionModelIdentifier+Extensions.m
│ │ │ │ ├── ModelManagementViewController.h
│ │ │ │ ├── ModelManagementViewController.m
│ │ │ │ └── main.m
│ │ │ ├── Podfile
│ │ │ └── README.md
│ │ ├── languageid/
│ │ │ ├── LanguageIDExample/
│ │ │ │ ├── AppDelegate.swift
│ │ │ │ ├── Assets.xcassets/
│ │ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ │ └── Contents.json
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Base.lproj/
│ │ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ │ └── Main.storyboard
│ │ │ │ ├── Info.plist
│ │ │ │ └── ViewController.swift
│ │ │ ├── LanguageIDExample.xcodeproj/
│ │ │ │ └── project.pbxproj
│ │ │ ├── LanguageIDExampleObjC/
│ │ │ │ ├── AppDelegate.h
│ │ │ │ ├── AppDelegate.m
│ │ │ │ ├── ViewController.h
│ │ │ │ ├── ViewController.m
│ │ │ │ └── main.m
│ │ │ ├── Podfile
│ │ │ └── README.md
│ │ ├── smartreply/
│ │ │ ├── Podfile
│ │ │ ├── README.md
│ │ │ ├── SmartReplyExample/
│ │ │ │ ├── AppDelegate.swift
│ │ │ │ ├── DateExtension.swift
│ │ │ │ ├── MainViewController.swift
│ │ │ │ └── UITextViewPlaceholder.swift
│ │ │ ├── SmartReplyExample.xcodeproj/
│ │ │ │ └── project.pbxproj
│ │ │ └── SmartReplyExampleObjC/
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── LaunchImage.launchimage/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── ic_account_circle_36pt.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── ic_more_vert_white.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── ic_send.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ └── Main.storyboard
│ │ │ ├── Info.plist
│ │ │ ├── LaunchScreen.xib
│ │ │ ├── MainViewController.h
│ │ │ ├── MainViewController.m
│ │ │ ├── NSDate+Format.h
│ │ │ ├── NSDate+Format.m
│ │ │ ├── UITextView+Placeholder.h
│ │ │ ├── UITextView+Placeholder.m
│ │ │ └── main.m
│ │ ├── translate/
│ │ │ ├── Podfile
│ │ │ ├── README.md
│ │ │ ├── TranslateExample/
│ │ │ │ ├── AppDelegate.swift
│ │ │ │ ├── Assets.xcassets/
│ │ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ │ └── Contents.json
│ │ │ │ │ ├── Contents.json
│ │ │ │ │ └── baseline_swap_horiz_black_48pt.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Base.lproj/
│ │ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ │ └── Main.storyboard
│ │ │ │ ├── Info.plist
│ │ │ │ └── ViewController.swift
│ │ │ ├── TranslateExample.xcodeproj/
│ │ │ │ └── project.pbxproj
│ │ │ └── TranslateExampleObjC/
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── ViewController.h
│ │ │ ├── ViewController.m
│ │ │ └── main.m
│ │ └── vision/
│ │ ├── Assets.xcassets/
│ │ │ ├── AppIcon.appiconset/
│ │ │ │ └── Contents.json
│ │ │ ├── Contents.json
│ │ │ ├── photo_camera.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── photo_library.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── switch_camera.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── video_camera.imageset/
│ │ │ └── Contents.json
│ │ ├── Podfile
│ │ ├── README.md
│ │ ├── Resources/
│ │ │ └── bird.tflite
│ │ ├── VisionExample/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── CameraViewController.swift
│ │ │ ├── Info.plist
│ │ │ ├── MLKitExtensions.swift
│ │ │ ├── UIUtilities.swift
│ │ │ └── ViewController.swift
│ │ ├── VisionExample.xcodeproj/
│ │ │ └── project.pbxproj
│ │ └── VisionExampleObjC/
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── CameraViewController.h
│ │ ├── CameraViewController.m
│ │ ├── UIImage+VisionDetection.h
│ │ ├── UIImage+VisionDetection.m
│ │ ├── UIUtilities.h
│ │ ├── UIUtilities.m
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── main.m
│ └── showcase/
│ ├── translate-showcase/
│ │ ├── Assets.xcassets/
│ │ │ ├── AppIcon.appiconset/
│ │ │ │ └── Contents.json
│ │ │ ├── Contents.json
│ │ │ ├── Image.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── baseline_check_black_24pt.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── ic_arrow_back.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── ic_close.imageset/
│ │ │ └── Contents.json
│ │ ├── Podfile
│ │ ├── README.md
│ │ ├── TranslateDemo/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Base.lproj/
│ │ │ │ └── Main.storyboard
│ │ │ ├── CVPixelBuffer+Helpers.swift
│ │ │ ├── CameraOverlayview.swift
│ │ │ ├── CameraViewController.swift
│ │ │ ├── Info.plist
│ │ │ ├── MLKitExtensions.swift
│ │ │ ├── SearchViewController.swift
│ │ │ ├── TranslateLanguage+Helpers.swift
│ │ │ └── UIUtilities.swift
│ │ ├── TranslateDemo.xcodeproj/
│ │ │ └── project.pbxproj
│ │ └── TranslateDemoTests/
│ │ ├── Info.plist
│ │ └── TranslateDemoTests.swift
│ └── vision-showcase/
│ ├── Podfile
│ ├── README.md
│ ├── ShowcaseApp/
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Base.lproj/
│ │ │ └── LaunchScreen.xib
│ │ ├── Common/
│ │ │ ├── MLKImageUtilities.h
│ │ │ ├── MLKImageUtilities.m
│ │ │ ├── MLKUIUtilities.h
│ │ │ ├── MLKUIUtilities.m
│ │ │ ├── UIImage+MLKShowcase.h
│ │ │ └── UIImage+MLKShowcase.m
│ │ ├── Controllers/
│ │ │ ├── MLKLiveObjectDetectionViewController.h
│ │ │ ├── MLKLiveObjectDetectionViewController.m
│ │ │ ├── MLKResultListViewController.h
│ │ │ ├── MLKResultListViewController.m
│ │ │ ├── MLKStartPageViewController.h
│ │ │ └── MLKStartPageViewController.m
│ │ ├── Images.xcassets/
│ │ │ ├── AppIcon.appiconset/
│ │ │ │ └── Contents.json
│ │ │ └── ic_arrow_back_ios.imageset/
│ │ │ └── Contents.json
│ │ ├── Info.plist
│ │ ├── Models/
│ │ │ ├── MLKODTStatus.h
│ │ │ ├── MLKProductSearchRequest.h
│ │ │ ├── MLKProductSearchRequest.m
│ │ │ ├── MLKResult.h
│ │ │ └── MLKResult.m
│ │ ├── Views/
│ │ │ ├── MLKCameraReticle.h
│ │ │ ├── MLKCameraReticle.m
│ │ │ ├── MLKConfirmationSpinner.h
│ │ │ ├── MLKConfirmationSpinner.m
│ │ │ ├── MLKDetectionOverlayView.h
│ │ │ ├── MLKDetectionOverlayView.m
│ │ │ ├── MLKResultCell.h
│ │ │ ├── MLKResultCell.m
│ │ │ ├── MLKResultListHeaderView.h
│ │ │ ├── MLKResultListHeaderView.m
│ │ │ ├── MLKStartPageCell.h
│ │ │ ├── MLKStartPageCell.m
│ │ │ ├── MLKStartPageHeaderView.h
│ │ │ └── MLKStartPageHeaderView.m
│ │ ├── bird.tflite
│ │ └── main.m
│ └── ShowcaseApp.xcodeproj/
│ └── project.pbxproj
└── tutorials/
├── README.md
└── mlkit_image_labeling_model_maker.ipynb
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Create a report to help us improve
title: "[Bug report] Title for the bug"
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Example Steps to reproduce the behavior in sample app:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
If applicable, please include `code snippet` and `sample input(image, video, text, etc)`
**Expected behavior**
A clear and concise description of what you expected to happen.
**SDK Info:**
- SDK Name & Version [e.g. com.google.mlkit:face-detection:16.1.3]
**Smartphone:**
- Device/Simulator: [e.g. iPhone6, Pixel 5]
- Device/Simulator OS: [e.g. iOS8.1, Android API 30]
**Development Environment:**
*(For Android issue feel free to skip this section)*
- IDE Eversion: [e.g. Xcode 13.1, Android Studio 4.2]
- Laptop/Desktop: [e.g. iMac Pro (2017), HP Z840 Workstation]
- Laptop/Desktop OS/version: [e.g. macOS 12.0.1]
================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.md
================================================
---
name: Feature request
about: Suggest an idea for this project
title: "[Feature request] Title for the request"
labels: ''
assignees: ''
---
**What's your feature request? Please describe.**
A clear and concise description of what the request is. Ex. I would like to have X language support in text recognition[...]
**Mobile environment**
Android, IOS or both
**Additional context**
Add any other context or screenshots about the feature request here.
================================================
FILE: .gitignore
================================================
*.DS_Store
*.idea
*.iml
.gradle
local.properties
.project
.settings
.classpath
**/Pods/
**/*.xcuserstate
ios-snippets/Podfile.lock
ios-snippets/mlkit-snippets.xcworkspace/xcuserdata/dfurlong.xcuserdatad/UserInterfaceState.xcuserstate
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================
# MLKit Samples
A collection of quickstart samples demonstrating the [ML Kit](https://developers.google.com/ml-kit) APIs on Android and iOS.
Note: due to how this repo works, we no longer accept pull requests directly. Instead, we'll patch them internally and then sync them out.
================================================
FILE: android/.gitignore
================================================
.gradle
build/
.DS_Store
*.iml
*.apk
*.aar
*.zip
google-services.json
.project
.settings
.classpath
local.properties
.idea/*
!idea/codeStyles
captures
.externalNativeBuild
.cxx
================================================
FILE: android/LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2020 Google Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: android/README.md
================================================
# MLKit Android Samples
A collection of quickstart samples demonstrating the MLKit APIs on Android.
[See a full list of Quickstart apps here.](https://developers.google.com/ml-kit/samples)
## Introduction
[Read more about ML Kit](https://developers.google.com/ml-kit)
================================================
FILE: android/android-snippets/README.md
================================================
# ML Kit Android Snippets
This is a collection of Android code snippets seen on https://developers.google.com/ml-kit. This project is not meant to be run as a standalone app to demo ML Kit APIs.
## License
Copyright 2020 Google, Inc.
Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for
additional information regarding copyright ownership. The ASF licenses this
file to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
================================================
FILE: android/android-snippets/app/build.gradle
================================================
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 31
defaultConfig {
applicationId "com.google.example.mlkit"
minSdkVersion 19
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/androidx.exifinterface_exifinterface.version'
exclude 'META-INF/proguard/androidx-annotations.pro'
}
}
dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.exifinterface:exifinterface:1.3.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// Add this dependency and multiDexEnabled = true in your defaultConfig to solve the error:
// Cannot fit requested classes in a single dex file
implementation 'androidx.multidex:multidex:2.0.1'
// ML Kit related dependencies
// Barcode model
implementation 'com.google.mlkit:barcode-scanning:17.0.2'
// Object detection and tracking features
implementation 'com.google.mlkit:object-detection:17.0.0'
implementation 'com.google.mlkit:object-detection-custom:17.0.0'
// Face features
implementation 'com.google.android.gms:play-services-mlkit-face-detection:17.0.1'
// Text features
implementation 'com.google.android.gms:play-services-mlkit-text-recognition:18.0.0'
// Image labeling
implementation 'com.google.mlkit:image-labeling:17.0.7'
// Language Identification
implementation 'com.google.mlkit:language-id:17.0.3'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
}
================================================
FILE: android/android-snippets/app/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/ianbarber/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
================================================
FILE: android/android-snippets/app/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.example.mlkit">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".kotlin.MainActivity" />
</application>
</manifest>
================================================
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/BarcodeScanningActivity.java
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.example.mlkit;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.mlkit.vision.barcode.common.Barcode;
import com.google.mlkit.vision.barcode.BarcodeScanner;
import com.google.mlkit.vision.barcode.BarcodeScannerOptions;
import com.google.mlkit.vision.barcode.BarcodeScanning;
import com.google.mlkit.vision.common.InputImage;
import java.util.List;
public class BarcodeScanningActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
private void scanBarcodes(InputImage image) {
// [START set_detector_options]
BarcodeScannerOptions options =
new BarcodeScannerOptions.Builder()
.setBarcodeFormats(
Barcode.FORMAT_QR_CODE,
Barcode.FORMAT_AZTEC)
.build();
// [END set_detector_options]
// [START get_detector]
BarcodeScanner scanner = BarcodeScanning.getClient();
// Or, to specify the formats to recognize:
// BarcodeScanner scanner = BarcodeScanning.getClient(options);
// [END get_detector]
// [START run_detector]
Task<List<Barcode>> result = scanner.process(image)
.addOnSuccessListener(new OnSuccessListener<List<Barcode>>() {
@Override
public void onSuccess(List<Barcode> barcodes) {
// Task completed successfully
// [START_EXCLUDE]
// [START get_barcodes]
for (Barcode barcode: barcodes) {
Rect bounds = barcode.getBoundingBox();
Point[] corners = barcode.getCornerPoints();
String rawValue = barcode.getRawValue();
int valueType = barcode.getValueType();
// See API reference for complete list of supported types
switch (valueType) {
case Barcode.TYPE_WIFI:
String ssid = barcode.getWifi().getSsid();
String password = barcode.getWifi().getPassword();
int type = barcode.getWifi().getEncryptionType();
break;
case Barcode.TYPE_URL:
String title = barcode.getUrl().getTitle();
String url = barcode.getUrl().getUrl();
break;
}
}
// [END get_barcodes]
// [END_EXCLUDE]
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// Task failed with an exception
// ...
}
});
// [END run_detector]
}
}
================================================
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/FaceDetectionActivity.java
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.example.mlkit;
import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.mlkit.vision.common.InputImage;
import com.google.mlkit.vision.face.Face;
import com.google.mlkit.vision.face.FaceContour;
import com.google.mlkit.vision.face.FaceDetection;
import com.google.mlkit.vision.face.FaceDetector;
import com.google.mlkit.vision.face.FaceDetectorOptions;
import com.google.mlkit.vision.face.FaceLandmark;
import java.util.List;
public class FaceDetectionActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
private void detectFaces(InputImage image) {
// [START set_detector_options]
FaceDetectorOptions options =
new FaceDetectorOptions.Builder()
.setPerformanceMode(FaceDetectorOptions.PERFORMANCE_MODE_ACCURATE)
.setLandmarkMode(FaceDetectorOptions.LANDMARK_MODE_ALL)
.setClassificationMode(FaceDetectorOptions.CLASSIFICATION_MODE_ALL)
.setMinFaceSize(0.15f)
.enableTracking()
.build();
// [END set_detector_options]
// [START get_detector]
FaceDetector detector = FaceDetection.getClient(options);
// Or use the default options:
// FaceDetector detector = FaceDetection.getClient();
// [END get_detector]
// [START run_detector]
Task<List<Face>> result =
detector.process(image)
.addOnSuccessListener(
new OnSuccessListener<List<Face>>() {
@Override
public void onSuccess(List<Face> faces) {
// Task completed successfully
// [START_EXCLUDE]
// [START get_face_info]
for (Face face : faces) {
Rect bounds = face.getBoundingBox();
float rotY = face.getHeadEulerAngleY(); // Head is rotated to the right rotY degrees
float rotZ = face.getHeadEulerAngleZ(); // Head is tilted sideways rotZ degrees
// If landmark detection was enabled (mouth, ears, eyes, cheeks, and
// nose available):
FaceLandmark leftEar = face.getLandmark(FaceLandmark.LEFT_EAR);
if (leftEar != null) {
PointF leftEarPos = leftEar.getPosition();
}
// If classification was enabled:
if (face.getSmilingProbability() != null) {
float smileProb = face.getSmilingProbability();
}
if (face.getRightEyeOpenProbability() != null) {
float rightEyeOpenProb = face.getRightEyeOpenProbability();
}
// If face tracking was enabled:
if (face.getTrackingId() != null) {
int id = face.getTrackingId();
}
}
// [END get_face_info]
// [END_EXCLUDE]
}
})
.addOnFailureListener(
new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// Task failed with an exception
// ...
}
});
// [END run_detector]
}
private void faceOptionsExamples() {
// [START mlkit_face_options_examples]
// High-accuracy landmark detection and face classification
FaceDetectorOptions highAccuracyOpts =
new FaceDetectorOptions.Builder()
.setPerformanceMode(FaceDetectorOptions.PERFORMANCE_MODE_ACCURATE)
.setLandmarkMode(FaceDetectorOptions.LANDMARK_MODE_ALL)
.setClassificationMode(FaceDetectorOptions.CLASSIFICATION_MODE_ALL)
.build();
// Real-time contour detection
FaceDetectorOptions realTimeOpts =
new FaceDetectorOptions.Builder()
.setContourMode(FaceDetectorOptions.CONTOUR_MODE_ALL)
.build();
// [END mlkit_face_options_examples]
}
private void processFaceList(List<Face> faces) {
// [START mlkit_face_list]
for (Face face : faces) {
Rect bounds = face.getBoundingBox();
float rotY = face.getHeadEulerAngleY(); // Head is rotated to the right rotY degrees
float rotZ = face.getHeadEulerAngleZ(); // Head is tilted sideways rotZ degrees
// If landmark detection was enabled (mouth, ears, eyes, cheeks, and
// nose available):
FaceLandmark leftEar = face.getLandmark(FaceLandmark.LEFT_EAR);
if (leftEar != null) {
PointF leftEarPos = leftEar.getPosition();
}
// If contour detection was enabled:
List<PointF> leftEyeContour =
face.getContour(FaceContour.LEFT_EYE).getPoints();
List<PointF> upperLipBottomContour =
face.getContour(FaceContour.UPPER_LIP_BOTTOM).getPoints();
// If classification was enabled:
if (face.getSmilingProbability() != null) {
float smileProb = face.getSmilingProbability();
}
if (face.getRightEyeOpenProbability() != null) {
float rightEyeOpenProb = face.getRightEyeOpenProbability();
}
// If face tracking was enabled:
if (face.getTrackingId() != null) {
int id = face.getTrackingId();
}
}
// [END mlkit_face_list]
}
}
================================================
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/ImageLabelingActivity.java
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.example.mlkit;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.mlkit.vision.common.InputImage;
import com.google.mlkit.vision.label.ImageLabel;
import com.google.mlkit.vision.label.ImageLabeler;
import com.google.mlkit.vision.label.ImageLabeling;
import com.google.mlkit.vision.label.defaults.ImageLabelerOptions;
import java.util.List;
public class ImageLabelingActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
private void labelImages(InputImage image) {
ImageLabelerOptions options =
new ImageLabelerOptions.Builder()
.setConfidenceThreshold(0.8f)
.build();
// [START get_detector_options]
ImageLabeler labeler = ImageLabeling.getClient(options);
// [END get_detector_options]
/*
// [START get_detector_default]
// Or use the default options:
ImageLabeler detector = ImageLabeling.getClient(ImageLabelerOptions.DEFAULT_OPTIONS);
// [END get_detector_default]
*/
// [START run_detector]
Task<List<ImageLabel>> result =
labeler.process(image)
.addOnSuccessListener(
new OnSuccessListener<List<ImageLabel>>() {
@Override
public void onSuccess(List<ImageLabel> labels) {
// Task completed successfully
// [START_EXCLUDE]
// [START get_labels]
for (ImageLabel label : labels) {
String text = label.getText();
float confidence = label.getConfidence();
}
// [END get_labels]
// [END_EXCLUDE]
}
})
.addOnFailureListener(
new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// Task failed with an exception
// ...
}
});
// [END run_detector]
}
private void configureAndRunImageLabeler(InputImage image) {
// [START on_device_image_labeler]
// To use default options:
ImageLabeler labeler = ImageLabeling.getClient(ImageLabelerOptions.DEFAULT_OPTIONS);
// Or, to set the minimum confidence required:
// ImageLabelerOptions options =
// new ImageLabelerOptions.Builder()
// .setConfidenceThreshold(0.7f)
// .build();
// ImageLabeler labeler = ImageLabeling.getClient(options);
// [END on_device_image_labeler]
// Process image with custom onSuccess() example
// [START process_image]
labeler.process(image)
.addOnSuccessListener(new OnSuccessListener<List<ImageLabel>>() {
@Override
public void onSuccess(List<ImageLabel> labels) {
// Task completed successfully
// ...
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// Task failed with an exception
// ...
}
});
// [END process_image]
// Process image with example onSuccess()
labeler.process(image)
.addOnSuccessListener(new OnSuccessListener<List<ImageLabel>>() {
@Override
public void onSuccess(List<ImageLabel> labels) {
// [START get_image_label_info]
for (ImageLabel label : labels) {
String text = label.getText();
float confidence = label.getConfidence();
int index = label.getIndex();
}
// [END get_image_label_info]
}
});
}
}
================================================
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/LanguageIdentificationActivity.java
================================================
package com.google.example.mlkit;
import android.os.Bundle;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.mlkit.nl.languageid.IdentifiedLanguage;
import com.google.mlkit.nl.languageid.LanguageIdentification;
import com.google.mlkit.nl.languageid.LanguageIdentificationOptions;
import com.google.mlkit.nl.languageid.LanguageIdentifier;
import java.util.List;
public class LanguageIdentificationActivity extends AppCompatActivity {
private static final String TAG = "LangID";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
private void identifyLanguageWithStringInput(String text) {
// [START identify_languages]
LanguageIdentifier languageIdentifier =
LanguageIdentification.getClient();
languageIdentifier.identifyLanguage(text)
.addOnSuccessListener(
new OnSuccessListener<String>() {
@Override
public void onSuccess(@Nullable String languageCode) {
if (languageCode.equals("und")) {
Log.i(TAG, "Can't identify language.");
} else {
Log.i(TAG, "Language: " + languageCode);
}
}
})
.addOnFailureListener(
new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// Model couldn’t be loaded or other internal error.
// ...
}
});
// [END identify_languages]
}
private void setConfidence() {
// [START set_confidence]
LanguageIdentifier languageIdentifier = LanguageIdentification.getClient(
new LanguageIdentificationOptions.Builder()
.setConfidenceThreshold(0.34f)
.build());
// [END set_confidence]
}
private void getPossibleLanguuages(String text) {
// [START get_possible_languages]
LanguageIdentifier languageIdentifier =
LanguageIdentification.getClient();
languageIdentifier.identifyPossibleLanguages(text)
.addOnSuccessListener(new OnSuccessListener<List<IdentifiedLanguage>>() {
@Override
public void onSuccess(List<IdentifiedLanguage> identifiedLanguages) {
for (IdentifiedLanguage identifiedLanguage : identifiedLanguages) {
String language = identifiedLanguage.getLanguageTag();
float confidence = identifiedLanguage.getConfidence();
Log.i(TAG, language + " (" + confidence + ")");
}
}
})
.addOnFailureListener(
new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// Model couldn’t be loaded or other internal error.
// ...
}
});
// [END get_possible_languages]
}
private void setConfidenceThreshold() {
// [START set_confidence_threshold]
LanguageIdentificationOptions identifierOptions =
new LanguageIdentificationOptions.Builder()
.setConfidenceThreshold(0.5f)
.build();
LanguageIdentifier languageIdentifier = LanguageIdentification
.getClient(identifierOptions);
// [END set_confidence_threshold]
}
}
================================================
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/MLKitVisionImage.java
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.example.mlkit;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraManager;
import android.media.Image;
import android.net.Uri;
import android.os.Build;
import androidx.annotation.RequiresApi;
import android.util.SparseIntArray;
import android.view.Surface;
import com.google.mlkit.vision.common.InputImage;
import java.io.IOException;
import java.nio.ByteBuffer;
import static android.content.Context.CAMERA_SERVICE;
public class MLKitVisionImage {
private static final String TAG = "MLKIT";
private static final String MY_CAMERA_ID = "my_camera_id";
private void imageFromBitmap(Bitmap bitmap) {
int rotationDegree = 0;
// [START image_from_bitmap]
InputImage image = InputImage.fromBitmap(bitmap, rotationDegree);
// [END image_from_bitmap]
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void imageFromMediaImage(Image mediaImage, int rotation) {
// [START image_from_media_image]
InputImage image = InputImage.fromMediaImage(mediaImage, rotation);
// [END image_from_media_image]
}
private void imageFromBuffer(ByteBuffer byteBuffer, int rotationDegrees) {
// [START set_metadata]
// TODO How do we document the FrameMetadata developers need to implement?
// [END set_metadata]
// [START image_from_buffer]
InputImage image = InputImage.fromByteBuffer(byteBuffer,
/* image width */ 480,
/* image height */ 360,
rotationDegrees,
InputImage.IMAGE_FORMAT_NV21 // or IMAGE_FORMAT_YV12
);
// [END image_from_buffer]
}
private void imageFromArray(byte[] byteArray, int rotation) {
// [START image_from_array]
InputImage image = InputImage.fromByteArray(
byteArray,
/* image width */480,
/* image height */360,
rotation,
InputImage.IMAGE_FORMAT_NV21 // or IMAGE_FORMAT_YV12
);
// [END image_from_array]
}
private void imageFromPath(Context context, Uri uri) {
// [START image_from_path]
InputImage image;
try {
image = InputImage.fromFilePath(context, uri);
} catch (IOException e) {
e.printStackTrace();
}
// [END image_from_path]
}
// [START get_rotation]
private static final SparseIntArray ORIENTATIONS = new SparseIntArray();
static {
ORIENTATIONS.append(Surface.ROTATION_0, 0);
ORIENTATIONS.append(Surface.ROTATION_90, 90);
ORIENTATIONS.append(Surface.ROTATION_180, 180);
ORIENTATIONS.append(Surface.ROTATION_270, 270);
}
/**
* Get the angle by which an image must be rotated given the device's current
* orientation.
*/
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private int getRotationCompensation(String cameraId, Activity activity, boolean isFrontFacing)
throws CameraAccessException {
// Get the device's current rotation relative to its "native" orientation.
// Then, from the ORIENTATIONS table, look up the angle the image must be
// rotated to compensate for the device's rotation.
int deviceRotation = activity.getWindowManager().getDefaultDisplay().getRotation();
int rotationCompensation = ORIENTATIONS.get(deviceRotation);
// Get the device's sensor orientation.
CameraManager cameraManager = (CameraManager) activity.getSystemService(CAMERA_SERVICE);
int sensorOrientation = cameraManager
.getCameraCharacteristics(cameraId)
.get(CameraCharacteristics.SENSOR_ORIENTATION);
if (isFrontFacing) {
rotationCompensation = (sensorOrientation + rotationCompensation) % 360;
} else { // back-facing
rotationCompensation = (sensorOrientation - rotationCompensation + 360) % 360;
}
return rotationCompensation;
}
// [END get_rotation]
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void getCompensation(Activity activity, boolean isFrontFacing) throws CameraAccessException {
// Get the ID of the camera using CameraManager. Then:
int rotation = getRotationCompensation(MY_CAMERA_ID, activity, isFrontFacing);
}
}
================================================
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/MainActivity.java
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.example.mlkit;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
}
================================================
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/ObjectDetectionActivity.java
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.example.mlkit;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.mlkit.common.model.LocalModel;
import com.google.mlkit.vision.common.InputImage;
import com.google.mlkit.vision.objects.DetectedObject;
import com.google.mlkit.vision.objects.ObjectDetection;
import com.google.mlkit.vision.objects.ObjectDetector;
import com.google.mlkit.vision.objects.custom.CustomObjectDetectorOptions;
import com.google.mlkit.vision.objects.defaults.ObjectDetectorOptions;
import com.google.mlkit.vision.objects.defaults.PredefinedCategory;
import java.util.ArrayList;
import java.util.List;
public class ObjectDetectionActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
private void useDefaultObjectDetector() {
// [START create_default_options]
// Live detection and tracking
ObjectDetectorOptions options =
new ObjectDetectorOptions.Builder()
.setDetectorMode(ObjectDetectorOptions.STREAM_MODE)
.enableClassification() // Optional
.build();
// Multiple object detection in static images
options =
new ObjectDetectorOptions.Builder()
.setDetectorMode(ObjectDetectorOptions.SINGLE_IMAGE_MODE)
.enableMultipleObjects()
.enableClassification() // Optional
.build();
// [END create_default_options]
// [START create_detector]
ObjectDetector objectDetector = ObjectDetection.getClient(options);
// [END create_detector]
InputImage image =
InputImage.fromBitmap(
Bitmap.createBitmap(new int[100 * 100], 100, 100, Bitmap.Config.ARGB_8888),
0);
// [START process_image]
objectDetector.process(image)
.addOnSuccessListener(
new OnSuccessListener<List<DetectedObject>>() {
@Override
public void onSuccess(List<DetectedObject> detectedObjects) {
// Task completed successfully
// ...
}
})
.addOnFailureListener(
new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// Task failed with an exception
// ...
}
});
// [END process_image]
List<DetectedObject> results = new ArrayList<>();
// [START read_results_default]
// The list of detected objects contains one item if multiple
// object detection wasn't enabled.
for (DetectedObject detectedObject : results) {
Rect boundingBox = detectedObject.getBoundingBox();
Integer trackingId = detectedObject.getTrackingId();
for (DetectedObject.Label label : detectedObject.getLabels()) {
String text = label.getText();
if (PredefinedCategory.FOOD.equals(text)) {
// ...
}
int index = label.getIndex();
if (PredefinedCategory.FOOD_INDEX == index) {
// ...
}
float confidence = label.getConfidence();
}
}
// [END read_results_default]
}
private void useCustomObjectDetector() {
InputImage image =
InputImage.fromBitmap(
Bitmap.createBitmap(new int[100 * 100], 100, 100, Bitmap.Config.ARGB_8888),
0);
// [START create_local_model]
LocalModel localModel =
new LocalModel.Builder()
.setAssetFilePath("asset_file_path_to_tflite_model")
// or .setAbsoluteFilePath("absolute_file_path_to_tflite_model")
.build();
// [END create_local_model]
// [START create_custom_options]
// Live detection and tracking
CustomObjectDetectorOptions options =
new CustomObjectDetectorOptions.Builder(localModel)
.setDetectorMode(CustomObjectDetectorOptions.STREAM_MODE)
.enableClassification()
.setClassificationConfidenceThreshold(0.5f)
.setMaxPerObjectLabelCount(3)
.build();
// Multiple object detection in static images
options =
new CustomObjectDetectorOptions.Builder(localModel)
.setDetectorMode(CustomObjectDetectorOptions.SINGLE_IMAGE_MODE)
.enableMultipleObjects()
.enableClassification()
.setClassificationConfidenceThreshold(0.5f)
.setMaxPerObjectLabelCount(3)
.build();
// [END create_custom_options]
List<DetectedObject> results = new ArrayList<>();
// [START read_results_custom]
// The list of detected objects contains one item if multiple
// object detection wasn't enabled.
for (DetectedObject detectedObject : results) {
Rect boundingBox = detectedObject.getBoundingBox();
Integer trackingId = detectedObject.getTrackingId();
for (DetectedObject.Label label : detectedObject.getLabels()) {
String text = label.getText();
int index = label.getIndex();
float confidence = label.getConfidence();
}
}
// [END read_results_custom]
}
}
================================================
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/TextRecognitionActivity.java
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.example.mlkit;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.mlkit.vision.common.InputImage;
import com.google.mlkit.vision.text.Text;
import com.google.mlkit.vision.text.TextRecognition;
import com.google.mlkit.vision.text.TextRecognizer;
import com.google.mlkit.vision.text.latin.TextRecognizerOptions;
public class TextRecognitionActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
private void recognizeText(InputImage image) {
// [START get_detector_default]
TextRecognizer recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS);
// [END get_detector_default]
// [START run_detector]
Task<Text> result =
recognizer.process(image)
.addOnSuccessListener(new OnSuccessListener<Text>() {
@Override
public void onSuccess(Text visionText) {
// Task completed successfully
// [START_EXCLUDE]
// [START get_text]
for (Text.TextBlock block : visionText.getTextBlocks()) {
Rect boundingBox = block.getBoundingBox();
Point[] cornerPoints = block.getCornerPoints();
String text = block.getText();
for (Text.Line line: block.getLines()) {
// ...
for (Text.Element element: line.getElements()) {
// ...
for (Text.Symbol symbol: element.getSymbols()) {
// ...
}
}
}
}
// [END get_text]
// [END_EXCLUDE]
}
})
.addOnFailureListener(
new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// Task failed with an exception
// ...
}
});
// [END run_detector]
}
private void processTextBlock(Text result) {
// [START mlkit_process_text_block]
String resultText = result.getText();
for (Text.TextBlock block : result.getTextBlocks()) {
String blockText = block.getText();
Point[] blockCornerPoints = block.getCornerPoints();
Rect blockFrame = block.getBoundingBox();
for (Text.Line line : block.getLines()) {
String lineText = line.getText();
Point[] lineCornerPoints = line.getCornerPoints();
Rect lineFrame = line.getBoundingBox();
for (Text.Element element : line.getElements()) {
String elementText = element.getText();
Point[] elementCornerPoints = element.getCornerPoints();
Rect elementFrame = element.getBoundingBox();
for (Text.Symbol symbol : element.getSymbols()) {
String symbolText = symbol.getText();
Point[] symbolCornerPoints = symbol.getCornerPoints();
Rect symbolFrame = symbol.getBoundingBox();
}
}
}
}
// [END mlkit_process_text_block]
}
private TextRecognizer getTextRecognizer() {
// [START mlkit_local_doc_recognizer]
TextRecognizer detector = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS);
// [END mlkit_local_doc_recognizer]
return detector;
}
}
================================================
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/kotlin/BarcodeScanningActivity.kt
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.example.mlkit.kotlin
import androidx.appcompat.app.AppCompatActivity
import com.google.mlkit.vision.barcode.BarcodeScannerOptions
import com.google.mlkit.vision.barcode.BarcodeScanning
import com.google.mlkit.vision.barcode.common.Barcode
import com.google.mlkit.vision.common.InputImage
class BarcodeScanningActivity : AppCompatActivity() {
private fun scanBarcodes(image: InputImage) {
// [START set_detector_options]
val options = BarcodeScannerOptions.Builder()
.setBarcodeFormats(
Barcode.FORMAT_QR_CODE,
Barcode.FORMAT_AZTEC)
.build()
// [END set_detector_options]
// [START get_detector]
val scanner = BarcodeScanning.getClient()
// Or, to specify the formats to recognize:
// val scanner = BarcodeScanning.getClient(options)
// [END get_detector]
// [START run_detector]
val result = scanner.process(image)
.addOnSuccessListener { barcodes ->
// Task completed successfully
// [START_EXCLUDE]
// [START get_barcodes]
for (barcode in barcodes) {
val bounds = barcode.boundingBox
val corners = barcode.cornerPoints
val rawValue = barcode.rawValue
val valueType = barcode.valueType
// See API reference for complete list of supported types
when (valueType) {
Barcode.TYPE_WIFI -> {
val ssid = barcode.wifi!!.ssid
val password = barcode.wifi!!.password
val type = barcode.wifi!!.encryptionType
}
Barcode.TYPE_URL -> {
val title = barcode.url!!.title
val url = barcode.url!!.url
}
}
}
// [END get_barcodes]
// [END_EXCLUDE]
}
.addOnFailureListener {
// Task failed with an exception
// ...
}
// [END run_detector]
}
}
================================================
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/kotlin/FaceDetectionActivity.kt
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.example.mlkit.kotlin
import androidx.appcompat.app.AppCompatActivity
import com.google.mlkit.vision.common.InputImage
import com.google.mlkit.vision.face.*
class FaceDetectionActivity : AppCompatActivity() {
private fun detectFaces(image: InputImage) {
// [START set_detector_options]
val options = FaceDetectorOptions.Builder()
.setPerformanceMode(FaceDetectorOptions.PERFORMANCE_MODE_ACCURATE)
.setLandmarkMode(FaceDetectorOptions.LANDMARK_MODE_ALL)
.setClassificationMode(FaceDetectorOptions.CLASSIFICATION_MODE_ALL)
.setMinFaceSize(0.15f)
.enableTracking()
.build()
// [END set_detector_options]
// [START get_detector]
val detector = FaceDetection.getClient(options)
// Or, to use the default option:
// val detector = FaceDetection.getClient();
// [END get_detector]
// [START run_detector]
val result = detector.process(image)
.addOnSuccessListener { faces ->
// Task completed successfully
// [START_EXCLUDE]
// [START get_face_info]
for (face in faces) {
val bounds = face.boundingBox
val rotY = face.headEulerAngleY // Head is rotated to the right rotY degrees
val rotZ = face.headEulerAngleZ // Head is tilted sideways rotZ degrees
// If landmark detection was enabled (mouth, ears, eyes, cheeks, and
// nose available):
val leftEar = face.getLandmark(FaceLandmark.LEFT_EAR)
leftEar?.let {
val leftEarPos = leftEar.position
}
// If classification was enabled:
if (face.smilingProbability != null) {
val smileProb = face.smilingProbability
}
if (face.rightEyeOpenProbability != null) {
val rightEyeOpenProb = face.rightEyeOpenProbability
}
// If face tracking was enabled:
if (face.trackingId != null) {
val id = face.trackingId
}
}
// [END get_face_info]
// [END_EXCLUDE]
}
.addOnFailureListener { e ->
// Task failed with an exception
// ...
}
// [END run_detector]
}
private fun faceOptionsExamples() {
// [START mlkit_face_options_examples]
// High-accuracy landmark detection and face classification
val highAccuracyOpts = FaceDetectorOptions.Builder()
.setPerformanceMode(FaceDetectorOptions.PERFORMANCE_MODE_ACCURATE)
.setLandmarkMode(FaceDetectorOptions.LANDMARK_MODE_ALL)
.setClassificationMode(FaceDetectorOptions.CLASSIFICATION_MODE_ALL)
.build()
// Real-time contour detection
val realTimeOpts = FaceDetectorOptions.Builder()
.setContourMode(FaceDetectorOptions.CONTOUR_MODE_ALL)
.build()
// [END mlkit_face_options_examples]
}
private fun processFaceList(faces: List<Face>) {
// [START mlkit_face_list]
for (face in faces) {
val bounds = face.boundingBox
val rotY = face.headEulerAngleY // Head is rotated to the right rotY degrees
val rotZ = face.headEulerAngleZ // Head is tilted sideways rotZ degrees
// If landmark detection was enabled (mouth, ears, eyes, cheeks, and
// nose available):
val leftEar = face.getLandmark(FaceLandmark.LEFT_EAR)
leftEar?.let {
val leftEarPos = leftEar.position
}
// If contour detection was enabled:
val leftEyeContour = face.getContour(FaceContour.LEFT_EYE)?.points
val upperLipBottomContour = face.getContour(FaceContour.UPPER_LIP_BOTTOM)?.points
// If classification was enabled:
if (face.smilingProbability != null) {
val smileProb = face.smilingProbability
}
if (face.rightEyeOpenProbability != null) {
val rightEyeOpenProb = face.rightEyeOpenProbability
}
// If face tracking was enabled:
if (face.trackingId != null) {
val id = face.trackingId
}
}
// [END mlkit_face_list]
}
}
================================================
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/kotlin/ImageLabelingActivity.kt
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.example.mlkit.kotlin
import androidx.appcompat.app.AppCompatActivity
import com.google.mlkit.vision.common.InputImage
import com.google.mlkit.vision.label.ImageLabeler
import com.google.mlkit.vision.label.ImageLabeling
import com.google.mlkit.vision.label.defaults.ImageLabelerOptions
class ImageLabelingActivity : AppCompatActivity() {
private fun labelImages(image: InputImage) {
val options = ImageLabelerOptions.Builder()
.setConfidenceThreshold(0.8f)
.build()
val labeler = ImageLabeling.getClient(options)
// [START run_detector]
val result = labeler.process(image)
.addOnSuccessListener { labels ->
// Task completed successfully
// [START_EXCLUDE]
// [START get_labels]
for (label in labels) {
val text = label.text
val confidence = label.confidence
}
// [END get_labels]
// [END_EXCLUDE]
}
.addOnFailureListener { e ->
// Task failed with an exception
// ...
}
// [END run_detector]
}
private fun configureAndRunImageLabeler(image: InputImage) {
// [START on_device_image_labeler]
// To use default options:
val labeler = ImageLabeling.getClient(ImageLabelerOptions.DEFAULT_OPTIONS)
// Or, to set the minimum confidence required:
// val options = ImageLabelerOptions.Builder()
// .setConfidenceThreshold(0.7f)
// .build()
// val labeler = ImageLabeling.getClient(options)
// [END on_device_image_labeler]
// Process image with custom onSuccess() example
// [START process_image]
labeler.process(image)
.addOnSuccessListener { labels ->
// Task completed successfully
// ...
}
.addOnFailureListener { e ->
// Task failed with an exception
// ...
}
// [END process_image]
// Process image with example onSuccess()
labeler.process(image)
.addOnSuccessListener { labels ->
// [START get_image_label_info]
for (label in labels) {
val text = label.text
val confidence = label.confidence
val index = label.index
}
// [END get_image_label_info]
}
}
}
================================================
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/kotlin/LanguageIdentificationActivity.kt
================================================
package com.google.example.mlkit.kotlin
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.google.mlkit.nl.languageid.LanguageIdentification
import com.google.mlkit.nl.languageid.LanguageIdentificationOptions
private const val TAG = "LangIDActivity"
class LanguageIdentificationActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
fun identifyLanguageWithStringInput(text: String) {
// [START identify_languages]
val languageIdentifier = LanguageIdentification.getClient()
languageIdentifier.identifyLanguage(text)
.addOnSuccessListener { languageCode ->
if (languageCode == "und") {
Log.i(TAG, "Can't identify language.")
} else {
Log.i(TAG, "Language: $languageCode")
}
}
.addOnFailureListener {
// Model couldn’t be loaded or other internal error.
// ...
}
// [END identify_languages]
}
fun setConfidence() {
// [START set_confidence]
val languageIdentifier = LanguageIdentification
.getClient(LanguageIdentificationOptions.Builder()
.setConfidenceThreshold(0.34f)
.build())
// [END set_confidence]
}
fun getPossibleLanguuages(text: String) {
// [START get_possible_languages]
val languageIdentifier = LanguageIdentification.getClient()
languageIdentifier.identifyPossibleLanguages(text)
.addOnSuccessListener { identifiedLanguages ->
for (identifiedLanguage in identifiedLanguages) {
val language = identifiedLanguage.languageTag
val confidence = identifiedLanguage.confidence
Log.i(TAG, "$language $confidence")
}
}
.addOnFailureListener {
// Model couldn’t be loaded or other internal error.
// ...
}
// [END get_possible_languages]
}
private fun setConfidenceThreshold() {
// [START set_confidence_threshold]
val identifierOptions = LanguageIdentificationOptions.Builder()
.setConfidenceThreshold(0.5f)
.build()
val languageIdentifier = LanguageIdentification
.getClient(identifierOptions)
// [END set_confidence_threshold]
}
}
================================================
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/kotlin/MLKitVisionImage.kt
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.example.mlkit.kotlin
import android.app.Activity
import android.content.Context
import android.content.Context.CAMERA_SERVICE
import android.graphics.Bitmap
import android.hardware.camera2.CameraAccessException
import android.hardware.camera2.CameraCharacteristics
import android.hardware.camera2.CameraManager
import android.media.Image
import android.net.Uri
import android.os.Build
import android.util.SparseIntArray
import android.view.Surface
import androidx.annotation.RequiresApi
import com.google.mlkit.vision.common.InputImage
import java.io.IOException
import java.nio.ByteBuffer
class MLKitVisionImage {
private fun imageFromBitmap(bitmap: Bitmap) {
val rotationDegrees = 0
// [START image_from_bitmap]
val image = InputImage.fromBitmap(bitmap, 0)
// [END image_from_bitmap]
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private fun imageFromMediaImage(mediaImage: Image, rotation: Int) {
// [START image_from_media_image]
val image = InputImage.fromMediaImage(mediaImage, rotation)
// [END image_from_media_image]
}
private fun imageFromBuffer(byteBuffer: ByteBuffer, rotationDegrees: Int) {
// [START set_metadata]
// TODO How do we document the FrameMetadata developers need to implement?
// [END set_metadata]
// [START image_from_buffer]
val image = InputImage.fromByteBuffer(
byteBuffer,
/* image width */ 480,
/* image height */ 360,
rotationDegrees,
InputImage.IMAGE_FORMAT_NV21 // or IMAGE_FORMAT_YV12
)
// [END image_from_buffer]
}
private fun imageFromArray(byteArray: ByteArray, rotationDegrees: Int) {
// [START image_from_array]
val image = InputImage.fromByteArray(
byteArray,
/* image width */ 480,
/* image height */ 360,
rotationDegrees,
InputImage.IMAGE_FORMAT_NV21 // or IMAGE_FORMAT_YV12
)
// [END image_from_array]
}
private fun imageFromPath(context: Context, uri: Uri) {
// [START image_from_path]
val image: InputImage
try {
image = InputImage.fromFilePath(context, uri)
} catch (e: IOException) {
e.printStackTrace()
}
// [END image_from_path]
}
// [START get_rotation]
/**
* Get the angle by which an image must be rotated given the device's current
* orientation.
*/
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Throws(CameraAccessException::class)
private fun getRotationCompensation(cameraId: String, activity: Activity, isFrontFacing: Boolean): Int {
// Get the device's current rotation relative to its "native" orientation.
// Then, from the ORIENTATIONS table, look up the angle the image must be
// rotated to compensate for the device's rotation.
val deviceRotation = activity.windowManager.defaultDisplay.rotation
var rotationCompensation = ORIENTATIONS.get(deviceRotation)
// Get the device's sensor orientation.
val cameraManager = activity.getSystemService(CAMERA_SERVICE) as CameraManager
val sensorOrientation = cameraManager
.getCameraCharacteristics(cameraId)
.get(CameraCharacteristics.SENSOR_ORIENTATION)!!
if (isFrontFacing) {
rotationCompensation = (sensorOrientation + rotationCompensation) % 360
} else { // back-facing
rotationCompensation = (sensorOrientation - rotationCompensation + 360) % 360
}
return rotationCompensation
}
// [END get_rotation]
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Throws(CameraAccessException::class)
private fun getCompensation(activity: Activity, context: Context, isFrontFacing: Boolean) {
// Get the ID of the camera using CameraManager. Then:
val rotation = getRotationCompensation(MY_CAMERA_ID, activity, isFrontFacing)
}
companion object {
private val TAG = "MLKIT"
private val MY_CAMERA_ID = "my_camera_id"
// [START camera_orientations]
private val ORIENTATIONS = SparseIntArray()
init {
ORIENTATIONS.append(Surface.ROTATION_0, 0)
ORIENTATIONS.append(Surface.ROTATION_90, 90)
ORIENTATIONS.append(Surface.ROTATION_180, 180)
ORIENTATIONS.append(Surface.ROTATION_270, 270)
}
// [END camera_orientations]
}
}
================================================
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/kotlin/MainActivity.kt
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.example.mlkit.kotlin
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity()
================================================
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/kotlin/ObjectDetectionActivity.kt
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.example.mlkit.kotlin
import android.graphics.Bitmap
import androidx.appcompat.app.AppCompatActivity
import com.google.mlkit.common.model.LocalModel
import com.google.mlkit.vision.common.InputImage
import com.google.mlkit.vision.objects.DetectedObject
import com.google.mlkit.vision.objects.ObjectDetection
import com.google.mlkit.vision.objects.custom.CustomObjectDetectorOptions
import com.google.mlkit.vision.objects.defaults.ObjectDetectorOptions
import com.google.mlkit.vision.objects.defaults.PredefinedCategory
class ObjectDetectionActivity : AppCompatActivity() {
private fun useDefaultObjectDetector() {
// [START create_default_options]
// Live detection and tracking
var options = ObjectDetectorOptions.Builder()
.setDetectorMode(ObjectDetectorOptions.STREAM_MODE)
.enableClassification() // Optional
.build()
// Multiple object detection in static images
options = ObjectDetectorOptions.Builder()
.setDetectorMode(ObjectDetectorOptions.SINGLE_IMAGE_MODE)
.enableMultipleObjects()
.enableClassification() // Optional
.build()
// [END create_default_options]
// [START create_detector]
val objectDetector = ObjectDetection.getClient(options)
// [END create_detector]
val image = InputImage.fromBitmap(
Bitmap.createBitmap(IntArray(100 * 100), 100, 100, Bitmap.Config.ARGB_8888),
0)
// [START process_image]
objectDetector.process(image)
.addOnSuccessListener { results ->
// Task completed successfully
// ...
}
.addOnFailureListener { e ->
// Task failed with an exception
// ...
}
// [END process_image]
val results = listOf<DetectedObject>()
// [START read_results_default]
for (detectedObject in results) {
val boundingBox = detectedObject.boundingBox
val trackingId = detectedObject.trackingId
for (label in detectedObject.labels) {
val text = label.text
if (PredefinedCategory.FOOD == text) {
// ...
}
val index = label.index
if (PredefinedCategory.FOOD_INDEX == index) {
// ...
}
val confidence = label.confidence
}
}
// [END read_results_default]
}
private fun useCustomObjectDetector() {
val image = InputImage.fromBitmap(
Bitmap.createBitmap(IntArray(100 * 100), 100, 100, Bitmap.Config.ARGB_8888),
0)
// [START create_local_model]
val localModel =
LocalModel.Builder()
.setAssetFilePath("asset_file_path_to_tflite_model")
// or .setAbsoluteFilePath("absolute_file_path_to_tflite_model")
.build()
// [END create_local_model]
// [START create_custom_options]
// Live detection and tracking
var options =
CustomObjectDetectorOptions.Builder(localModel)
.setDetectorMode(CustomObjectDetectorOptions.STREAM_MODE)
.enableClassification()
.setClassificationConfidenceThreshold(0.5f)
.setMaxPerObjectLabelCount(3)
.build()
// Multiple object detection in static images
options =
CustomObjectDetectorOptions.Builder(localModel)
.setDetectorMode(CustomObjectDetectorOptions.SINGLE_IMAGE_MODE)
.enableMultipleObjects()
.enableClassification()
.setClassificationConfidenceThreshold(0.5f)
.setMaxPerObjectLabelCount(3)
.build()
// [END create_custom_options]
val results = listOf<DetectedObject>()
// [START read_results_custom]
for (detectedObject in results) {
val boundingBox = detectedObject.boundingBox
val trackingId = detectedObject.trackingId
for (label in detectedObject.labels) {
val text = label.text
val index = label.index
val confidence = label.confidence
}
}
// [END read_results_custom]
}
}
================================================
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/kotlin/TextRecognitionActivity.kt
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.example.mlkit.kotlin
import androidx.appcompat.app.AppCompatActivity
import com.google.mlkit.vision.common.InputImage
import com.google.mlkit.vision.text.Text
import com.google.mlkit.vision.text.TextRecognition
import com.google.mlkit.vision.text.TextRecognizer
import com.google.mlkit.vision.text.latin.TextRecognizerOptions
class TextRecognitionActivity : AppCompatActivity() {
private fun recognizeText(image: InputImage) {
// [START get_detector_default]
val recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS)
// [END get_detector_default]
// [START run_detector]
val result = recognizer.process(image)
.addOnSuccessListener { visionText ->
// Task completed successfully
// [START_EXCLUDE]
// [START get_text]
for (block in visionText.textBlocks) {
val boundingBox = block.boundingBox
val cornerPoints = block.cornerPoints
val text = block.text
for (line in block.lines) {
// ...
for (element in line.elements) {
// ...
}
}
}
// [END get_text]
// [END_EXCLUDE]
}
.addOnFailureListener { e ->
// Task failed with an exception
// ...
}
// [END run_detector]
}
private fun processTextBlock(result: Text) {
// [START mlkit_process_text_block]
val resultText = result.text
for (block in result.textBlocks) {
val blockText = block.text
val blockCornerPoints = block.cornerPoints
val blockFrame = block.boundingBox
for (line in block.lines) {
val lineText = line.text
val lineCornerPoints = line.cornerPoints
val lineFrame = line.boundingBox
for (element in line.elements) {
val elementText = element.text
val elementCornerPoints = element.cornerPoints
val elementFrame = element.boundingBox
}
}
}
// [END mlkit_process_text_block]
}
private fun getTextRecognizer(): TextRecognizer {
// [START mlkit_local_doc_recognizer]
return TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS)
// [END mlkit_local_doc_recognizer]
}
}
================================================
FILE: android/android-snippets/app/src/main/res/layout/activity_main.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"/>
</RelativeLayout>
================================================
FILE: android/android-snippets/app/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
================================================
FILE: android/android-snippets/app/src/main/res/values/dimens.xml
================================================
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
================================================
FILE: android/android-snippets/app/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">MLKit Code Snippets</string>
</resources>
================================================
FILE: android/android-snippets/app/src/main/res/values/styles.xml
================================================
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
================================================
FILE: android/android-snippets/app/src/main/res/values-w820dp/dimens.xml
================================================
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
================================================
FILE: android/android-snippets/build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.4.31'
repositories {
mavenLocal()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenLocal()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: android/android-snippets/gradle/wrapper/gradle-wrapper.properties
================================================
#Mon Aug 24 22:29:37 PDT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
================================================
FILE: android/android-snippets/gradle.properties
================================================
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
================================================
FILE: android/android-snippets/gradlew
================================================
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
================================================
FILE: android/android-snippets/gradlew.bat
================================================
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: android/android-snippets/settings.gradle
================================================
include ':app'
================================================
FILE: android/automl/LICENSE
================================================
Copyright 2020 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
================================================
FILE: android/automl/README.md
================================================
# ML Kit AutoML Remote Model Quickstart Sample App
* [Read more about training an image classification model using AutoML Vision Edge model](https://firebase.google.com/docs/ml/automl-image-labeling)
* [Read more about hosting models with Firebase Model deployment](https://firebase.google.com/docs/ml/manage-hosted-models)
## Introduction
This ML Kit Quickstart App demonstrates how to label images and objects with an
AutoML Vision Edge trained model, and also how to download models that are
hosted within Firebase.
## Feature List
Features that are included in this demo app:
* [Custom Image labeling](https://developers.google.com/ml-kit/vision/image-labeling/custom-models/android) - Label images using a custom AutoML VisionEdge trained model that is downloaded from Firebase.
* [Custom Object Detection and Tracking](https://developers.google.com/ml-kit/vision/object-detection/custom-models/android) - Detect and label object using a custom AutoML VisionEdge trained model that is downloaded from Firebase.
<img src="../screenshots/automl-quickstart.png" width="256"/>
## Getting Started
* In order to setup this app to run, you need to create a Firebase project as
outlined [here](https://firebase.google.com/docs/android/setup).
* Run the sample code on your Android device or emulator
* Try extending the code to add new features and functionality
* Ensure your device is connected to the Internet to download the remote model
## How to use the app
This app supports three usage scenarios: Live Camera, Static Image, and CameraX
enabled live camera.
### Live Camera Scenario
This mode uses the camera preview as input and allows you to label images using
a remotely downloaded AutoML Vision Edge model. There is also a settings page
that allows you to configure several options:
* Camera
* Preview Size -- Specify the preview size of rear camera manually (Default
size is chose appropriately based on screen size)
* Enable live viewport -- Prevent the live camera preview from being blocked
by API rendering speed.
* AutoML Image Labeling
* AutoML Remote Model Name -- Allows you to specify an AutoML VisionEdge
model to remotely download from the Firebase Console
### Static Image Scenario
The static image scenario is identical to the live camera scenario, but instead
relies on images fed into the app through the gallery.
### CameraX Live Preview scenario
The CameraX live preview scenario is very similar to the native live camera
scenario, but instead relies on CameraX live preview instead of the Camera2 live
preview. Note: CameraX is only supported on API level 21+.
## Support
* [Stack Overflow](https://stackoverflow.com/questions/tagged/google-mlkit)
## License
Copyright 2020 Google, Inc.
Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for
additional information regarding copyright ownership. The ASF licenses this
file to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
================================================
FILE: android/automl/app/build.gradle
================================================
apply plugin: 'com.android.application'
android {
compileSdkVersion 34
defaultConfig {
applicationId "com.google.mlkit.vision.automl.demo"
minSdkVersion 21
multiDexEnabled true
targetSdkVersion 34
// Version code for next release (version 9 is now in Play Store)
versionCode 11
versionName "1.11"
vectorDrawables.useSupportLibrary = true
setProperty("archivesBaseName", "vision-automl-remote-model-quickstart")
}
buildTypes {
proguard {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'proguard.cfg'
testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguardTest-rules.pro', 'proguard.cfg'
}
testBuildType "proguard"
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// Do NOT compress tflite model files (need to call out to developers!)
aaptOptions {
noCompress "tflite"
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
repositories {
// Depending on AndroidX Snapshot Builds to get the latest CameraX libs.
maven { url 'https://androidx.dev/snapshots/builds/6787662/artifacts/repository/' }
}
dependencies {
// Image labeling with AutoML model support
implementation 'com.google.mlkit:image-labeling-custom:17.0.3'
// Or comment the dependency above and uncomment the dependency below to
// use unbundled model that depends on Google Play Services
// implementation 'com.google.android.gms:play-services-mlkit-image-labeling-custom:16.0.0-beta5'
implementation 'com.google.mlkit:object-detection-custom:17.0.2'
implementation 'com.google.mlkit:linkfirebase:17.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
// -------------------------------------------------------
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.guava:guava:27.1-android'
// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-livedata:2.3.1"
implementation "androidx.lifecycle:lifecycle-viewmodel:2.3.1"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.annotation:annotation:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
// CameraX
implementation "androidx.camera:camera-camera2:1.0.0-SNAPSHOT"
implementation "androidx.camera:camera-lifecycle:1.0.0-SNAPSHOT"
implementation "androidx.camera:camera-view:1.0.0-SNAPSHOT"
}
configurations {
// Resolves dependency conflict caused by some dependencies use
// com.google.guava:guava and com.google.guava:listenablefuture together.
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
================================================
FILE: android/automl/app/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
================================================
FILE: android/automl/app/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.google.mlkit.vision.automl.demo"
android:installLocation="auto">
<!-- CameraX libraries require minSdkVersion 21, while this quickstart app
supports low to 19. Needs to use overrideLibrary to make the merger tool
ignore this conflict and import the libraries while keeping the app's lower
minSdkVersion value. In code, will check SDK version, before calling CameraX
APIs. -->
<uses-sdk
tools:overrideLibrary="
androidx.camera.camera2, androidx.camera.core,
androidx.camera.view, androidx.camera.lifecycle" />
<uses-feature android:name="android.hardware.camera"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<application
android:name="androidx.multidex.MultiDexApplication"
android:icon="@drawable/logo_mlkit"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat">
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<meta-data
android:name="com.google.mlkit.vision.DEPENDENCIES"
android:value="custom_ica"/>
<activity
android:name=".ChooserActivity"
android:exported="true"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".LivePreviewActivity"
android:exported="true"
android:theme="@style/AppTheme">
</activity>
<activity
android:name=".CameraXLivePreviewActivity"
android:exported="true"
android:theme="@style/AppTheme">
</activity>
<activity
android:name=".StillImageActivity"
android:exported="true"
android:theme="@style/AppTheme">
</activity>
<activity
android:name=".preference.SettingsActivity"
android:exported="false"/>
</application>
<queries>
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
</queries>
</manifest>
================================================
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/BitmapUtils.java
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.mlkit.vision.automl.demo;
import static java.lang.Math.min;
import android.content.ContentResolver;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.ImageFormat;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.YuvImage;
import android.media.Image;
import android.media.Image.Plane;
import android.net.Uri;
import android.os.Build.VERSION_CODES;
import android.provider.MediaStore;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.camera.core.ExperimentalGetImage;
import androidx.camera.core.ImageProxy;
import androidx.exifinterface.media.ExifInterface;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
/** Utils functions for bitmap conversions. */
public final class BitmapUtils {
private static final String TAG = "BitmapUtils";
/** Converts NV21 format byte buffer to bitmap. */
@Nullable
public static Bitmap getBitmap(ByteBuffer data, FrameMetadata metadata) {
data.rewind();
byte[] imageInBuffer = new byte[data.limit()];
data.get(imageInBuffer, 0, imageInBuffer.length);
try {
YuvImage image =
new YuvImage(
imageInBuffer, ImageFormat.NV21, metadata.getWidth(), metadata.getHeight(), null);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
image.compressToJpeg(new Rect(0, 0, metadata.getWidth(), metadata.getHeight()), 80, stream);
Bitmap bmp = BitmapFactory.decodeByteArray(stream.toByteArray(), 0, stream.size());
stream.close();
return rotateBitmap(bmp, metadata.getRotation(), false, false);
} catch (Exception e) {
Log.e("VisionProcessorBase", "Error: " + e.getMessage());
}
return null;
}
/** Converts a YUV_420_888 image from CameraX API to a bitmap. */
@RequiresApi(VERSION_CODES.LOLLIPOP)
@Nullable
@ExperimentalGetImage
public static Bitmap getBitmap(ImageProxy image) {
FrameMetadata frameMetadata =
new FrameMetadata.Builder()
.setWidth(image.getWidth())
.setHeight(image.getHeight())
.setRotation(image.getImageInfo().getRotationDegrees())
.build();
ByteBuffer nv21Buffer =
yuv420ThreePlanesToNV21(image.getImage().getPlanes(), image.getWidth(), image.getHeight());
return getBitmap(nv21Buffer, frameMetadata);
}
/** Rotates a bitmap if it is converted from a bytebuffer. */
private static Bitmap rotateBitmap(
Bitmap bitmap, int rotationDegrees, boolean flipX, boolean flipY) {
Matrix matrix = new Matrix();
// Rotate the image back to straight.
matrix.postRotate(rotationDegrees);
// Mirror the image along the X or Y axis.
matrix.postScale(flipX ? -1.0f : 1.0f, flipY ? -1.0f : 1.0f);
Bitmap rotatedBitmap =
Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
// Recycle the old bitmap if it has changed.
if (rotatedBitmap != bitmap) {
bitmap.recycle();
}
return rotatedBitmap;
}
@Nullable
public static Bitmap getBitmapFromAsset(Context context, String fileName) {
InputStream inputStream = null;
try {
inputStream = context.getAssets().open(fileName);
return BitmapFactory.decodeStream(inputStream);
} catch (IOException e) {
Log.e(TAG, "Error reading asset: " + fileName, e);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
Log.e(TAG, "Failed to close input stream: ", e);
}
}
}
return null;
}
@Nullable
public static Bitmap getBitmapFromContentUri(ContentResolver contentResolver, Uri imageUri)
throws IOException {
Bitmap decodedBitmap = MediaStore.Images.Media.getBitmap(contentResolver, imageUri);
if (decodedBitmap == null) {
return null;
}
int orientation = getExifOrientationTag(contentResolver, imageUri);
int rotationDegrees = 0;
boolean flipX = false;
boolean flipY = false;
// See e.g. https://magnushoff.com/articles/jpeg-orientation/ for a detailed explanation on each
// orientation.
switch (orientation) {
case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
flipX = true;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
rotationDegrees = 90;
break;
case ExifInterface.ORIENTATION_TRANSPOSE:
rotationDegrees = 90;
flipX = true;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotationDegrees = 180;
break;
case ExifInterface.ORIENTATION_FLIP_VERTICAL:
flipY = true;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
rotationDegrees = -90;
break;
case ExifInterface.ORIENTATION_TRANSVERSE:
rotationDegrees = -90;
flipX = true;
break;
case ExifInterface.ORIENTATION_UNDEFINED:
case ExifInterface.ORIENTATION_NORMAL:
default:
// No transformations necessary in this case.
}
return rotateBitmap(decodedBitmap, rotationDegrees, flipX, flipY);
}
private static int getExifOrientationTag(ContentResolver resolver, Uri imageUri) {
// We only support parsing EXIF orientation tag from local file on the device.
// See also:
// https://android-developers.googleblog.com/2016/12/introducing-the-exifinterface-support-library.html
if (!ContentResolver.SCHEME_CONTENT.equals(imageUri.getScheme())
&& !ContentResolver.SCHEME_FILE.equals(imageUri.getScheme())) {
return 0;
}
ExifInterface exif;
try (InputStream inputStream = resolver.openInputStream(imageUri)) {
if (inputStream == null) {
return 0;
}
exif = new ExifInterface(inputStream);
} catch (IOException e) {
Log.e(TAG, "failed to open file to read rotation meta data: " + imageUri, e);
return 0;
}
return exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
}
public static ByteBuffer convertBitmapToNv21Buffer(Bitmap bitmap) {
return ByteBuffer.wrap(convertBitmapToNv21Bytes(bitmap));
}
public static byte[] convertBitmapToNv21Bytes(Bitmap bitmap) {
int inputWidth = bitmap.getWidth();
int inputHeight = bitmap.getHeight();
int[] argb = new int[inputWidth * inputHeight];
bitmap.getPixels(argb, 0, inputWidth, 0, 0, inputWidth, inputHeight);
byte[] nv21Bytes =
new byte
[inputHeight * inputWidth
+ 2 * (int) Math.ceil(inputHeight / 2.0) * (int) Math.ceil(inputWidth / 2.0)];
encodeToNv21(nv21Bytes, argb, inputWidth, inputHeight);
return nv21Bytes;
}
private static void encodeToNv21(byte[] nv21Bytes, int[] argb, int width, int height) {
int frameSize = width * height;
int yIndex = 0;
int uvIndex = frameSize;
int red;
int green;
int blue;
int y;
int u;
int v;
int index = 0;
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
// first byte is alpha, but is unused
red = (argb[index] & 0xff0000) >> 16;
green = (argb[index] & 0xff00) >> 8;
blue = (argb[index] & 0xff) >> 0;
// well known RGB to YUV algorithm
y = ((66 * red + 129 * green + 25 * blue + 128) >> 8) + 16;
u = ((-38 * red - 74 * green + 112 * blue + 128) >> 8) + 128;
v = ((112 * red - 94 * green - 18 * blue + 128) >> 8) + 128;
// NV21 has a plane of Y and interleaved planes of VU each sampled by a factor of 2
// meaning for every 4 Y pixels there are 1 V and 1 U. Note the sampling is every other
// pixel AND every other scanline.
nv21Bytes[yIndex++] = (byte) ((y < 0) ? 0 : min(255, y));
if (j % 2 == 0 && index % 2 == 0) {
nv21Bytes[uvIndex++] = (byte) ((v < 0) ? 0 : min(255, v));
nv21Bytes[uvIndex++] = (byte) ((u < 0) ? 0 : min(255, u));
}
index++;
}
}
}
public static ByteBuffer convertBitmapToYv12Buffer(Bitmap bitmap) {
return ByteBuffer.wrap(convertBitmapToYv12Bytes(bitmap));
}
public static byte[] convertBitmapToYv12Bytes(Bitmap bitmap) {
byte[] nv21Bytes = convertBitmapToNv21Bytes(bitmap);
return nv21Toyv12(nv21Bytes);
}
/**
* Converts nv21 byte[] to yv12 byte[].
*
* <p>NV21 (4:2:0) Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y V U V U V U V U V U V U
*
* <p>YV12 (4:2:0) Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y V V V V V V U U U U U U
*/
private static byte[] nv21Toyv12(byte[] nv21Bytes) {
int totalBytes = nv21Bytes.length;
int rowSize = totalBytes / 6; // 4+2+0
byte[] yv12Bytes = new byte[totalBytes];
System.arraycopy(nv21Bytes, 0, yv12Bytes, 0, rowSize * 4);
int offSet = totalBytes / 6 * 4;
for (int i = 0; i < rowSize; i++) {
yv12Bytes[offSet + i] = nv21Bytes[offSet + 2 * i]; // V
yv12Bytes[offSet + rowSize + i] = nv21Bytes[offSet + 2 * i + 1]; // U
}
return yv12Bytes;
}
/**
* Converts YUV_420_888 to NV21 bytebuffer.
*
* <p>The NV21 format consists of a single byte array containing the Y, U and V values. For an
* image of size S, the first S positions of the array contain all the Y values. The remaining
* positions contain interleaved V and U values. U and V are subsampled by a factor of 2 in both
* dimensions, so there are S/4 U values and S/4 V values. In summary, the NV21 array will contain
* S Y values followed by S/4 VU values: YYYYYYYYYYYYYY(...)YVUVUVUVU(...)VU
*
* <p>YUV_420_888 is a generic format that can describe any YUV image where U and V are subsampled
* by a factor of 2 in both dimensions. {@link Image#getPlanes} returns an array with the Y, U and
* V planes. The Y plane is guaranteed not to be interleaved, so we can just copy its values into
* the first part of the NV21 array. The U and V planes may already have the representation in the
* NV21 format. This happens if the planes share the same buffer, the V buffer is one position
* before the U buffer and the planes have a pixelStride of 2. If this is case, we can just copy
* them to the NV21 array.
*/
private static ByteBuffer yuv420ThreePlanesToNV21(
Plane[] yuv420888planes, int width, int height) {
int imageSize = width * height;
byte[] out = new byte[imageSize + 2 * (imageSize / 4)];
if (areUVPlanesNV21(yuv420888planes, width, height)) {
// Copy the Y values.
yuv420888planes[0].getBuffer().get(out, 0, imageSize);
ByteBuffer uBuffer = yuv420888planes[1].getBuffer();
ByteBuffer vBuffer = yuv420888planes[2].getBuffer();
// Get the first V value from the V buffer, since the U buffer does not contain it.
vBuffer.get(out, imageSize, 1);
// Copy the first U value and the remaining VU values from the U buffer.
uBuffer.get(out, imageSize + 1, 2 * imageSize / 4 - 1);
} else {
// Fallback to copying the UV values one by one, which is slower but also works.
// Unpack Y.
unpackPlane(yuv420888planes[0], width, height, out, 0, 1);
// Unpack U.
unpackPlane(yuv420888planes[1], width, height, out, imageSize + 1, 2);
// Unpack V.
unpackPlane(yuv420888planes[2], width, height, out, imageSize, 2);
}
return ByteBuffer.wrap(out);
}
/** Checks if the UV plane buffers of a YUV_420_888 image are in the NV21 format. */
private static boolean areUVPlanesNV21(Plane[] planes, int width, int height) {
int imageSize = width * height;
ByteBuffer uBuffer = planes[1].getBuffer();
ByteBuffer vBuffer = planes[2].getBuffer();
// Backup buffer properties.
int vBufferPosition = vBuffer.position();
int uBufferLimit = uBuffer.limit();
// Advance the V buffer by 1 byte, since the U buffer will not contain the first V value.
vBuffer.position(vBufferPosition + 1);
// Chop off the last byte of the U buffer, since the V buffer will not contain the last U value.
uBuffer.limit(uBufferLimit - 1);
// Check that the buffers are equal and have the expected number of elements.
boolean areNV21 =
(vBuffer.remaining() == (2 * imageSize / 4 - 2)) && (vBuffer.compareTo(uBuffer) == 0);
// Restore buffers to their initial state.
vBuffer.position(vBufferPosition);
uBuffer.limit(uBufferLimit);
return areNV21;
}
/**
* Unpack an image plane into a byte array.
*
* <p>The input plane data will be copied in 'out', starting at 'offset' and every pixel will be
* spaced by 'pixelStride'. Note that there is no row padding on the output.
*/
private static void unpackPlane(
Plane plane, int width, int height, byte[] out, int offset, int pixelStride) {
ByteBuffer buffer = plane.getBuffer();
buffer.rewind();
// Compute the size of the current plane.
// We assume that it has the aspect ratio as the original image.
int numRow = (buffer.limit() + plane.getRowStride() - 1) / plane.getRowStride();
if (numRow == 0) {
return;
}
int scaleFactor = height / numRow;
int numCol = width / scaleFactor;
// Extract the data in the output buffer.
int outputPos = offset;
int rowStart = 0;
for (int row = 0; row < numRow; row++) {
int inputPos = rowStart;
for (int col = 0; col < numCol; col++) {
out[outputPos] = buffer.get(inputPos);
outputPos += pixelStride;
inputPos += plane.getPixelStride();
}
rowStart += plane.getRowStride();
}
}
private BitmapUtils() {}
}
================================================
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/CameraImageGraphic.java
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.mlkit.vision.automl.demo;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import com.google.mlkit.vision.automl.demo.GraphicOverlay.Graphic;
/** Draw camera image to background. */
public class CameraImageGraphic extends Graphic {
private final Bitmap bitmap;
public CameraImageGraphic(GraphicOverlay overlay, Bitmap bitmap) {
super(overlay);
this.bitmap = bitmap;
}
@Override
public void draw(Canvas canvas) {
canvas.drawBitmap(bitmap, getTransformationMatrix(), null);
}
}
================================================
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/CameraSource.java
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.mlkit.vision.automl.demo;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.ImageFormat;
import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;
import android.util.Log;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.WindowManager;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresPermission;
import com.google.android.gms.common.images.Size;
import com.google.mlkit.vision.automl.demo.preference.PreferenceUtils;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.List;
/**
* Manages the camera and allows UI updates on top of it (e.g. overlaying extra Graphics or
* displaying extra information). This receives preview frames from the camera at a specified rate,
* sending those frames to child classes' detectors / classifiers as fast as it is able to process.
*/
public class CameraSource {
@SuppressLint("InlinedApi")
public static final int CAMERA_FACING_BACK = CameraInfo.CAMERA_FACING_BACK;
@SuppressLint("InlinedApi")
public static final int CAMERA_FACING_FRONT = CameraInfo.CAMERA_FACING_FRONT;
public static final int IMAGE_FORMAT = ImageFormat.NV21;
public static final int DEFAULT_REQUESTED_CAMERA_PREVIEW_WIDTH = 480;
public static final int DEFAULT_REQUESTED_CAMERA_PREVIEW_HEIGHT = 360;
private static final String TAG = "MIDemoApp:CameraSource";
/**
* The dummy surface texture must be assigned a chosen name. Since we never use an OpenGL context,
* we can choose any ID we want here. The dummy surface texture is not a crazy hack - it is
* actually how the camera team recommends using the camera without a preview.
*/
private static final int DUMMY_TEXTURE_NAME = 100;
/**
* If the absolute difference between a preview size aspect ratio and a picture size aspect ratio
* is less than this tolerance, they are considered to be the same aspect ratio.
*/
private static final float ASPECT_RATIO_TOLERANCE = 0.01f;
private static final float REQUESTED_FPS = 30.0f;
private static final boolean REQUESTED_AUTO_FOCUS = true;
protected Activity activity;
private Camera camera;
private int facing = CAMERA_FACING_BACK;
/** Rotation of the device, and thus the associated preview images captured from the device. */
private int rotationDegrees;
private Size previewSize;
// These instances need to be held onto to avoid GC of their underlying resources. Even though
// these aren't used outside of the method that creates them, they still must have hard
// references maintained to them.
private SurfaceTexture dummySurfaceTexture;
private final GraphicOverlay graphicOverlay;
// True if a SurfaceTexture is being used for the preview, false if a SurfaceHolder is being
// used for the preview. We want to be compatible back to Gingerbread, but SurfaceTexture
// wasn't introduced until Honeycomb. Since the interface cannot use a SurfaceTexture, if the
// developer wants to display a preview we must use a SurfaceHolder. If the developer doesn't
// want to display a preview we use a SurfaceTexture if we are running at least Honeycomb.
private boolean usingSurfaceTexture;
/**
* Dedicated thread and associated runnable for calling into the detector with frames, as the
* frames become available from the camera.
*/
private Thread processingThread;
private final FrameProcessingRunnable processingRunnable;
private final Object processorLock = new Object();
// TODO(b/74400062) Re-enable the annotaion
// @GuardedBy("processorLock")
private VisionImageProcessor frameProcessor;
/**
* Map to convert between a byte array, received from the camera, and its associated byte buffer.
* We use byte buffers internally because this is a more efficient way to call into native code
* later (avoids a potential copy).
*
* <p><b>Note:</b> uses IdentityHashMap here instead of HashMap because the behavior of an array's
* equals, hashCode and toString methods is both useless and unexpected. IdentityHashMap enforces
* identity ('==') check on the keys.
*/
private final IdentityHashMap<byte[], ByteBuffer> bytesToByteBuffer = new IdentityHashMap<>();
public CameraSource(Activity activity, GraphicOverlay overlay) {
this.activity = activity;
graphicOverlay = overlay;
graphicOverlay.clear();
processingRunnable = new FrameProcessingRunnable();
}
// ==============================================================================================
// Public
// ==============================================================================================
/** Stops the camera and releases the resources of the camera and underlying detector. */
public void release() {
synchronized (processorLock) {
stop();
cleanScreen();
if (frameProcessor != null) {
frameProcessor.stop();
}
}
}
/**
* Opens the camera and starts sending preview frames to the underlying detector. The preview
* frames are not displayed.
*
* @throws IOException if the camera's preview texture or display could not be initialized
*/
@RequiresPermission(Manifest.permission.CAMERA)
public synchronized CameraSource start() throws IOException {
if (camera != null) {
return this;
}
camera = createCamera();
dummySurfaceTexture = new SurfaceTexture(DUMMY_TEXTURE_NAME);
camera.setPreviewTexture(dummySurfaceTexture);
usingSurfaceTexture = true;
camera.startPreview();
processingThread = new Thread(processingRunnable);
processingRunnable.setActive(true);
processingThread.start();
return this;
}
/**
* Opens the camera and starts sending preview frames to the underlying detector. The supplied
* surface holder is used for the preview so frames can be displayed to the user.
*
* @param surfaceHolder the surface holder to use for the preview frames
* @throws IOException if the supplied surface holder could not be used as the preview display
*/
@RequiresPermission(Manifest.permission.CAMERA)
public synchronized CameraSource start(SurfaceHolder surfaceHolder) throws IOException {
if (camera != null) {
return this;
}
camera = createCamera();
camera.setPreviewDisplay(surfaceHolder);
camera.startPreview();
processingThread = new Thread(processingRunnable);
processingRunnable.setActive(true);
processingThread.start();
usingSurfaceTexture = false;
return this;
}
/**
* Closes the camera and stops sending frames to the underlying frame detector.
*
* <p>This camera source may be restarted again by calling {@link #start()} or {@link
* #start(SurfaceHolder)}.
*
* <p>Call {@link #release()} instead to completely shut down this camera source and release the
* resources of the underlying detector.
*/
public synchronized void stop() {
processingRunnable.setActive(false);
if (processingThread != null) {
try {
// Wait for the thread to complete to ensure that we can't have multiple threads
// executing at the same time (i.e., which would happen if we called start too
// quickly after stop).
processingThread.join();
} catch (InterruptedException e) {
Log.d(TAG, "Frame processing thread interrupted on release.");
}
processingThread = null;
}
if (camera != null) {
camera.stopPreview();
camera.setPreviewCallbackWithBuffer(null);
try {
if (usingSurfaceTexture) {
camera.setPreviewTexture(null);
} else {
camera.setPreviewDisplay(null);
}
} catch (Exception e) {
Log.e(TAG, "Failed to clear camera preview: " + e);
}
camera.release();
camera = null;
}
// Release the reference to any image buffers, since these will no longer be in use.
bytesToByteBuffer.clear();
}
/** Changes the facing of the camera. */
public synchronized void setFacing(int facing) {
if ((facing != CAMERA_FACING_BACK) && (facing != CAMERA_FACING_FRONT)) {
throw new IllegalArgumentException("Invalid camera: " + facing);
}
this.facing = facing;
}
/** Returns the preview size that is currently in use by the underlying camera. */
public Size getPreviewSize() {
return previewSize;
}
/**
* Returns the selected camera; one of {@link #CAMERA_FACING_BACK} or {@link
* #CAMERA_FACING_FRONT}.
*/
public int getCameraFacing() {
return facing;
}
/**
* Opens the camera and applies the user settings.
*
* @throws IOException if camera cannot be found or preview cannot be processed
*/
@SuppressLint("InlinedApi")
private Camera createCamera() throws IOException {
int requestedCameraId = getIdForRequestedCamera(facing);
if (requestedCameraId == -1) {
throw new IOException("Could not find requested camera.");
}
Camera camera = Camera.open(requestedCameraId);
SizePair sizePair = PreferenceUtils.getCameraPreviewSizePair(activity, requestedCameraId);
if (sizePair == null) {
sizePair =
selectSizePair(
camera,
DEFAULT_REQUESTED_CAMERA_PREVIEW_WIDTH,
DEFAULT_REQUESTED_CAMERA_PREVIEW_HEIGHT);
}
if (sizePair == null) {
throw new IOException("Could not find suitable preview size.");
}
previewSize = sizePair.preview;
Log.v(TAG, "Camera preview size: " + previewSize);
int[] previewFpsRange = selectPreviewFpsRange(camera, REQUESTED_FPS);
if (previewFpsRange == null) {
throw new IOException("Could not find suitable preview frames per second range.");
}
Camera.Parameters parameters = camera.getParameters();
Size pictureSize = sizePair.picture;
if (pictureSize != null) {
Log.v(TAG, "Camera picture size: " + pictureSize);
parameters.setPictureSize(pictureSize.getWidth(), pictureSize.getHeight());
}
parameters.setPreviewSize(previewSize.getWidth(), previewSize.getHeight());
parameters.setPreviewFpsRange(
previewFpsRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
previewFpsRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
// Use YV12 so that we can exercise YV12->NV21 auto-conversion logic for OCR detection
parameters.setPreviewFormat(IMAGE_FORMAT);
setRotation(camera, parameters, requestedCameraId);
if (REQUESTED_AUTO_FOCUS) {
if (parameters
.getSupportedFocusModes()
.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
} else {
Log.i(TAG, "Camera auto focus is not supported on this device.");
}
}
camera.setParameters(parameters);
// Four frame buffers are needed for working with the camera:
//
// one for the frame that is currently being executed upon in doing detection
// one for the next pending frame to process immediately upon completing detection
// two for the frames that the camera uses to populate future preview images
//
// Through trial and error it appears that two free buffers, in addition to the two buffers
// used in this code, are needed for the camera to work properly. Perhaps the camera has
// one thread for acquiring images, and another thread for calling into user code. If only
// three buffers are used, then the camera will spew thousands of warning messages when
// detection takes a non-trivial amount of time.
camera.setPreviewCallbackWithBuffer(new CameraPreviewCallback());
camera.addCallbackBuffer(createPreviewBuffer(previewSize));
camera.addCallbackBuffer(createPreviewBuffer(previewSize));
camera.addCallbackBuffer(createPreviewBuffer(previewSize));
camera.addCallbackBuffer(createPreviewBuffer(previewSize));
return camera;
}
/**
* Gets the id for the camera specified by the direction it is facing. Returns -1 if no such
* camera was found.
*
* @param facing the desired camera (front-facing or rear-facing)
*/
private static int getIdForRequestedCamera(int facing) {
CameraInfo cameraInfo = new CameraInfo();
for (int i = 0; i < Camera.getNumberOfCameras(); ++i) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == facing) {
return i;
}
}
return -1;
}
/**
* Selects the most suitable preview and picture size, given the desired width and height.
*
* <p>Even though we only need to find the preview size, it's necessary to find both the preview
* size and the picture size of the camera together, because these need to have the same aspect
* ratio. On some hardware, if you would only set the preview size, you will get a distorted
* image.
*
* @param camera the camera to select a preview size from
* @param desiredWidth the desired width of the camera preview frames
* @param desiredHeight the desired height of the camera preview frames
* @return the selected preview and picture size pair
*/
public static SizePair selectSizePair(Camera camera, int desiredWidth, int desiredHeight) {
List<SizePair> validPreviewSizes = generateValidPreviewSizeList(camera);
// The method for selecting the best size is to minimize the sum of the differences between
// the desired values and the actual values for width and height. This is certainly not the
// only way to select the best size, but it provides a decent tradeoff between using the
// closest aspect ratio vs. using the closest pixel area.
SizePair selectedPair = null;
int minDiff = Integer.MAX_VALUE;
for (SizePair sizePair : validPreviewSizes) {
Size size = sizePair.preview;
int diff =
Math.abs(size.getWidth() - desiredWidth) + Math.abs(size.getHeight() - desiredHeight);
if (diff < minDiff) {
selectedPair = sizePair;
minDiff = diff;
}
}
return selectedPair;
}
/**
* Stores a preview size and a corresponding same-aspect-ratio picture size. To avoid distorted
* preview images on some devices, the picture size must be set to a size that is the same aspect
* ratio as the preview size or the preview may end up being distorted. If the picture size is
* null, then there is no picture size with the same aspect ratio as the preview size.
*/
public static class SizePair {
public final Size preview;
@Nullable public final Size picture;
SizePair(
Camera.Size previewSize,
@Nullable Camera.Size pictureSize) {
preview = new Size(previewSize.width, previewSize.height);
picture = pictureSize != null ? new Size(pictureSize.width, pictureSize.height) : null;
}
public SizePair(Size previewSize, @Nullable Size pictureSize) {
preview = previewSize;
picture = pictureSize;
}
}
/**
* Generates a list of acceptable preview sizes. Preview sizes are not acceptable if there is not
* a corresponding picture size of the same aspect ratio. If there is a corresponding picture size
* of the same aspect ratio, the picture size is paired up with the preview size.
*
* <p>This is necessary because even if we don't use still pictures, the still picture size must
* be set to a size that is the same aspect ratio as the preview size we choose. Otherwise, the
* preview images may be distorted on some devices.
*/
public static List<SizePair> generateValidPreviewSizeList(Camera camera) {
Camera.Parameters parameters = camera.getParameters();
List<Camera.Size> supportedPreviewSizes =
parameters.getSupportedPreviewSizes();
List<Camera.Size> supportedPictureSizes =
parameters.getSupportedPictureSizes();
List<SizePair> validPreviewSizes = new ArrayList<>();
for (Camera.Size previewSize : supportedPreviewSizes) {
float previewAspectRatio = (float) previewSize.width / (float) previewSize.height;
// By looping through the picture sizes in order, we favor the higher resolutions.
// We choose the highest resolution in order to support taking the full resolution
// picture later.
for (Camera.Size pictureSize : supportedPictureSizes) {
float pictureAspectRatio = (float) pictureSize.width / (float) pictureSize.height;
if (Math.abs(previewAspectRatio - pictureAspectRatio) < ASPECT_RATIO_TOLERANCE) {
validPreviewSizes.add(new SizePair(previewSize, pictureSize));
break;
}
}
}
// If there are no picture sizes with the same aspect ratio as any preview sizes, allow all
// of the preview sizes and hope that the camera can handle it. Probably unlikely, but we
// still account for it.
if (validPreviewSizes.isEmpty()) {
Log.w(TAG, "No preview sizes have a corresponding same-aspect-ratio picture size");
for (Camera.Size previewSize : supportedPreviewSizes) {
// The null picture size will let us know that we shouldn't set a picture size.
validPreviewSizes.add(new SizePair(previewSize, null));
}
}
return validPreviewSizes;
}
/**
* Selects the most suitable preview frames per second range, given the desired frames per second.
*
* @param camera the camera to select a frames per second range from
* @param desiredPreviewFps the desired frames per second for the camera preview frames
* @return the selected preview frames per second range
*/
@SuppressLint("InlinedApi")
private static int[] selectPreviewFpsRange(Camera camera, float desiredPreviewFps) {
// The camera API uses integers scaled by a factor of 1000 instead of floating-point frame
// rates.
int desiredPreviewFpsScaled = (int) (desiredPreviewFps * 1000.0f);
// The method for selecting the best range is to minimize the sum of the differences between
// the desired value and the upper and lower bounds of the range. This may select a range
// that the desired value is outside of, but this is often preferred. For example, if the
// desired frame rate is 29.97, the range (30, 30) is probably more desirable than the
// range (15, 30).
int[] selectedFpsRange = null;
int minDiff = Integer.MAX_VALUE;
List<int[]> previewFpsRangeList = camera.getParameters().getSupportedPreviewFpsRange();
for (int[] range : previewFpsRangeList) {
int deltaMin = desiredPreviewFpsScaled - range[Camera.Parameters.PREVIEW_FPS_MIN_INDEX];
int deltaMax = desiredPreviewFpsScaled - range[Camera.Parameters.PREVIEW_FPS_MAX_INDEX];
int diff = Math.abs(deltaMin) + Math.abs(deltaMax);
if (diff < minDiff) {
selectedFpsRange = range;
minDiff = diff;
}
}
return selectedFpsRange;
}
/**
* Calculates the correct rotation for the given camera id and sets the rotation in the
* parameters. It also sets the camera's display orientation and rotation.
*
* @param parameters the camera parameters for which to set the rotation
* @param cameraId the camera id to set rotation based on
*/
private void setRotation(Camera camera, Camera.Parameters parameters, int cameraId) {
WindowManager windowManager = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE);
int degrees = 0;
int rotation = windowManager.getDefaultDisplay().getRotation();
switch (rotation) {
case Surface.ROTATION_0:
degrees = 0;
break;
case Surface.ROTATION_90:
degrees = 90;
break;
case Surface.ROTATION_180:
degrees = 180;
break;
case Surface.ROTATION_270:
degrees = 270;
break;
default:
Log.e(TAG, "Bad rotation value: " + rotation);
}
CameraInfo cameraInfo = new CameraInfo();
Camera.getCameraInfo(cameraId, cameraInfo);
int displayAngle;
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT) {
this.rotationDegrees = (cameraInfo.orientation + degrees) % 360;
displayAngle = (360 - this.rotationDegrees) % 360; // compensate for it being mirrored
} else { // back-facing
this.rotationDegrees = (cameraInfo.orientation - degrees + 360) % 360;
displayAngle = this.rotationDegrees;
}
Log.d(TAG, "Display rotation is: " + rotation);
Log.d(TAG, "Camera face is: " + cameraInfo.facing);
Log.d(TAG, "Camera rotation is: " + cameraInfo.orientation);
// This value should be one of the degrees that ImageMetadata accepts: 0, 90, 180 or 270.
Log.d(TAG, "RotationDegrees is: " + this.rotationDegrees);
camera.setDisplayOrientation(displayAngle);
parameters.setRotation(this.rotationDegrees);
}
/**
* Creates one buffer for the camera preview callback. The size of the buffer is based off of the
* camera preview size and the format of the camera image.
*
* @return a new preview buffer of the appropriate size for the current camera settings
*/
@SuppressLint("InlinedApi")
private byte[] createPreviewBuffer(Size previewSize) {
int bitsPerPixel = ImageFormat.getBitsPerPixel(IMAGE_FORMAT);
long sizeInBits = (long) previewSize.getHeight() * previewSize.getWidth() * bitsPerPixel;
int bufferSize = (int) Math.ceil(sizeInBits / 8.0d) + 1;
// Creating the byte array this way and wrapping it, as opposed to using .allocate(),
// should guarantee that there will be an array to work with.
byte[] byteArray = new byte[bufferSize];
ByteBuffer buffer = ByteBuffer.wrap(byteArray);
if (!buffer.hasArray() || (buffer.array() != byteArray)) {
// I don't think that this will ever happen. But if it does, then we wouldn't be
// passing the preview content to the underlying detector later.
throw new IllegalStateException("Failed to create valid buffer for camera source.");
}
bytesToByteBuffer.put(byteArray, buffer);
return byteArray;
}
// ==============================================================================================
// Frame processing
// ==============================================================================================
/** Called when the camera has a new preview frame. */
private class CameraPreviewCallback implements Camera.PreviewCallback {
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
processingRunnable.setNextFrame(data, camera);
}
}
void setMachineLearningFrameProcessor(VisionImageProcessor processor) {
synchronized (processorLock) {
cleanScreen();
if (frameProcessor != null) {
frameProcessor.stop();
}
frameProcessor = processor;
}
}
/**
* This runnable controls access to the underlying receiver, calling it to process frames when
* available from the camera. This is designed to run detection on frames as fast as possible
* (i.e., without unnecessary context switching or waiting on the next frame).
*
* <p>While detection is running on a frame, new frames may be received from the camera. As these
* frames come in, the most recent frame is held onto as pending. As soon as detection and its
* associated processing is done for the previous frame, detection on the mostly recently received
* frame will immediately start on the same thread.
*/
private class FrameProcessingRunnable implements Runnable {
// This lock guards all of the member variables below.
private final Object lock = new Object();
private boolean active = true;
// These pending variables hold the state associated with the new frame awaiting processing.
private ByteBuffer pendingFrameData;
FrameProcessingRunnable() {}
/** Marks the runnable as active/not active. Signals any blocked threads to continue. */
void setActive(boolean active) {
synchronized (lock) {
this.active = active;
lock.notifyAll();
}
}
/**
* Sets the frame data received from the camera. This adds the previous unused frame buffer (if
* present) back to the camera, and keeps a pending reference to the frame data for future use.
*/
@SuppressWarnings("ByteBufferBackingArray")
void setNextFrame(byte[] data, Camera camera) {
synchronized (lock) {
if (pendingFrameData != null) {
camera.addCallbackBuffer(pendingFrameData.array());
pendingFrameData = null;
}
if (!bytesToByteBuffer.containsKey(data)) {
Log.d(
TAG,
"Skipping frame. Could not find ByteBuffer associated with the image "
+ "data from the camera.");
return;
}
pendingFrameData = bytesToByteBuffer.get(data);
// Notify the processor thread if it is waiting on the next frame (see below).
lock.notifyAll();
}
}
/**
* As long as the processing thread is active, this executes detection on frames continuously.
* The next pending frame is either immediately available or hasn't been received yet. Once it
* is available, we transfer the frame info to local variables and run detection on that frame.
* It immediately loops back for the next frame without pausing.
*
* <p>If detection takes longer than the time in between new frames from the camera, this will
* mean that this loop will run without ever waiting on a frame, avoiding any context switching
* or frame acquisition time latency.
*
* <p>If you find that this is using more CPU than you'd like, you should probably decrease the
* FPS setting above to allow for some idle time in between frames.
*/
@SuppressLint("InlinedApi")
@SuppressWarnings({"GuardedBy", "ByteBufferBackingArray"})
@Override
public void run() {
ByteBuffer data;
while (true) {
synchronized (lock) {
while (active && (pendingFrameData == null)) {
try {
// Wait for the next frame to be received from the camera, since we
// don't have it yet.
lock.wait();
} catch (InterruptedException e) {
Log.d(TAG, "Frame processing loop terminated.", e);
return;
}
}
if (!active) {
// Exit the loop once this camera source is stopped or released. We check
// this here, immediately after the wait() above, to handle the case where
// setActive(false) had been called, triggering the termination of this
// loop.
return;
}
// Hold onto the frame data locally, so that we can use this for detection
// below. We need to clear pendingFrameData to ensure that this buffer isn't
// recycled back to the camera before we are done using that data.
data = pendingFrameData;
pendingFrameData = null;
}
// The code below needs to run outside of synchronization, because this will allow
// the camera to add pending frame(s) while we are running detection on the current
// frame.
try {
synchronized (processorLock) {
frameProcessor.processByteBuffer(
data,
new FrameMetadata.Builder()
.setWidth(previewSize.getWidth())
.setHeight(previewSize.getHeight())
.setRotation(rotationDegrees)
.build(),
graphicOverlay);
}
} catch (Exception t) {
Log.e(TAG, "Exception thrown from receiver.", t);
} finally {
camera.addCallbackBuffer(data.array());
}
}
}
}
/** Cleans up graphicOverlay and child classes can do their cleanups as well . */
private void cleanScreen() {
graphicOverlay.clear();
}
}
================================================
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/CameraSourcePreview.java
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.mlkit.vision.automl.demo;
import android.content.Context;
import android.content.res.Configuration;
import android.util.AttributeSet;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.ViewGroup;
import com.google.android.gms.common.images.Size;
import com.google.mlkit.vision.automl.demo.preference.PreferenceUtils;
import java.io.IOException;
/** Preview the camera image in the screen. */
public class CameraSourcePreview extends ViewGroup {
private static final String TAG = "MIDemoApp:Preview";
private final Context context;
private final SurfaceView surfaceView;
private boolean startRequested;
private boolean surfaceAvailable;
private CameraSource cameraSource;
private GraphicOverlay overlay;
public CameraSourcePreview(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
startRequested = false;
surfaceAvailable = false;
surfaceView = new SurfaceView(context);
surfaceView.getHolder().addCallback(new SurfaceCallback());
addView(surfaceView);
}
private void start(CameraSource cameraSource) throws IOException {
this.cameraSource = cameraSource;
if (this.cameraSource != null) {
startRequested = true;
startIfReady();
}
}
public void start(CameraSource cameraSource, GraphicOverlay overlay) throws IOException {
this.overlay = overlay;
start(cameraSource);
}
public void stop() {
if (cameraSource != null) {
cameraSource.stop();
}
}
public void release() {
if (cameraSource != null) {
cameraSource.release();
cameraSource = null;
}
surfaceView.getHolder().getSurface().release();
}
private void startIfReady() throws IOException, SecurityException {
if (startRequested && surfaceAvailable) {
if (PreferenceUtils.isCameraLiveViewportEnabled(context)) {
cameraSource.start(surfaceView.getHolder());
} else {
cameraSource.start();
}
requestLayout();
if (overlay != null) {
Size size = cameraSource.getPreviewSize();
int min = Math.min(size.getWidth(), size.getHeight());
int max = Math.max(size.getWidth(), size.getHeight());
boolean isImageFlipped = cameraSource.getCameraFacing() == CameraSource.CAMERA_FACING_FRONT;
if (isPortraitMode()) {
// Swap width and height sizes when in portrait, since it will be rotated by 90 degrees.
// The camera preview and the image being processed have the same size.
overlay.setImageSourceInfo(min, max, isImageFlipped);
} else {
overlay.setImageSourceInfo(max, min, isImageFlipped);
}
overlay.clear();
}
startRequested = false;
}
}
private class SurfaceCallback implements SurfaceHolder.Callback {
@Override
public void surfaceCreated(SurfaceHolder surface) {
surfaceAvailable = true;
try {
startIfReady();
} catch (IOException e) {
Log.e(TAG, "Could not start camera source.", e);
}
}
@Override
public void surfaceDestroyed(SurfaceHolder surface) {
surfaceAvailable = false;
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
int width = 320;
int height = 240;
if (cameraSource != null) {
Size size = cameraSource.getPreviewSize();
if (size != null) {
width = size.getWidth();
height = size.getHeight();
}
}
// Swap width and height sizes when in portrait, since it will be rotated 90 degrees
if (isPortraitMode()) {
int tmp = width;
width = height;
height = tmp;
}
final int layoutWidth = right - left;
final int layoutHeight = bottom - top;
// Computes height and width for potentially doing fit width.
int childWidth = layoutWidth;
int childHeight = (int) (((float) layoutWidth / (float) width) * height);
// If height is too tall using fit width, does fit height instead.
if (childHeight > layoutHeight) {
childHeight = layoutHeight;
childWidth = (int) (((float) layoutHeight / (float) height) * width);
}
for (int i = 0; i < getChildCount(); ++i) {
getChildAt(i).layout(0, 0, childWidth, childHeight);
Log.d(TAG, "Assigned view: " + i);
}
}
private boolean isPortraitMode() {
int orientation = context.getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
return false;
}
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
return true;
}
Log.d(TAG, "isPortraitMode returning false by default");
return false;
}
}
================================================
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/CameraXLivePreviewActivity.java
================================================
/*
* Copyright 2020 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.mlkit.vision.automl.demo;
import android.content.Intent;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.util.Size;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.Toast;
import android.widget.ToggleButton;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.camera.core.CameraInfoUnavailableException;
import androidx.camera.core.CameraSelector;
import androidx.camera.core.ImageAnalysis;
import androidx.camera.core.Preview;
import androidx.camera.lifecycle.ProcessCameraProvider;
import androidx.camera.view.PreviewView;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProvider.AndroidViewModelFactory;
import com.google.android.gms.common.annotation.KeepName;
import com.google.mlkit.common.MlKitException;
import com.google.mlkit.common.model.CustomRemoteModel;
import com.google.mlkit.linkfirebase.FirebaseModelSource;
import com.google.mlkit.vision.automl.demo.automl.AutoMLImageLabelerProcessor;
import com.google.mlkit.vision.automl.demo.automl.AutoMLImageLabelerProcessor.Mode;
import com.google.mlkit.vision.automl.demo.object.ObjectDetectorProcessor;
import com.google.mlkit.vision.automl.demo.preference.PreferenceUtils;
import com.google.mlkit.vision.automl.demo.preference.SettingsActivity;
import com.google.mlkit.vision.label.custom.CustomImageLabelerOptions;
import com.google.mlkit.vision.objects.custom.CustomObjectDetectorOptions;
import java.util.ArrayList;
import java.util.List;
/** Live preview demo app for ML Kit APIs using CameraX. */
@KeepName
@RequiresApi(VERSION_CODES.LOLLIPOP)
public final class CameraXLivePreviewActivity extends AppCompatActivity
implements OnItemSelectedListener, CompoundButton.OnCheckedChangeListener {
private static final String TAG = "CameraXLivePreview";
private static final String CUSTOM_AUTOML_LABELING = "Custom AutoML Image Labeling";
private static final String CUSTOM_AUTOML_OBJECT_DETECTION = "Custom AutoML Object Detection";
private static final String STATE_SELECTED_MODEL = "selected_model";
private static final String STATE_LENS_FACING = "lens_facing";
private PreviewView previewView;
private GraphicOverlay graphicOverlay;
@Nullable private ProcessCameraProvider cameraProvider;
@Nullable private Preview previewUseCase;
@Nullable private ImageAnalysis analysisUseCase;
@Nullable private VisionImageProcessor imageProcessor;
private boolean needUpdateGraphicOverlayImageSourceInfo;
private String selectedModel = CUSTOM_AUTOML_LABELING;
private int lensFacing = CameraSelector.LENS_FACING_BACK;
private CameraSelector cameraSelector;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate");
if (savedInstanceState != null) {
selectedModel = savedInstanceState.getString(STATE_SELECTED_MODEL, CUSTOM_AUTOML_LABELING);
lensFacing = savedInstanceState.getInt(STATE_LENS_FACING, CameraSelector.LENS_FACING_BACK);
}
cameraSelector = new CameraSelector.Builder().requireLensFacing(lensFacing).build();
setContentView(R.layout.activity_camerax_live_preview);
previewView = findViewById(R.id.preview_view);
if (previewView == null) {
Log.d(TAG, "previewView is null");
}
graphicOverlay = findViewById(R.id.graphic_overlay);
if (graphicOverlay == null) {
Log.d(TAG, "graphicOverlay is null");
}
Spinner spinner = findViewById(R.id.spinner);
List<String> options = new ArrayList<>();
options.add(CUSTOM_AUTOML_LABELING);
options.add(CUSTOM_AUTOML_OBJECT_DETECTION);
// Creating adapter for spinner
ArrayAdapter<String> dataAdapter = new ArrayAdapter<>(this, R.layout.spinner_style, options);
// Drop down layout style - list view with radio button
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// attaching data adapter to spinner
spinner.setAdapter(dataAdapter);
spinner.setOnItemSelectedListener(this);
ToggleButton facingSwitch = findViewById(R.id.facing_switch);
facingSwitch.setOnCheckedChangeListener(this);
new ViewModelProvider(this, AndroidViewModelFactory.getInstance(getApplication()))
.get(CameraXViewModel.class)
.getProcessCameraProvider()
.observe(
this,
provider -> {
cameraProvider = provider;
bindAllCameraUseCases();
});
ImageView settingsButton = findViewById(R.id.settings_button);
settingsButton.setOnClickListener(
v -> {
Intent intent = new Intent(getApplicationContext(), SettingsActivity.class);
intent.putExtra(
SettingsActivity.EXTRA_LAUNCH_SOURCE,
SettingsActivity.LaunchSource.CAMERAX_LIVE_PREVIEW);
startActivity(intent);
});
}
@Override
protected void onSaveInstanceState(@NonNull Bundle bundle) {
super.onSaveInstanceState(bundle);
bundle.putString(STATE_SELECTED_MODEL, selectedModel);
bundle.putInt(STATE_LENS_FACING, lensFacing);
}
@Override
public synchronized void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
// An item was selected. You can retrieve the selected item using
// parent.getItemAtPosition(pos)
selectedModel = parent.getItemAtPosition(pos).toString();
Log.d(TAG, "Selected model: " + selectedModel);
bindAnalysisUseCase();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// Do nothing.
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Log.d(TAG, "Set facing");
if (cameraProvider == null) {
return;
}
int newLensFacing =
lensFacing == CameraSelector.LENS_FACING_FRONT
? CameraSelector.LENS_FACING_BACK
: CameraSelector.LENS_FACING_FRONT;
CameraSelector newCameraSelector =
new CameraSelector.Builder().requireLensFacing(newLensFacing).build();
try {
if (cameraProvider.hasCamera(newCameraSelector)) {
lensFacing = newLensFacing;
cameraSelector = newCameraSelector;
bindAllCameraUseCases();
return;
}
} catch (CameraInfoUnavailableException e) {
// Falls through
}
Toast.makeText(
getApplicationContext(),
"This device does not have lens with facing: " + newLensFacing,
Toast.LENGTH_SHORT)
.show();
}
@Override
public void onResume() {
super.onResume();
bindAllCameraUseCases();
}
@Override
protected void onPause() {
super.onPause();
if (imageProcessor != null) {
imageProcessor.stop();
}
}
@Override
public void onDestroy() {
super.onDestroy();
if (imageProcessor != null) {
imageProcessor.stop();
}
}
private void bindAllCameraUseCases() {
bindPreviewUseCase();
bindAnalysisUseCase();
}
private void bindPreviewUseCase() {
if (!PreferenceUtils.isCameraLiveViewportEnabled(this)) {
return;
}
if (cameraProvider == null) {
return;
}
if (previewUseCase != null) {
cameraProvider.unbind(previewUseCase);
}
Preview.Builder builder = new Preview.Builder();
Size targetResolution = PreferenceUtils.getCameraXTargetResolution(this, lensFacing);
if (targetResolution != null) {
builder.setTargetResolution(targetResolution);
}
previewUseCase = builder.build();
previewUseCase.setSurfaceProvider(previewView.getSurfaceProvider());
cameraProvider.bindToLifecycle(/* lifecycleOwner= */ this, cameraSelector, previewUseCase);
}
private void bindAnalysisUseCase() {
if (cameraProvider == null) {
return;
}
if (analysisUseCase != null) {
cameraProvider.unbind(analysisUseCase);
}
if (imageProcessor != null) {
imageProcessor.stop();
}
try {
String autoMLRemoteModelName = PreferenceUtils.getAutoMLRemoteModelName(this);
switch (selectedModel) {
case CUSTOM_AUTOML_LABELING:
Log.i(TAG, "Create Custom AutoML Image Label Processor");
CustomRemoteModel customRemoteModel =
new CustomRemoteModel.Builder(
new FirebaseModelSource.Builder(autoMLRemoteModelName).build())
.build();
CustomImageLabelerOptions customImageLabelerOptions =
new CustomImageLabelerOptions.Builder(customRemoteModel)
.setConfidenceThreshold(0)
.build();
imageProcessor =
new AutoMLImageLabelerProcessor(
this, customRemoteModel, customImageLabelerOptions, Mode.LIVE_PREVIEW);
break;
case CUSTOM_AUTOML_OBJECT_DETECTION:
Log.i(TAG, "Using Custom AutoML Object Detector Processor");
CustomRemoteModel customODTRemoteModel =
new CustomRemoteModel.Builder(
new FirebaseModelSource.Builder(autoMLRemoteModelName).build())
.build();
CustomObjectDetectorOptions customAutoMLODTOptions =
new CustomObjectDetectorOptions.Builder(customODTRemoteModel)
.setDetectorMode(CustomObjectDetectorOptions.STREAM_MODE)
.enableClassification()
.setClassificationConfidenceThreshold(0)
.setMaxPerObjectLabelCount(1)
.build();
imageProcessor =
new ObjectDetectorProcessor(this, customODTRemoteModel, customAutoMLODTOptions);
gitextract_e0cwqdyw/
├── .github/
│ └── ISSUE_TEMPLATE/
│ ├── bug_report.md
│ └── feature_request.md
├── .gitignore
├── LICENSE
├── README.md
├── android/
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── android-snippets/
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── example/
│ │ │ │ └── mlkit/
│ │ │ │ ├── BarcodeScanningActivity.java
│ │ │ │ ├── FaceDetectionActivity.java
│ │ │ │ ├── ImageLabelingActivity.java
│ │ │ │ ├── LanguageIdentificationActivity.java
│ │ │ │ ├── MLKitVisionImage.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── ObjectDetectionActivity.java
│ │ │ │ ├── TextRecognitionActivity.java
│ │ │ │ └── kotlin/
│ │ │ │ ├── BarcodeScanningActivity.kt
│ │ │ │ ├── FaceDetectionActivity.kt
│ │ │ │ ├── ImageLabelingActivity.kt
│ │ │ │ ├── LanguageIdentificationActivity.kt
│ │ │ │ ├── MLKitVisionImage.kt
│ │ │ │ ├── MainActivity.kt
│ │ │ │ ├── ObjectDetectionActivity.kt
│ │ │ │ └── TextRecognitionActivity.kt
│ │ │ └── res/
│ │ │ ├── layout/
│ │ │ │ └── activity_main.xml
│ │ │ ├── values/
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ └── values-w820dp/
│ │ │ └── dimens.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── automl/
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── vision/
│ │ │ │ └── automl/
│ │ │ │ └── demo/
│ │ │ │ ├── BitmapUtils.java
│ │ │ │ ├── CameraImageGraphic.java
│ │ │ │ ├── CameraSource.java
│ │ │ │ ├── CameraSourcePreview.java
│ │ │ │ ├── CameraXLivePreviewActivity.java
│ │ │ │ ├── CameraXViewModel.java
│ │ │ │ ├── ChooserActivity.java
│ │ │ │ ├── FrameMetadata.java
│ │ │ │ ├── GraphicOverlay.java
│ │ │ │ ├── InferenceInfoGraphic.java
│ │ │ │ ├── LivePreviewActivity.java
│ │ │ │ ├── ScopedExecutor.java
│ │ │ │ ├── StillImageActivity.java
│ │ │ │ ├── VisionImageProcessor.java
│ │ │ │ ├── VisionProcessorBase.java
│ │ │ │ ├── automl/
│ │ │ │ │ ├── AutoMLImageLabelerProcessor.java
│ │ │ │ │ └── LabelGraphic.java
│ │ │ │ ├── object/
│ │ │ │ │ ├── ObjectDetectorProcessor.java
│ │ │ │ │ └── ObjectGraphic.java
│ │ │ │ └── preference/
│ │ │ │ ├── CameraXLivePreviewPreferenceFragment.java
│ │ │ │ ├── LivePreviewPreferenceFragment.java
│ │ │ │ ├── PreferenceUtils.java
│ │ │ │ ├── SettingsActivity.java
│ │ │ │ └── StillImagePreferenceFragment.java
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ └── logo_mlkit.xml
│ │ │ ├── drawable-hdpi/
│ │ │ │ └── ic_switch_camera_white_48dp.xml
│ │ │ ├── drawable-mdpi/
│ │ │ │ └── ic_switch_camera_white_48dp.xml
│ │ │ ├── drawable-xhdpi/
│ │ │ │ └── ic_switch_camera_white_48dp.xml
│ │ │ ├── drawable-xxhdpi/
│ │ │ │ └── ic_switch_camera_white_48dp.xml
│ │ │ ├── drawable-xxxhdpi/
│ │ │ │ └── ic_switch_camera_white_48dp.xml
│ │ │ ├── layout/
│ │ │ │ ├── activity_camerax_live_preview.xml
│ │ │ │ ├── activity_chooser.xml
│ │ │ │ ├── activity_live_preview.xml
│ │ │ │ ├── activity_settings.xml
│ │ │ │ ├── activity_still_image.xml
│ │ │ │ ├── settings_style.xml
│ │ │ │ ├── spinner_style.xml
│ │ │ │ └── toggle_style.xml
│ │ │ ├── layout-land/
│ │ │ │ ├── activity_camerax_live_preview.xml
│ │ │ │ └── activity_live_preview.xml
│ │ │ ├── menu/
│ │ │ │ └── camera_button_menu.xml
│ │ │ ├── values/
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ └── xml/
│ │ │ ├── preference_live_preview_automl.xml
│ │ │ └── preference_still_image.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── codescanner/
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── samples/
│ │ │ │ └── codescanner/
│ │ │ │ ├── EntryChoiceActivity.kt
│ │ │ │ ├── java/
│ │ │ │ │ └── MainActivity.java
│ │ │ │ └── kotlin/
│ │ │ │ └── MainActivity.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ └── logo_mlkit.xml
│ │ │ ├── layout/
│ │ │ │ └── activity_main.xml
│ │ │ └── values/
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── digitalink/
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── samples/
│ │ │ │ └── vision/
│ │ │ │ └── digitalink/
│ │ │ │ └── recognition/
│ │ │ │ ├── DigitalInkMainActivity.java
│ │ │ │ ├── DrawingView.java
│ │ │ │ ├── ModelManager.java
│ │ │ │ ├── RecognitionTask.java
│ │ │ │ ├── StatusTextView.java
│ │ │ │ ├── StrokeManager.java
│ │ │ │ └── kotlin/
│ │ │ │ ├── DigitalInkMainActivity.kt
│ │ │ │ ├── DrawingView.kt
│ │ │ │ ├── ModelManager.kt
│ │ │ │ ├── RecognitionTask.kt
│ │ │ │ ├── StatusTextView.kt
│ │ │ │ └── StrokeManager.kt
│ │ │ └── res/
│ │ │ ├── layout/
│ │ │ │ ├── activity_digital_ink_main.xml
│ │ │ │ └── activity_digital_ink_main_kotlin.xml
│ │ │ └── values/
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── documentscanner/
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── samples/
│ │ │ │ └── documentscanner/
│ │ │ │ ├── EntryChoiceActivity.kt
│ │ │ │ ├── java/
│ │ │ │ │ └── MainActivity.java
│ │ │ │ └── kotlin/
│ │ │ │ └── MainActivity.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ └── logo_mlkit.xml
│ │ │ ├── layout/
│ │ │ │ └── activity_main.xml
│ │ │ ├── values/
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ └── xml/
│ │ │ └── file_paths.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── entityextraction/
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── samples/
│ │ │ │ └── nl/
│ │ │ │ └── entityextraction/
│ │ │ │ ├── EntryChoiceActivity.kt
│ │ │ │ ├── java/
│ │ │ │ │ ├── MainActivityJava.java
│ │ │ │ │ └── ModelsActivityJava.java
│ │ │ │ └── kotlin/
│ │ │ │ ├── MainActivityKotlin.kt
│ │ │ │ └── ModelsActivityKotlin.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ ├── ic_baseline_delete_gray_32.xml
│ │ │ │ ├── ic_baseline_get_app_gray_32.xml
│ │ │ │ ├── ic_baseline_get_app_white_32.xml
│ │ │ │ └── logo_mlkit.xml
│ │ │ ├── layout/
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── activity_models.xml
│ │ │ │ └── list_item.xml
│ │ │ ├── menu/
│ │ │ │ └── menu_choose_model.xml
│ │ │ └── values/
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── build.gradle
│ │ ├── gradle.properties
│ │ └── settings.gradle
│ ├── genai/
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── genai/
│ │ │ │ └── demo/
│ │ │ │ ├── ContentAdapter.kt
│ │ │ │ ├── ContentItem.kt
│ │ │ │ ├── EntryChoiceActivity.kt
│ │ │ │ ├── GenerationConfigDialog.kt
│ │ │ │ ├── GenerationConfigUtils.kt
│ │ │ │ ├── java/
│ │ │ │ │ ├── BaseActivity.java
│ │ │ │ │ ├── ImageDescriptionActivity.java
│ │ │ │ │ ├── OpenPromptActivity.java
│ │ │ │ │ ├── ProofreadingActivity.java
│ │ │ │ │ ├── RewritingActivity.java
│ │ │ │ │ ├── SummarizationActivity.java
│ │ │ │ │ └── TextInputBaseActivity.java
│ │ │ │ └── kotlin/
│ │ │ │ ├── BaseActivity.kt
│ │ │ │ ├── ImageDescriptionActivity.kt
│ │ │ │ ├── OpenPromptActivity.kt
│ │ │ │ ├── ProofreadingActivity.kt
│ │ │ │ ├── RewritingActivity.kt
│ │ │ │ ├── SummarizationActivity.kt
│ │ │ │ └── TextInputBaseActivity.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ ├── edit_text_background_chat.xml
│ │ │ │ ├── ic_add_photo.xml
│ │ │ │ ├── ic_send.xml
│ │ │ │ ├── list_item_background.xml
│ │ │ │ ├── request_item_background.xml
│ │ │ │ └── response_item_background.xml
│ │ │ ├── layout/
│ │ │ │ ├── activity_entry_choice.xml
│ │ │ │ ├── activity_image_description.xml
│ │ │ │ ├── activity_openprompt.xml
│ │ │ │ ├── activity_proofreading.xml
│ │ │ │ ├── activity_rewrite.xml
│ │ │ │ ├── activity_summarization.xml
│ │ │ │ ├── dialog_generation_config.xml
│ │ │ │ ├── entry_choice_item.xml
│ │ │ │ ├── row_item_request_image.xml
│ │ │ │ ├── row_item_request_text.xml
│ │ │ │ ├── row_item_request_text_and_images.xml
│ │ │ │ └── row_item_response.xml
│ │ │ ├── menu/
│ │ │ │ └── menu_main.xml
│ │ │ └── values/
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── themes.xml
│ │ ├── build.gradle
│ │ ├── gradle.properties
│ │ └── settings.gradle
│ ├── internal/
│ │ ├── chooserx/
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── mlkit/
│ │ │ │ └── example/
│ │ │ │ └── internal/
│ │ │ │ ├── BaseEntryChoiceActivity.java
│ │ │ │ ├── Choice.java
│ │ │ │ └── ChoiceAdapter.java
│ │ │ └── res/
│ │ │ └── layout/
│ │ │ ├── activity_entry_choice.xml
│ │ │ └── item_choice.xml
│ │ ├── lint/
│ │ │ ├── build.gradle
│ │ │ ├── gradle/
│ │ │ │ └── wrapper/
│ │ │ │ ├── gradle-wrapper.jar
│ │ │ │ └── gradle-wrapper.properties
│ │ │ ├── gradlew
│ │ │ ├── gradlew.bat
│ │ │ └── src/
│ │ │ ├── main/
│ │ │ │ └── java/
│ │ │ │ └── com/
│ │ │ │ └── mlkit/
│ │ │ │ └── lint/
│ │ │ │ ├── HungarianNotationDetector.kt
│ │ │ │ ├── InvalidImportDetector.kt
│ │ │ │ └── QuickstartIssueRegistry.kt
│ │ │ └── test/
│ │ │ └── java/
│ │ │ └── com/
│ │ │ └── mlkit/
│ │ │ └── lint/
│ │ │ └── InvalidImportDetectorTest.kt
│ │ └── lintchecks/
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ ├── proguard-rules.pro
│ │ └── src/
│ │ └── main/
│ │ └── AndroidManifest.xml
│ ├── langid/
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── samples/
│ │ │ │ └── nl/
│ │ │ │ └── languageid/
│ │ │ │ ├── EntryChoiceActivity.kt
│ │ │ │ ├── java/
│ │ │ │ │ └── MainActivityJava.java
│ │ │ │ └── kotlin/
│ │ │ │ └── MainActivityKotlin.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ └── logo_mlkit.xml
│ │ │ ├── layout/
│ │ │ │ └── activity_main.xml
│ │ │ └── values/
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── material-showcase/
│ │ ├── .editorconfig
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── assets/
│ │ │ │ └── custom_models/
│ │ │ │ └── bird_classifier.tflite
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── md/
│ │ │ │ ├── CustomModelObjectDetectionActivity.kt
│ │ │ │ ├── InputInfo.kt
│ │ │ │ ├── LiveBarcodeScanningActivity.kt
│ │ │ │ ├── LiveObjectDetectionActivity.kt
│ │ │ │ ├── MainActivity.kt
│ │ │ │ ├── ScopedExecutor.kt
│ │ │ │ ├── StaticObjectDetectionActivity.kt
│ │ │ │ ├── TaskExt.kt
│ │ │ │ ├── Utils.kt
│ │ │ │ ├── barcodedetection/
│ │ │ │ │ ├── BarcodeConfirmingGraphic.kt
│ │ │ │ │ ├── BarcodeField.kt
│ │ │ │ │ ├── BarcodeFieldAdapter.kt
│ │ │ │ │ ├── BarcodeGraphicBase.kt
│ │ │ │ │ ├── BarcodeLoadingGraphic.kt
│ │ │ │ │ ├── BarcodeProcessor.kt
│ │ │ │ │ ├── BarcodeResultFragment.kt
│ │ │ │ │ └── BarcodeReticleGraphic.kt
│ │ │ │ ├── camera/
│ │ │ │ │ ├── CameraReticleAnimator.kt
│ │ │ │ │ ├── CameraSizePair.kt
│ │ │ │ │ ├── CameraSource.kt
│ │ │ │ │ ├── CameraSourcePreview.kt
│ │ │ │ │ ├── FrameMetadata.kt
│ │ │ │ │ ├── FrameProcessor.kt
│ │ │ │ │ ├── FrameProcessorBase.kt
│ │ │ │ │ ├── GraphicOverlay.kt
│ │ │ │ │ └── WorkflowModel.kt
│ │ │ │ ├── objectdetection/
│ │ │ │ │ ├── DetectedObjectInfo.kt
│ │ │ │ │ ├── MultiObjectProcessor.kt
│ │ │ │ │ ├── ObjectConfirmationController.kt
│ │ │ │ │ ├── ObjectConfirmationGraphic.kt
│ │ │ │ │ ├── ObjectDotAnimator.kt
│ │ │ │ │ ├── ObjectDotGraphic.kt
│ │ │ │ │ ├── ObjectGraphicInMultiMode.kt
│ │ │ │ │ ├── ObjectGraphicInProminentMode.kt
│ │ │ │ │ ├── ObjectReticleGraphic.kt
│ │ │ │ │ ├── ProminentObjectProcessor.kt
│ │ │ │ │ └── StaticObjectDotView.kt
│ │ │ │ ├── productsearch/
│ │ │ │ │ ├── BottomSheetScrimView.kt
│ │ │ │ │ ├── ImageDownloadTask.kt
│ │ │ │ │ ├── PreviewCardAdapter.kt
│ │ │ │ │ ├── Product.kt
│ │ │ │ │ ├── ProductAdapter.kt
│ │ │ │ │ ├── SearchEngine.kt
│ │ │ │ │ └── SearchedObject.kt
│ │ │ │ └── settings/
│ │ │ │ ├── PreferenceUtils.kt
│ │ │ │ ├── SettingsActivity.kt
│ │ │ │ └── SettingsFragment.kt
│ │ │ └── res/
│ │ │ ├── animator/
│ │ │ │ ├── bottom_prompt_chip_enter.xml
│ │ │ │ ├── search_button_enter.xml
│ │ │ │ └── static_image_dot_enter.xml
│ │ │ ├── drawable/
│ │ │ │ ├── barcode_field_box.xml
│ │ │ │ ├── camera_flash.xml
│ │ │ │ ├── ic_close_vd_white_24.xml
│ │ │ │ ├── ic_flash_off_vd_white_24.xml
│ │ │ │ ├── ic_flash_on_vd_white_24.xml
│ │ │ │ ├── ic_image_search_vd_black_24.xml
│ │ │ │ ├── ic_launcher_background.xml
│ │ │ │ ├── ic_photo_library_vd_white_24.xml
│ │ │ │ ├── ic_settings_vd_white_24.xml
│ │ │ │ ├── logo_mlkit.xml
│ │ │ │ └── top_action_bar_scrim.xml
│ │ │ ├── layout/
│ │ │ │ ├── activity_live_barcode.xml
│ │ │ │ ├── activity_live_object.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── activity_settings.xml
│ │ │ │ ├── activity_static_object.xml
│ │ │ │ ├── barcode_bottom_sheet.xml
│ │ │ │ ├── barcode_field.xml
│ │ │ │ ├── camera_preview_overlay.xml
│ │ │ │ ├── detection_mode_item.xml
│ │ │ │ ├── product_bottom_sheet.xml
│ │ │ │ ├── product_item.xml
│ │ │ │ ├── products_preview_card.xml
│ │ │ │ ├── top_action_bar_in_live_camera.xml
│ │ │ │ └── top_action_bar_in_static_image.xml
│ │ │ ├── values/
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ ├── values-v21/
│ │ │ │ └── styles.xml
│ │ │ └── xml/
│ │ │ └── preferences.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── smartreply/
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── samples/
│ │ │ │ └── nl/
│ │ │ │ └── smartreply/
│ │ │ │ ├── EntryChoiceActivity.kt
│ │ │ │ ├── java/
│ │ │ │ │ ├── MainActivityJava.java
│ │ │ │ │ ├── chat/
│ │ │ │ │ │ ├── ChatFragment.java
│ │ │ │ │ │ ├── ChatViewModel.java
│ │ │ │ │ │ ├── MessageListAdapter.java
│ │ │ │ │ │ └── ReplyChipAdapter.java
│ │ │ │ │ └── model/
│ │ │ │ │ └── Message.java
│ │ │ │ └── kotlin/
│ │ │ │ ├── MainActivityKotlin.kt
│ │ │ │ ├── chat/
│ │ │ │ │ ├── ChatFragment.kt
│ │ │ │ │ ├── ChatViewModel.kt
│ │ │ │ │ ├── MessageListAdapter.kt
│ │ │ │ │ └── ReplyChipAdapter.kt
│ │ │ │ └── model/
│ │ │ │ └── Message.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ ├── ic_camera_front_black_24dp.xml
│ │ │ │ ├── ic_launcher_background.xml
│ │ │ │ ├── ic_tag_faces_black_24dp.xml
│ │ │ │ ├── logo_mlkit.xml
│ │ │ │ ├── rounded_rectangle_blue.xml
│ │ │ │ ├── rounded_rectangle_gray.xml
│ │ │ │ └── rounded_rectangle_light_gray.xml
│ │ │ ├── drawable-v24/
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── layout/
│ │ │ │ ├── chat_fragment.xml
│ │ │ │ ├── item_message_local.xml
│ │ │ │ ├── item_message_remote.xml
│ │ │ │ ├── main_smartreply_activity.xml
│ │ │ │ └── smart_reply_chip.xml
│ │ │ ├── menu/
│ │ │ │ └── chat_fragment_actions.xml
│ │ │ └── values/
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── speech/
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── genai/
│ │ │ │ └── speech/
│ │ │ │ └── demo/
│ │ │ │ └── SpeechRecognitionActivity.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ ├── ic_launcher_background.xml
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── layout/
│ │ │ │ └── activity_speech_recognition.xml
│ │ │ ├── mipmap-anydpi/
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ └── values/
│ │ │ ├── arrays.xml
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── themes.xml
│ │ ├── build.gradle
│ │ ├── gradle.properties
│ │ └── settings.gradle
│ ├── translate/
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── samples/
│ │ │ │ └── nl/
│ │ │ │ └── translate/
│ │ │ │ ├── EntryChoiceActivity.kt
│ │ │ │ ├── java/
│ │ │ │ │ ├── MainActivity.java
│ │ │ │ │ ├── TranslateFragment.java
│ │ │ │ │ └── TranslateViewModel.java
│ │ │ │ └── kotlin/
│ │ │ │ ├── MainActivity.kt
│ │ │ │ ├── TranslateFragment.kt
│ │ │ │ └── TranslateViewModel.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ ├── ic_baseline_delete_24.xml
│ │ │ │ ├── ic_baseline_translate_32.xml
│ │ │ │ ├── ic_compare_arrows_black_24dp.xml
│ │ │ │ ├── ic_file_download_white_24dp.xml
│ │ │ │ └── logo_mlkit.xml
│ │ │ ├── layout/
│ │ │ │ ├── activity_translate_main.xml
│ │ │ │ └── translate_fragment.xml
│ │ │ └── values/
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ ├── translate-showcase/
│ │ ├── README.md
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ ├── proguard-rules.pro
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── google/
│ │ │ │ └── mlkit/
│ │ │ │ └── showcase/
│ │ │ │ └── translate/
│ │ │ │ ├── MainActivity.kt
│ │ │ │ ├── analyzer/
│ │ │ │ │ └── TextAnalyzer.kt
│ │ │ │ ├── main/
│ │ │ │ │ ├── MainFragment.kt
│ │ │ │ │ └── MainViewModel.kt
│ │ │ │ └── util/
│ │ │ │ ├── ImageUtils.kt
│ │ │ │ ├── Language.kt
│ │ │ │ ├── ResultOrError.kt
│ │ │ │ ├── ScopedExecutor.kt
│ │ │ │ └── SmoothedMutableLiveData.kt
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ └── logo_mlkit.xml
│ │ │ ├── layout/
│ │ │ │ ├── main_fragment.xml
│ │ │ │ └── main_translateshowcase_activity.xml
│ │ │ └── values/
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ └── vision-quickstart/
│ ├── LICENSE
│ ├── README.md
│ ├── app/
│ │ ├── build.gradle
│ │ └── src/
│ │ └── main/
│ │ ├── AndroidManifest.xml
│ │ ├── assets/
│ │ │ ├── automl/
│ │ │ │ ├── dict.txt
│ │ │ │ ├── manifest.json
│ │ │ │ └── model.tflite
│ │ │ ├── custom_models/
│ │ │ │ ├── bird_classifier.tflite
│ │ │ │ └── object_labeler.tflite
│ │ │ └── pose/
│ │ │ └── fitness_pose_samples.csv
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── google/
│ │ │ └── mlkit/
│ │ │ └── vision/
│ │ │ └── demo/
│ │ │ ├── BitmapUtils.java
│ │ │ ├── CameraImageGraphic.java
│ │ │ ├── CameraSource.java
│ │ │ ├── CameraSourcePreview.java
│ │ │ ├── CameraXViewModel.java
│ │ │ ├── EntryChoiceActivity.kt
│ │ │ ├── FrameMetadata.java
│ │ │ ├── GraphicOverlay.java
│ │ │ ├── InferenceInfoGraphic.java
│ │ │ ├── ScopedExecutor.java
│ │ │ ├── TemperatureMonitor.java
│ │ │ ├── VisionImageProcessor.java
│ │ │ ├── java/
│ │ │ │ ├── CameraXLivePreviewActivity.java
│ │ │ │ ├── CameraXSourceDemoActivity.java
│ │ │ │ ├── ChooserActivity.java
│ │ │ │ ├── LivePreviewActivity.java
│ │ │ │ ├── StillImageActivity.java
│ │ │ │ ├── VisionProcessorBase.java
│ │ │ │ ├── barcodescanner/
│ │ │ │ │ ├── BarcodeGraphic.java
│ │ │ │ │ └── BarcodeScannerProcessor.java
│ │ │ │ ├── facedetector/
│ │ │ │ │ ├── FaceDetectorProcessor.java
│ │ │ │ │ └── FaceGraphic.java
│ │ │ │ ├── facemeshdetector/
│ │ │ │ │ ├── FaceMeshDetectorProcessor.java
│ │ │ │ │ └── FaceMeshGraphic.java
│ │ │ │ ├── labeldetector/
│ │ │ │ │ ├── LabelDetectorProcessor.java
│ │ │ │ │ └── LabelGraphic.java
│ │ │ │ ├── objectdetector/
│ │ │ │ │ ├── ObjectDetectorProcessor.java
│ │ │ │ │ └── ObjectGraphic.java
│ │ │ │ ├── posedetector/
│ │ │ │ │ ├── PoseDetectorProcessor.java
│ │ │ │ │ ├── PoseGraphic.java
│ │ │ │ │ └── classification/
│ │ │ │ │ ├── ClassificationResult.java
│ │ │ │ │ ├── EMASmoothing.java
│ │ │ │ │ ├── PoseClassifier.java
│ │ │ │ │ ├── PoseClassifierProcessor.java
│ │ │ │ │ ├── PoseEmbedding.java
│ │ │ │ │ ├── PoseSample.java
│ │ │ │ │ ├── RepetitionCounter.java
│ │ │ │ │ └── Utils.java
│ │ │ │ ├── segmenter/
│ │ │ │ │ ├── SegmentationGraphic.java
│ │ │ │ │ └── SegmenterProcessor.java
│ │ │ │ ├── subjectsegmenter/
│ │ │ │ │ ├── SubjectSegmentationGraphic.java
│ │ │ │ │ └── SubjectSegmenterProcessor.java
│ │ │ │ └── textdetector/
│ │ │ │ ├── TextGraphic.java
│ │ │ │ └── TextRecognitionProcessor.java
│ │ │ ├── kotlin/
│ │ │ │ ├── CameraXLivePreviewActivity.kt
│ │ │ │ ├── CameraXSourceDemoActivity.kt
│ │ │ │ ├── ChooserActivity.kt
│ │ │ │ ├── LivePreviewActivity.kt
│ │ │ │ ├── StillImageActivity.kt
│ │ │ │ ├── TaskExt.kt
│ │ │ │ ├── VisionProcessorBase.kt
│ │ │ │ ├── barcodescanner/
│ │ │ │ │ ├── BarcodeGraphic.kt
│ │ │ │ │ └── BarcodeScannerProcessor.kt
│ │ │ │ ├── facedetector/
│ │ │ │ │ ├── FaceDetectorProcessor.kt
│ │ │ │ │ └── FaceGraphic.kt
│ │ │ │ ├── facemeshdetector/
│ │ │ │ │ ├── FaceMeshDetectorProcessor.kt
│ │ │ │ │ └── FaceMeshGraphic.kt
│ │ │ │ ├── labeldetector/
│ │ │ │ │ ├── LabelDetectorProcessor.kt
│ │ │ │ │ └── LabelGraphic.kt
│ │ │ │ ├── objectdetector/
│ │ │ │ │ ├── ObjectDetectorProcessor.kt
│ │ │ │ │ └── ObjectGraphic.kt
│ │ │ │ ├── posedetector/
│ │ │ │ │ ├── PoseDetectorProcessor.kt
│ │ │ │ │ └── PoseGraphic.kt
│ │ │ │ ├── segmenter/
│ │ │ │ │ ├── SegmentationGraphic.kt
│ │ │ │ │ └── SegmenterProcessor.kt
│ │ │ │ ├── subjectsegmenter/
│ │ │ │ │ ├── SubjectSegmentationGraphic.kt
│ │ │ │ │ └── SubjectSegmenterProcessor.kt
│ │ │ │ └── textdetector/
│ │ │ │ ├── TextGraphic.kt
│ │ │ │ └── TextRecognitionProcessor.kt
│ │ │ └── preference/
│ │ │ ├── CameraXLivePreviewPreferenceFragment.java
│ │ │ ├── CameraXSourceDemoPreferenceFragment.java
│ │ │ ├── LivePreviewPreferenceFragment.java
│ │ │ ├── PreferenceUtils.java
│ │ │ ├── SettingsActivity.java
│ │ │ └── StillImagePreferenceFragment.java
│ │ └── res/
│ │ ├── drawable/
│ │ │ ├── list_item_background.xml
│ │ │ └── logo_mlkit.xml
│ │ ├── drawable-hdpi/
│ │ │ └── ic_switch_camera_white_48dp.xml
│ │ ├── drawable-mdpi/
│ │ │ └── ic_switch_camera_white_48dp.xml
│ │ ├── drawable-xhdpi/
│ │ │ └── ic_switch_camera_white_48dp.xml
│ │ ├── drawable-xxhdpi/
│ │ │ └── ic_switch_camera_white_48dp.xml
│ │ ├── drawable-xxxhdpi/
│ │ │ └── ic_switch_camera_white_48dp.xml
│ │ ├── layout/
│ │ │ ├── activity_chooser.xml
│ │ │ ├── activity_settings.xml
│ │ │ ├── activity_still_image.xml
│ │ │ ├── activity_vision_camerax_live_preview.xml
│ │ │ ├── activity_vision_cameraxsource_demo.xml
│ │ │ ├── activity_vision_entry_choice.xml
│ │ │ ├── activity_vision_live_preview.xml
│ │ │ ├── settings_style.xml
│ │ │ ├── spinner_style.xml
│ │ │ └── toggle_style.xml
│ │ ├── layout-land/
│ │ │ ├── activity_vision_camerax_live_preview.xml
│ │ │ ├── activity_vision_cameraxsource_demo.xml
│ │ │ └── activity_vision_live_preview.xml
│ │ ├── menu/
│ │ │ └── camera_button_menu.xml
│ │ ├── values/
│ │ │ ├── arrays.xml
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── xml/
│ │ ├── preference_live_preview_quickstart.xml
│ │ └── preference_still_image.xml
│ ├── build.gradle
│ ├── gradle/
│ │ └── wrapper/
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradle.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── ios/
│ ├── ios-snippets/
│ │ ├── Podfile
│ │ ├── mlkit-snippets.xcodeproj/
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace/
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ └── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ └── dfurlong.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ └── xcschememanagement.plist
│ │ ├── mlkit-snippets.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ └── dfurlong.xcuserdatad/
│ │ │ └── xcdebugger/
│ │ │ └── Breakpoints_v2.xcbkptlist
│ │ ├── objc-snippets/
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ ├── AutoMLVision.m
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── ImagePreparation.m
│ │ │ ├── Info.plist
│ │ │ ├── ModelManagement.m
│ │ │ ├── ViewController.h
│ │ │ ├── ViewController.m
│ │ │ └── main.m
│ │ └── swift-snippets/
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets/
│ │ │ ├── AppIcon.appiconset/
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ ├── AutoMLVision.swift
│ │ ├── Base.lproj/
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── ImagePreparation.swift
│ │ ├── Info.plist
│ │ ├── ModelManagement.swift
│ │ └── ViewController.swift
│ ├── quickstarts/
│ │ ├── automl/
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Contents.json
│ │ │ │ ├── cloud_download.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── delete.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── photo_camera.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── photo_library.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── switch_camera.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── video_camera.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── AutoMLExample/
│ │ │ │ ├── AppDelegate.swift
│ │ │ │ ├── Base.lproj/
│ │ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ │ └── Main.storyboard
│ │ │ │ ├── CameraViewController.swift
│ │ │ │ ├── Info.plist
│ │ │ │ ├── MLKitExtensions.swift
│ │ │ │ ├── UIUtilities.swift
│ │ │ │ └── ViewController.swift
│ │ │ ├── AutoMLExample.xcodeproj/
│ │ │ │ └── project.pbxproj
│ │ │ ├── AutoMLExampleObjC/
│ │ │ │ ├── AppDelegate.h
│ │ │ │ ├── AppDelegate.m
│ │ │ │ ├── CameraViewController.h
│ │ │ │ ├── CameraViewController.m
│ │ │ │ ├── UIImage+VisionDetection.h
│ │ │ │ ├── UIImage+VisionDetection.m
│ │ │ │ ├── UIUtilities.h
│ │ │ │ ├── UIUtilities.m
│ │ │ │ ├── ViewController.h
│ │ │ │ ├── ViewController.m
│ │ │ │ └── main.m
│ │ │ ├── Podfile
│ │ │ ├── README.md
│ │ │ └── Resources/
│ │ │ ├── automl_labeler_labels.txt
│ │ │ ├── automl_labeler_manifest.json
│ │ │ └── automl_labeler_model.tflite
│ │ ├── digitalinkrecognition/
│ │ │ ├── DigitalInkRecognitionExample/
│ │ │ │ ├── AppDelegate.swift
│ │ │ │ ├── Info.plist
│ │ │ │ ├── RecognizedInk.swift
│ │ │ │ ├── SceneDelegate.swift
│ │ │ │ ├── StrokeManager.swift
│ │ │ │ └── ViewController.swift
│ │ │ ├── DigitalInkRecognitionExample.xcodeproj/
│ │ │ │ └── project.pbxproj
│ │ │ ├── DigitalInkRecognitionExampleObjC/
│ │ │ │ ├── AppDelegate.h
│ │ │ │ ├── AppDelegate.m
│ │ │ │ ├── Assets.xcassets/
│ │ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ │ └── Contents.json
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Base.lproj/
│ │ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ │ └── Main.storyboard
│ │ │ │ ├── RecognizedInk.h
│ │ │ │ ├── RecognizedInk.m
│ │ │ │ ├── SceneDelegate.h
│ │ │ │ ├── SceneDelegate.m
│ │ │ │ ├── StrokeManager.h
│ │ │ │ ├── StrokeManager.m
│ │ │ │ ├── ViewController.h
│ │ │ │ ├── ViewController.m
│ │ │ │ └── main.m
│ │ │ ├── Podfile
│ │ │ └── README.md
│ │ ├── entityextraction/
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── cloud_download_24pt.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── delete_24pt.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── EntityExtractionExample/
│ │ │ │ ├── AppDelegate.swift
│ │ │ │ ├── Base.lproj/
│ │ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ │ └── Main.storyboard
│ │ │ │ ├── EntityExtractionModelIdentifierExtensions.swift
│ │ │ │ ├── EntityViewController.swift
│ │ │ │ ├── Info.plist
│ │ │ │ └── ModelManagementViewController.swift
│ │ │ ├── EntityExtractionExample.xcodeproj/
│ │ │ │ └── project.pbxproj
│ │ │ ├── EntityExtractionExampleObjC/
│ │ │ │ ├── AppDelegate.h
│ │ │ │ ├── AppDelegate.m
│ │ │ │ ├── EntityViewController.h
│ │ │ │ ├── EntityViewController.m
│ │ │ │ ├── MLKEntityExtractionModelIdentifier+Extensions.h
│ │ │ │ ├── MLKEntityExtractionModelIdentifier+Extensions.m
│ │ │ │ ├── ModelManagementViewController.h
│ │ │ │ ├── ModelManagementViewController.m
│ │ │ │ └── main.m
│ │ │ ├── Podfile
│ │ │ └── README.md
│ │ ├── languageid/
│ │ │ ├── LanguageIDExample/
│ │ │ │ ├── AppDelegate.swift
│ │ │ │ ├── Assets.xcassets/
│ │ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ │ └── Contents.json
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Base.lproj/
│ │ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ │ └── Main.storyboard
│ │ │ │ ├── Info.plist
│ │ │ │ └── ViewController.swift
│ │ │ ├── LanguageIDExample.xcodeproj/
│ │ │ │ └── project.pbxproj
│ │ │ ├── LanguageIDExampleObjC/
│ │ │ │ ├── AppDelegate.h
│ │ │ │ ├── AppDelegate.m
│ │ │ │ ├── ViewController.h
│ │ │ │ ├── ViewController.m
│ │ │ │ └── main.m
│ │ │ ├── Podfile
│ │ │ └── README.md
│ │ ├── smartreply/
│ │ │ ├── Podfile
│ │ │ ├── README.md
│ │ │ ├── SmartReplyExample/
│ │ │ │ ├── AppDelegate.swift
│ │ │ │ ├── DateExtension.swift
│ │ │ │ ├── MainViewController.swift
│ │ │ │ └── UITextViewPlaceholder.swift
│ │ │ ├── SmartReplyExample.xcodeproj/
│ │ │ │ └── project.pbxproj
│ │ │ └── SmartReplyExampleObjC/
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── LaunchImage.launchimage/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── ic_account_circle_36pt.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── ic_more_vert_white.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── ic_send.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ └── Main.storyboard
│ │ │ ├── Info.plist
│ │ │ ├── LaunchScreen.xib
│ │ │ ├── MainViewController.h
│ │ │ ├── MainViewController.m
│ │ │ ├── NSDate+Format.h
│ │ │ ├── NSDate+Format.m
│ │ │ ├── UITextView+Placeholder.h
│ │ │ ├── UITextView+Placeholder.m
│ │ │ └── main.m
│ │ ├── translate/
│ │ │ ├── Podfile
│ │ │ ├── README.md
│ │ │ ├── TranslateExample/
│ │ │ │ ├── AppDelegate.swift
│ │ │ │ ├── Assets.xcassets/
│ │ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ │ └── Contents.json
│ │ │ │ │ ├── Contents.json
│ │ │ │ │ └── baseline_swap_horiz_black_48pt.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Base.lproj/
│ │ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ │ └── Main.storyboard
│ │ │ │ ├── Info.plist
│ │ │ │ └── ViewController.swift
│ │ │ ├── TranslateExample.xcodeproj/
│ │ │ │ └── project.pbxproj
│ │ │ └── TranslateExampleObjC/
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── ViewController.h
│ │ │ ├── ViewController.m
│ │ │ └── main.m
│ │ └── vision/
│ │ ├── Assets.xcassets/
│ │ │ ├── AppIcon.appiconset/
│ │ │ │ └── Contents.json
│ │ │ ├── Contents.json
│ │ │ ├── photo_camera.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── photo_library.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── switch_camera.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── video_camera.imageset/
│ │ │ └── Contents.json
│ │ ├── Podfile
│ │ ├── README.md
│ │ ├── Resources/
│ │ │ └── bird.tflite
│ │ ├── VisionExample/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── CameraViewController.swift
│ │ │ ├── Info.plist
│ │ │ ├── MLKitExtensions.swift
│ │ │ ├── UIUtilities.swift
│ │ │ └── ViewController.swift
│ │ ├── VisionExample.xcodeproj/
│ │ │ └── project.pbxproj
│ │ └── VisionExampleObjC/
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── CameraViewController.h
│ │ ├── CameraViewController.m
│ │ ├── UIImage+VisionDetection.h
│ │ ├── UIImage+VisionDetection.m
│ │ ├── UIUtilities.h
│ │ ├── UIUtilities.m
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── main.m
│ └── showcase/
│ ├── translate-showcase/
│ │ ├── Assets.xcassets/
│ │ │ ├── AppIcon.appiconset/
│ │ │ │ └── Contents.json
│ │ │ ├── Contents.json
│ │ │ ├── Image.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── baseline_check_black_24pt.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── ic_arrow_back.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── ic_close.imageset/
│ │ │ └── Contents.json
│ │ ├── Podfile
│ │ ├── README.md
│ │ ├── TranslateDemo/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Base.lproj/
│ │ │ │ └── Main.storyboard
│ │ │ ├── CVPixelBuffer+Helpers.swift
│ │ │ ├── CameraOverlayview.swift
│ │ │ ├── CameraViewController.swift
│ │ │ ├── Info.plist
│ │ │ ├── MLKitExtensions.swift
│ │ │ ├── SearchViewController.swift
│ │ │ ├── TranslateLanguage+Helpers.swift
│ │ │ └── UIUtilities.swift
│ │ ├── TranslateDemo.xcodeproj/
│ │ │ └── project.pbxproj
│ │ └── TranslateDemoTests/
│ │ ├── Info.plist
│ │ └── TranslateDemoTests.swift
│ └── vision-showcase/
│ ├── Podfile
│ ├── README.md
│ ├── ShowcaseApp/
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Base.lproj/
│ │ │ └── LaunchScreen.xib
│ │ ├── Common/
│ │ │ ├── MLKImageUtilities.h
│ │ │ ├── MLKImageUtilities.m
│ │ │ ├── MLKUIUtilities.h
│ │ │ ├── MLKUIUtilities.m
│ │ │ ├── UIImage+MLKShowcase.h
│ │ │ └── UIImage+MLKShowcase.m
│ │ ├── Controllers/
│ │ │ ├── MLKLiveObjectDetectionViewController.h
│ │ │ ├── MLKLiveObjectDetectionViewController.m
│ │ │ ├── MLKResultListViewController.h
│ │ │ ├── MLKResultListViewController.m
│ │ │ ├── MLKStartPageViewController.h
│ │ │ └── MLKStartPageViewController.m
│ │ ├── Images.xcassets/
│ │ │ ├── AppIcon.appiconset/
│ │ │ │ └── Contents.json
│ │ │ └── ic_arrow_back_ios.imageset/
│ │ │ └── Contents.json
│ │ ├── Info.plist
│ │ ├── Models/
│ │ │ ├── MLKODTStatus.h
│ │ │ ├── MLKProductSearchRequest.h
│ │ │ ├── MLKProductSearchRequest.m
│ │ │ ├── MLKResult.h
│ │ │ └── MLKResult.m
│ │ ├── Views/
│ │ │ ├── MLKCameraReticle.h
│ │ │ ├── MLKCameraReticle.m
│ │ │ ├── MLKConfirmationSpinner.h
│ │ │ ├── MLKConfirmationSpinner.m
│ │ │ ├── MLKDetectionOverlayView.h
│ │ │ ├── MLKDetectionOverlayView.m
│ │ │ ├── MLKResultCell.h
│ │ │ ├── MLKResultCell.m
│ │ │ ├── MLKResultListHeaderView.h
│ │ │ ├── MLKResultListHeaderView.m
│ │ │ ├── MLKStartPageCell.h
│ │ │ ├── MLKStartPageCell.m
│ │ │ ├── MLKStartPageHeaderView.h
│ │ │ └── MLKStartPageHeaderView.m
│ │ ├── bird.tflite
│ │ └── main.m
│ └── ShowcaseApp.xcodeproj/
│ └── project.pbxproj
└── tutorials/
├── README.md
└── mlkit_image_labeling_model_maker.ipynb
SYMBOL INDEX (951 symbols across 111 files)
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/BarcodeScanningActivity.java
class BarcodeScanningActivity (line 36) | public class BarcodeScanningActivity extends AppCompatActivity {
method onCreate (line 38) | @Override
method scanBarcodes (line 43) | private void scanBarcodes(InputImage image) {
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/FaceDetectionActivity.java
class FaceDetectionActivity (line 38) | public class FaceDetectionActivity extends AppCompatActivity {
method onCreate (line 40) | @Override
method detectFaces (line 45) | private void detectFaces(InputImage image) {
method faceOptionsExamples (line 113) | private void faceOptionsExamples() {
method processFaceList (line 131) | private void processFaceList(List<Face> faces) {
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/ImageLabelingActivity.java
class ImageLabelingActivity (line 35) | public class ImageLabelingActivity extends AppCompatActivity {
method onCreate (line 37) | @Override
method labelImages (line 42) | private void labelImages(InputImage image) {
method configureAndRunImageLabeler (line 88) | private void configureAndRunImageLabeler(InputImage image) {
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/LanguageIdentificationActivity.java
class LanguageIdentificationActivity (line 20) | public class LanguageIdentificationActivity extends AppCompatActivity {
method onCreate (line 24) | @Override
method identifyLanguageWithStringInput (line 29) | private void identifyLanguageWithStringInput(String text) {
method setConfidence (line 56) | private void setConfidence() {
method getPossibleLanguuages (line 65) | private void getPossibleLanguuages(String text) {
method setConfidenceThreshold (line 91) | private void setConfidenceThreshold() {
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/MLKitVisionImage.java
class MLKitVisionImage (line 41) | public class MLKitVisionImage {
method imageFromBitmap (line 46) | private void imageFromBitmap(Bitmap bitmap) {
method imageFromMediaImage (line 53) | @RequiresApi(api = Build.VERSION_CODES.KITKAT)
method imageFromBuffer (line 60) | private void imageFromBuffer(ByteBuffer byteBuffer, int rotationDegree...
method imageFromArray (line 75) | private void imageFromArray(byte[] byteArray, int rotation) {
method imageFromPath (line 87) | private void imageFromPath(Context context, Uri uri) {
method getRotationCompensation (line 111) | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
method getCompensation (line 135) | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/MainActivity.java
class MainActivity (line 21) | public class MainActivity extends AppCompatActivity {
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/ObjectDetectionActivity.java
class ObjectDetectionActivity (line 40) | public class ObjectDetectionActivity extends AppCompatActivity {
method onCreate (line 42) | @Override
method useDefaultObjectDetector (line 47) | private void useDefaultObjectDetector() {
method useCustomObjectDetector (line 116) | private void useCustomObjectDetector() {
FILE: android/android-snippets/app/src/main/java/com/google/example/mlkit/TextRecognitionActivity.java
class TextRecognitionActivity (line 34) | public class TextRecognitionActivity extends AppCompatActivity {
method onCreate (line 36) | @Override
method recognizeText (line 41) | private void recognizeText(InputImage image) {
method processTextBlock (line 86) | private void processTextBlock(Text result) {
method getTextRecognizer (line 112) | private TextRecognizer getTextRecognizer() {
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/BitmapUtils.java
class BitmapUtils (line 46) | public final class BitmapUtils {
method getBitmap (line 50) | @Nullable
method getBitmap (line 73) | @RequiresApi(VERSION_CODES.LOLLIPOP)
method rotateBitmap (line 90) | private static Bitmap rotateBitmap(
method getBitmapFromAsset (line 109) | @Nullable
method getBitmapFromContentUri (line 130) | @Nullable
method getExifOrientationTag (line 177) | private static int getExifOrientationTag(ContentResolver resolver, Uri...
method convertBitmapToNv21Buffer (line 201) | public static ByteBuffer convertBitmapToNv21Buffer(Bitmap bitmap) {
method convertBitmapToNv21Bytes (line 205) | public static byte[] convertBitmapToNv21Bytes(Bitmap bitmap) {
method encodeToNv21 (line 220) | private static void encodeToNv21(byte[] nv21Bytes, int[] argb, int wid...
method convertBitmapToYv12Buffer (line 260) | public static ByteBuffer convertBitmapToYv12Buffer(Bitmap bitmap) {
method convertBitmapToYv12Bytes (line 264) | public static byte[] convertBitmapToYv12Bytes(Bitmap bitmap) {
method nv21Toyv12 (line 276) | private static byte[] nv21Toyv12(byte[] nv21Bytes) {
method yuv420ThreePlanesToNV21 (line 307) | private static ByteBuffer yuv420ThreePlanesToNV21(
method areUVPlanesNV21 (line 336) | private static boolean areUVPlanesNV21(Plane[] planes, int width, int ...
method unpackPlane (line 368) | private static void unpackPlane(
method BitmapUtils (line 396) | private BitmapUtils() {}
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/CameraImageGraphic.java
class CameraImageGraphic (line 24) | public class CameraImageGraphic extends Graphic {
method CameraImageGraphic (line 28) | public CameraImageGraphic(GraphicOverlay overlay, Bitmap bitmap) {
method draw (line 33) | @Override
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/CameraSource.java
class CameraSource (line 46) | public class CameraSource {
method CameraSource (line 123) | public CameraSource(Activity activity, GraphicOverlay overlay) {
method release (line 135) | public void release() {
method start (line 152) | @RequiresPermission(Manifest.permission.CAMERA)
method start (line 177) | @RequiresPermission(Manifest.permission.CAMERA)
method stop (line 204) | public synchronized void stop() {
method setFacing (line 239) | public synchronized void setFacing(int facing) {
method getPreviewSize (line 247) | public Size getPreviewSize() {
method getCameraFacing (line 255) | public int getCameraFacing() {
method createCamera (line 264) | @SuppressLint("InlinedApi")
method getIdForRequestedCamera (line 347) | private static int getIdForRequestedCamera(int facing) {
method selectSizePair (line 371) | public static SizePair selectSizePair(Camera camera, int desiredWidth,...
class SizePair (line 399) | public static class SizePair {
method SizePair (line 403) | SizePair(
method SizePair (line 410) | public SizePair(Size previewSize, @Nullable Size pictureSize) {
method generateValidPreviewSizeList (line 425) | public static List<SizePair> generateValidPreviewSizeList(Camera camer...
method selectPreviewFpsRange (line 468) | @SuppressLint("InlinedApi")
method setRotation (line 501) | private void setRotation(Camera camera, Camera.Parameters parameters, ...
method createPreviewBuffer (line 549) | @SuppressLint("InlinedApi")
class CameraPreviewCallback (line 574) | private class CameraPreviewCallback implements Camera.PreviewCallback {
method onPreviewFrame (line 575) | @Override
method setMachineLearningFrameProcessor (line 581) | void setMachineLearningFrameProcessor(VisionImageProcessor processor) {
class FrameProcessingRunnable (line 601) | private class FrameProcessingRunnable implements Runnable {
method FrameProcessingRunnable (line 610) | FrameProcessingRunnable() {}
method setActive (line 613) | void setActive(boolean active) {
method setNextFrame (line 624) | @SuppressWarnings("ByteBufferBackingArray")
method run (line 660) | @SuppressLint("InlinedApi")
method cleanScreen (line 719) | private void cleanScreen() {
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/CameraSourcePreview.java
class CameraSourcePreview (line 31) | public class CameraSourcePreview extends ViewGroup {
method CameraSourcePreview (line 42) | public CameraSourcePreview(Context context, AttributeSet attrs) {
method start (line 53) | private void start(CameraSource cameraSource) throws IOException {
method start (line 62) | public void start(CameraSource cameraSource, GraphicOverlay overlay) t...
method stop (line 67) | public void stop() {
method release (line 73) | public void release() {
method startIfReady (line 81) | private void startIfReady() throws IOException, SecurityException {
class SurfaceCallback (line 108) | private class SurfaceCallback implements SurfaceHolder.Callback {
method surfaceCreated (line 109) | @Override
method surfaceDestroyed (line 119) | @Override
method surfaceChanged (line 124) | @Override
method onLayout (line 128) | @Override
method isPortraitMode (line 166) | private boolean isPortraitMode() {
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/CameraXLivePreviewActivity.java
class CameraXLivePreviewActivity (line 61) | @KeepName
method onCreate (line 85) | @Override
method onSaveInstanceState (line 143) | @Override
method onItemSelected (line 150) | @Override
method onNothingSelected (line 159) | @Override
method onCheckedChanged (line 164) | @Override
method onResume (line 194) | @Override
method onPause (line 200) | @Override
method onDestroy (line 208) | @Override
method bindAllCameraUseCases (line 216) | private void bindAllCameraUseCases() {
method bindPreviewUseCase (line 221) | private void bindPreviewUseCase() {
method bindAnalysisUseCase (line 242) | private void bindAnalysisUseCase() {
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/CameraXViewModel.java
class CameraXViewModel (line 33) | @RequiresApi(VERSION_CODES.LOLLIPOP)
method CameraXViewModel (line 42) | public CameraXViewModel(@NonNull Application application) {
method getProcessCameraProvider (line 46) | LiveData<ProcessCameraProvider> getProcessCameraProvider() {
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/ChooserActivity.java
class ChooserActivity (line 46) | public final class ChooserActivity extends AppCompatActivity
method onCreate (line 77) | @Override
method onItemClick (line 110) | @Override
method allPermissionsGranted (line 116) | private boolean allPermissionsGranted() {
method getRuntimePermissions (line 125) | private void getRuntimePermissions() {
method isPermissionGranted (line 139) | private static boolean isPermissionGranted(Context context, String per...
class MyArrayAdapter (line 149) | private static class MyArrayAdapter extends ArrayAdapter<Class<?>> {
method MyArrayAdapter (line 155) | MyArrayAdapter(Context context, int resource, Class<?>[] objects) {
method getView (line 162) | @Override
method setDescriptionIds (line 178) | void setDescriptionIds(int[] descriptionIds) {
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/FrameMetadata.java
class FrameMetadata (line 20) | public class FrameMetadata {
method getWidth (line 26) | public int getWidth() {
method getHeight (line 30) | public int getHeight() {
method getRotation (line 34) | public int getRotation() {
method FrameMetadata (line 38) | private FrameMetadata(int width, int height, int rotation) {
class Builder (line 45) | public static class Builder {
method setWidth (line 51) | public Builder setWidth(int width) {
method setHeight (line 56) | public Builder setHeight(int height) {
method setRotation (line 61) | public Builder setRotation(int rotation) {
method build (line 66) | public FrameMetadata build() {
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/GraphicOverlay.java
class GraphicOverlay (line 47) | public class GraphicOverlay extends View {
class Graphic (line 72) | public abstract static class Graphic {
method Graphic (line 75) | public Graphic(GraphicOverlay overlay) {
method draw (line 92) | public abstract void draw(Canvas canvas);
method scale (line 97) | public float scale(float imagePixel) {
method getApplicationContext (line 102) | public Context getApplicationContext() {
method isImageFlipped (line 106) | public boolean isImageFlipped() {
method translateX (line 113) | public float translateX(float x) {
method translateY (line 124) | public float translateY(float y) {
method getTransformationMatrix (line 131) | public Matrix getTransformationMatrix() {
method postInvalidate (line 135) | public void postInvalidate() {
method GraphicOverlay (line 140) | public GraphicOverlay(Context context, AttributeSet attrs) {
method clear (line 148) | public void clear() {
method add (line 156) | public void add(Graphic graphic) {
method remove (line 163) | public void remove(Graphic graphic) {
method setImageSourceInfo (line 179) | public void setImageSourceInfo(int imageWidth, int imageHeight, boolea...
method getImageWidth (line 191) | public int getImageWidth() {
method getImageHeight (line 195) | public int getImageHeight() {
method updateTransformationIfNeeded (line 199) | private void updateTransformationIfNeeded() {
method onDraw (line 229) | @Override
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/InferenceInfoGraphic.java
class InferenceInfoGraphic (line 25) | public class InferenceInfoGraphic extends GraphicOverlay.Graphic {
method InferenceInfoGraphic (line 37) | public InferenceInfoGraphic(
method draw (line 49) | @Override
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/LivePreviewActivity.java
class LivePreviewActivity (line 47) | @KeepName
method onCreate (line 60) | @Override
method onItemSelected (line 104) | @Override
method onNothingSelected (line 115) | @Override
method onCheckedChanged (line 120) | @Override
method createCameraSource (line 134) | private void createCameraSource(String model) {
method startCameraSource (line 191) | private void startCameraSource() {
method onResume (line 209) | @Override
method onPause (line 218) | @Override
method onDestroy (line 224) | @Override
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/ScopedExecutor.java
class ScopedExecutor (line 27) | public class ScopedExecutor implements Executor {
method ScopedExecutor (line 32) | public ScopedExecutor(@NonNull Executor executor) {
method execute (line 36) | @Override
method shutdown (line 58) | public void shutdown() {
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/StillImageActivity.java
class StillImageActivity (line 57) | @KeepName
method onCreate (line 88) | @Override
method onResume (line 151) | @Override
method populateFeatureSelector (line 159) | private void populateFeatureSelector() {
method populateSizeSelector (line 187) | private void populateSizeSelector() {
method onSaveInstanceState (line 216) | @Override
method startCameraIntentForResult (line 223) | private void startCameraIntentForResult() {
method startChooseImageIntentForResult (line 239) | private void startChooseImageIntentForResult() {
method onActivityResult (line 246) | @Override
method tryReloadAndDetectInImage (line 259) | private void tryReloadAndDetectInImage() {
method getTargetedWidthHeight (line 310) | private Pair<Integer, Integer> getTargetedWidthHeight() {
method createImageProcessor (line 334) | private void createImageProcessor() {
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/VisionImageProcessor.java
type VisionImageProcessor (line 25) | public interface VisionImageProcessor {
method processBitmap (line 28) | void processBitmap(Bitmap bitmap, GraphicOverlay graphicOverlay);
method processByteBuffer (line 31) | void processByteBuffer(
method processImageProxy (line 36) | void processImageProxy(ImageProxy image, GraphicOverlay graphicOverlay)
method stop (line 40) | void stop();
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/VisionProcessorBase.java
class VisionProcessorBase (line 48) | public abstract class VisionProcessorBase<T> implements VisionImageProce...
method VisionProcessorBase (line 84) | protected VisionProcessorBase(Context context) {
method processBitmap (line 101) | @Override
method processByteBuffer (line 111) | @Override
method processLatestImage (line 121) | private synchronized void processLatestImage(final GraphicOverlay grap...
method processImage (line 131) | private void processImage(
method processImageProxy (line 154) | @Override
method requestDetectInImage (line 180) | private Task<T> requestDetectInImage(
method stop (line 233) | @Override
method detectInImage (line 242) | protected abstract Task<T> detectInImage(InputImage image);
method onSuccess (line 244) | protected abstract void onSuccess(@NonNull T results, @NonNull Graphic...
method onFailure (line 246) | protected abstract void onFailure(@NonNull Exception e);
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/automl/AutoMLImageLabelerProcessor.java
class AutoMLImageLabelerProcessor (line 39) | public class AutoMLImageLabelerProcessor extends VisionProcessorBase<Lis...
method AutoMLImageLabelerProcessor (line 48) | public AutoMLImageLabelerProcessor(
method stop (line 69) | @Override
method detectInImage (line 75) | @Override
method processImageOnDownloadComplete (line 90) | private Task<List<ImageLabel>> processImageOnDownloadComplete(InputIma...
method onSuccess (line 106) | @Override
method onFailure (line 112) | @Override
type Mode (line 121) | public enum Mode {
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/automl/LabelGraphic.java
class LabelGraphic (line 31) | public class LabelGraphic extends GraphicOverlay.Graphic {
method LabelGraphic (line 42) | public LabelGraphic(GraphicOverlay overlay, List<ImageLabel> labels) {
method draw (line 56) | @Override
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/object/ObjectDetectorProcessor.java
class ObjectDetectorProcessor (line 39) | public class ObjectDetectorProcessor extends VisionProcessorBase<List<De...
method ObjectDetectorProcessor (line 47) | public ObjectDetectorProcessor(
method stop (line 67) | @Override
method detectInImage (line 73) | @Override
method processImageOnDownloadComplete (line 88) | private Task<List<DetectedObject>> processImageOnDownloadComplete(Inpu...
method onSuccess (line 104) | @Override
method onFailure (line 112) | @Override
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/object/ObjectGraphic.java
class ObjectGraphic (line 30) | public class ObjectGraphic extends Graphic {
method ObjectGraphic (line 56) | ObjectGraphic(GraphicOverlay overlay, DetectedObject object) {
method draw (line 81) | @Override
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/preference/CameraXLivePreviewPreferenceFragment.java
class CameraXLivePreviewPreferenceFragment (line 38) | @RequiresApi(VERSION_CODES.LOLLIPOP)
method setUpCameraPreferences (line 41) | @Override
method setUpCameraXTargetAnalysisSizePreference (line 56) | private void setUpCameraXTargetAnalysisSizePreference(
method getCameraCharacteristics (line 96) | @Nullable
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/preference/LivePreviewPreferenceFragment.java
class LivePreviewPreferenceFragment (line 33) | public class LivePreviewPreferenceFragment extends PreferenceFragment {
method onCreate (line 35) | @Override
method setUpCameraPreferences (line 44) | void setUpCameraPreferences() {
method setUpCameraPreviewSizePreference (line 61) | private void setUpCameraPreviewSizePreference(
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/preference/PreferenceUtils.java
class PreferenceUtils (line 37) | public final class PreferenceUtils {
method saveString (line 39) | static void saveString(Context context, @StringRes int prefKeyId, @Nul...
method getCameraPreviewSizePair (line 46) | @Nullable
method getCameraXTargetResolution (line 71) | @RequiresApi(VERSION_CODES.LOLLIPOP)
method isCameraLiveViewportEnabled (line 89) | public static boolean isCameraLiveViewportEnabled(Context context) {
method getAutoMLRemoteModelName (line 95) | public static String getAutoMLRemoteModelName(Context context) {
method setUpRemoteModelNamePreferences (line 106) | public static void setUpRemoteModelNamePreferences(PreferenceFragment ...
method PreferenceUtils (line 129) | private PreferenceUtils() {}
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/preference/SettingsActivity.java
class SettingsActivity (line 29) | public class SettingsActivity extends AppCompatActivity {
type LaunchSource (line 34) | @SuppressWarnings("NewApi") // CameraX is only available on API 21+
method LaunchSource (line 45) | LaunchSource(int titleResId, Class<? extends PreferenceFragment> pre...
method onCreate (line 51) | @Override
FILE: android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/preference/StillImagePreferenceFragment.java
class StillImagePreferenceFragment (line 24) | public class StillImagePreferenceFragment extends PreferenceFragment {
method onCreate (line 26) | @Override
FILE: android/codescanner/app/src/main/java/com/google/mlkit/samples/codescanner/java/MainActivity.java
class MainActivity (line 34) | public class MainActivity extends AppCompatActivity {
method onCreate (line 43) | @Override
method onAllowManualInputCheckboxClicked (line 51) | public void onAllowManualInputCheckboxClicked(View view) {
method onEnableAutoZoomCheckboxClicked (line 55) | public void onEnableAutoZoomCheckboxClicked(View view) {
method onScanButtonClicked (line 59) | public void onScanButtonClicked(View view) {
method onSaveInstanceState (line 78) | @Override
method onRestoreInstanceState (line 85) | @Override
method getSuccessfulMessage (line 92) | private String getSuccessfulMessage(Barcode barcode) {
method getErrorMessage (line 104) | @SuppressLint("SwitchIntDef")
FILE: android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/DigitalInkMainActivity.java
class DigitalInkMainActivity (line 23) | public class DigitalInkMainActivity extends AppCompatActivity
method onCreate (line 38) | @Override
method downloadClick (line 83) | public void downloadClick(View v) {
method recognizeClick (line 87) | public void recognizeClick(View v) {
method clearClick (line 91) | public void clearClick(View v) {
method deleteClick (line 97) | public void deleteClick(View v) {
class ModelLanguageContainer (line 101) | private static class ModelLanguageContainer implements Comparable<Mode...
method ModelLanguageContainer (line 106) | private ModelLanguageContainer(String label, @Nullable String langua...
method createModelContainer (line 115) | public static ModelLanguageContainer createModelContainer(String lab...
method createLabelOnly (line 121) | public static ModelLanguageContainer createLabelOnly(String label) {
method getLanguageTag (line 125) | public String getLanguageTag() {
method setDownloaded (line 129) | public void setDownloaded(boolean downloaded) {
method toString (line 133) | @NonNull
method compareTo (line 145) | @Override
method onDownloadedModelsChanged (line 151) | @Override
method populateLanguageAdapter (line 160) | private ArrayAdapter<ModelLanguageContainer> populateLanguageAdapter() {
method buildModelContainer (line 205) | private static ModelLanguageContainer buildModelContainer(
FILE: android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/DrawingView.java
class DrawingView (line 27) | public class DrawingView extends View implements ContentChangedListener {
method DrawingView (line 45) | public DrawingView(Context context) {
method DrawingView (line 49) | public DrawingView(Context context, AttributeSet attributeSet) {
method computeBoundingBox (line 72) | private static Rect computeBoundingBox(Ink ink) {
method setStrokeManager (line 105) | void setStrokeManager(StrokeManager strokeManager) {
method onSizeChanged (line 109) | @Override
method redrawContent (line 117) | public void redrawContent() {
method drawTextIntoBoundingBox (line 131) | private void drawTextIntoBoundingBox(String text, Rect bb, TextPaint t...
method drawInk (line 155) | private void drawInk(Ink ink, Paint paint) {
method drawStroke (line 161) | private void drawStroke(Stroke s, Paint paint) {
method clear (line 175) | public void clear() {
method onDraw (line 184) | @Override
method onTouchEvent (line 190) | @Override
method onContentChanged (line 216) | @Override
FILE: android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/ModelManager.java
class ModelManager (line 18) | public class ModelManager {
method setModel (line 25) | public String setModel(String languageTag) {
method getRecognizer (line 59) | public DigitalInkRecognizer getRecognizer() {
method checkIsModelDownloaded (line 63) | public Task<Boolean> checkIsModelDownloaded() {
method deleteActiveModel (line 67) | public Task<String> deleteActiveModel() {
method getDownloadedModelLanguages (line 89) | public Task<Set<String>> getDownloadedModelLanguages() {
method download (line 103) | public Task<String> download() {
FILE: android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/RecognitionTask.java
class RecognitionTask (line 12) | public class RecognitionTask {
method RecognitionTask (line 21) | public RecognitionTask(DigitalInkRecognizer recognizer, Ink ink) {
method cancel (line 29) | public void cancel() {
method done (line 33) | public boolean done() {
method result (line 37) | @Nullable
class RecognizedInk (line 43) | public static class RecognizedInk {
method RecognizedInk (line 47) | RecognizedInk(Ink ink, String text) {
method run (line 53) | public Task<String> run() {
FILE: android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/StatusTextView.java
class StatusTextView (line 14) | public class StatusTextView extends AppCompatTextView implements StatusC...
method StatusTextView (line 18) | public StatusTextView(@NonNull Context context) {
method StatusTextView (line 22) | public StatusTextView(Context context, AttributeSet attributeSet) {
method onStatusChanged (line 26) | @Override
method setStrokeManager (line 31) | void setStrokeManager(StrokeManager strokeManager) {
FILE: android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/StrokeManager.java
class StrokeManager (line 17) | public class StrokeManager {
type ContentChangedListener (line 20) | public interface ContentChangedListener {
method onContentChanged (line 23) | void onContentChanged();
type StatusChangedListener (line 27) | public interface StatusChangedListener {
method onStatusChanged (line 30) | void onStatusChanged();
type DownloadedModelsChangedListener (line 34) | public interface DownloadedModelsChangedListener {
method onDownloadedModelsChanged (line 37) | void onDownloadedModelsChanged(Set<String> downloadedLanguageTags);
method setTriggerRecognitionAfterInput (line 61) | public void setTriggerRecognitionAfterInput(boolean shouldTrigger) {
method setClearCurrentInkAfterRecognition (line 65) | public void setClearCurrentInkAfterRecognition(boolean shouldClear) {
method setStatus (line 88) | private void setStatus(String newStatus) {
method commitResult (line 95) | private void commitResult() {
method reset (line 108) | public void reset() {
method resetCurrentInk (line 118) | private void resetCurrentInk() {
method getCurrentInk (line 124) | public Ink getCurrentInk() {
method addNewTouchEvent (line 137) | public boolean addNewTouchEvent(MotionEvent event) {
method setContentChangedListener (line 169) | public void setContentChangedListener(ContentChangedListener contentCh...
method setStatusChangedListener (line 173) | public void setStatusChangedListener(StatusChangedListener statusChang...
method setDownloadedModelsChangedListener (line 177) | public void setDownloadedModelsChangedListener(
method getContent (line 182) | public List<RecognitionTask.RecognizedInk> getContent() {
method getStatus (line 186) | public String getStatus() {
method setActiveModel (line 192) | public void setActiveModel(String languageTag) {
method deleteActiveModel (line 196) | public Task<Void> deleteActiveModel() {
method download (line 207) | public Task<Void> download() {
method recognize (line 221) | public Task<String> recognize() {
method refreshDownloadedModelsStatus (line 250) | public void refreshDownloadedModelsStatus() {
FILE: android/documentscanner/app/src/main/java/com/google/mlkit/samples/documentscanner/java/MainActivity.java
class MainActivity (line 49) | public class MainActivity extends AppCompatActivity {
method onCreate (line 64) | @Override
method onEnableGalleryImportCheckboxClicked (line 78) | public void onEnableGalleryImportCheckboxClicked(View view) {
method onScanButtonClicked (line 82) | public void onScanButtonClicked(View view) {
method populateModeSelector (line 127) | private void populateModeSelector() {
method handleActivityResult (line 155) | private void handleActivityResult(ActivityResult activityResult) {
FILE: android/entityextraction/app/src/main/java/com/google/mlkit/samples/nl/entityextraction/java/MainActivityJava.java
class MainActivityJava (line 44) | public class MainActivityJava extends AppCompatActivity {
method onCreate (line 56) | @Override
method extractEntities (line 90) | public void extractEntities(final String input) {
method getEntityExtractionParams (line 120) | private static EntityExtractionParams getEntityExtractionParams(String...
method onCreateOptionsMenu (line 124) | @Override
method onOptionsItemSelected (line 130) | @Override
method onActivityResult (line 139) | @Override
method onSaveInstanceState (line 153) | @Override
method displayEntityInfo (line 159) | private void displayEntityInfo(String annotatedText, Entity entity) {
method displayAddressInfo (line 200) | private void displayAddressInfo(String annotatedText) {
method displayEmailInfo (line 204) | private void displayEmailInfo(String annotatedText) {
method displayPhoneInfo (line 208) | private void displayPhoneInfo(String annotatedText) {
method displayDefaultInfo (line 216) | private void displayDefaultInfo(String annotatedText) {
method displayUrlInfo (line 220) | private void displayUrlInfo(String annotatedText) {
method displayDateTimeInfo (line 224) | private void displayDateTimeInfo(Entity entity, String annotatedText) {
method convertGranularityToString (line 234) | private String convertGranularityToString(Entity entity) {
method displayTrackingNoInfo (line 257) | private void displayTrackingNoInfo(Entity entity, String annotatedText) {
method displayPaymentCardInfo (line 267) | private void displayPaymentCardInfo(Entity entity, String annotatedTex...
method displayIsbnInfo (line 277) | private void displayIsbnInfo(Entity entity, String annotatedText) {
method displayIbanInfo (line 282) | private void displayIbanInfo(Entity entity, String annotatedText) {
method displayFlightNoInfo (line 292) | private void displayFlightNoInfo(Entity entity, String annotatedText) {
method displayMoneyEntityInfo (line 302) | private void displayMoneyEntityInfo(Entity entity, String annotatedTex...
FILE: android/entityextraction/app/src/main/java/com/google/mlkit/samples/nl/entityextraction/java/ModelsActivityJava.java
class ModelsActivityJava (line 30) | public class ModelsActivityJava extends AppCompatActivity {
method onCreate (line 38) | @Override
class LanguageAdapter (line 57) | class LanguageAdapter extends BaseAdapter {
method LanguageAdapter (line 65) | public LanguageAdapter(List<String> languageList) {
method getCount (line 81) | @Override
method getItem (line 86) | @Override
method getItemId (line 91) | @Override
method getView (line 96) | @Override
method updateSnackbar (line 147) | private void updateSnackbar() {
method getSnackbarMessage (line 161) | private String getSnackbarMessage() {
method getFormattedListOfDownloadingModels (line 169) | private String getFormattedListOfDownloadingModels() {
FILE: android/genai/app/src/main/java/com/google/mlkit/genai/demo/java/BaseActivity.java
class BaseActivity (line 72) | abstract class BaseActivity<RequestT extends ContentItem> extends AppCom...
method onCreate (line 96) | @Override
method onPostCreate (line 130) | @Override
method onSend (line 150) | protected void onSend(RequestT request) {
method getLayoutResId (line 160) | protected abstract int getLayoutResId();
method onCreateOptionsMenu (line 162) | @Override
method onPrepareOptionsMenu (line 168) | @Override
method onOptionsItemSelected (line 183) | @Override
method checkFeatureStatus (line 197) | private void checkFeatureStatus(RequestT request) {
method checkFeatureStatus (line 222) | @FeatureStatus
method getBaseModelName (line 225) | protected abstract ListenableFuture<String> getBaseModelName();
method downloadAndRunInference (line 227) | private void downloadAndRunInference(RequestT request) {
method downloadFeature (line 274) | protected abstract ListenableFuture<Void> downloadFeature(DownloadCall...
method runInference (line 276) | private void runInference(RequestT request) {
method runInferenceWithTokenInfo (line 340) | private void runInferenceWithTokenInfo(RequestT request, String tokenI...
method runInferenceImpl (line 414) | protected abstract ListenableFuture<List<String>> runInferenceImpl(
method countTokens (line 417) | protected ListenableFuture<CountTokensResponse> countTokens(RequestT r...
method getTokenLimit (line 421) | protected ListenableFuture<Integer> getTokenLimit() {
method setupSpinner (line 425) | protected void setupSpinner(int spinnerId, int arrayId, Consumer<Integ...
method displayErrorMessage (line 444) | private void displayErrorMessage(String errorMessage) {
method displayErrorMessage (line 448) | private void displayErrorMessage(String errorMessage, @Nullable Throwa...
method startGeneratingUi (line 459) | protected void startGeneratingUi() {
method endGeneratingUi (line 463) | protected void endGeneratingUi(String debugInfo) {
method resetProcessor (line 468) | protected void resetProcessor() {
method runInferenceForBatchTask (line 472) | protected abstract List<String> runInferenceForBatchTask(String request);
method batchRun (line 485) | private void batchRun(Uri inputUri, Uri outputUri) {
FILE: android/genai/app/src/main/java/com/google/mlkit/genai/demo/java/ImageDescriptionActivity.java
class ImageDescriptionActivity (line 49) | public class ImageDescriptionActivity extends BaseActivity<ImageItem> {
method onCreate (line 55) | @Override
method getLayoutResId (line 75) | @Override
method onPrepareOptionsMenu (line 80) | @Override
method onDestroy (line 89) | @Override
method getBaseModelName (line 97) | @Override
method checkFeatureStatus (line 102) | @Override
method downloadFeature (line 107) | @Override
method countTokens (line 112) | @Override
method getTokenLimit (line 117) | @Override
method runInferenceImpl (line 122) | @Override
method startGeneratingUi (line 142) | @Override
method endGeneratingUi (line 149) | @Override
method runInferenceForBatchTask (line 156) | @Override
method initImageDescriptor (line 161) | private void initImageDescriptor() {
FILE: android/genai/app/src/main/java/com/google/mlkit/genai/demo/java/OpenPromptActivity.java
class OpenPromptActivity (line 76) | public class OpenPromptActivity extends BaseActivity<ContentItem>
method onCreate (line 116) | @Override
method onConfigUpdated (line 210) | @Override
method updateRequestEditTextHint (line 248) | private void updateRequestEditTextHint() {
method showCacheSelectionDialog (line 260) | private void showCacheSelectionDialog() {
method updatePrefixEditTextState (line 292) | private void updatePrefixEditTextState() {
method getLayoutResId (line 311) | @Override
method runInferenceImpl (line 316) | @Override
method countTokens (line 363) | @Override
method getTokenLimit (line 377) | @Override
method buildGenerateContentRequest (line 386) | private GenerateContentRequest buildGenerateContentRequest(ContentItem...
method runInferenceForBatchTask (line 437) | @Override
method startGeneratingUi (line 465) | @Override
method endGeneratingUi (line 475) | @Override
method initGenerator (line 485) | private void initGenerator() {
method createCache (line 497) | private ListenableFuture<List<String>> createCache(ContentItem.CacheRe...
method getBaseModelName (line 510) | @Override
method checkFeatureStatus (line 515) | @Override
method downloadFeature (line 520) | @Override
method onCreateOptionsMenu (line 525) | @Override
method onPrepareOptionsMenu (line 534) | @Override
method onOptionsItemSelected (line 550) | @Override
method generateExplicitCachesClearCallback (line 581) | private FutureCallback<List<CachedContext>> generateExplicitCachesClea...
method generateExplicitCacheDeleteCallback (line 619) | private FutureCallback<Boolean> generateExplicitCacheDeleteCallback(St...
method generateImplicitCachesClearCallback (line 637) | private FutureCallback<Void> generateImplicitCachesClearCallback() {
FILE: android/genai/app/src/main/java/com/google/mlkit/genai/demo/java/ProofreadingActivity.java
class ProofreadingActivity (line 49) | public class ProofreadingActivity extends TextInputBaseActivity {
method onCreate (line 56) | @Override
method getLayoutResId (line 64) | @Override
method onDestroy (line 69) | @Override
method getBaseModelName (line 77) | @Override
method checkFeatureStatus (line 82) | @Override
method downloadFeature (line 88) | @Override
method runInferenceImpl (line 93) | @Override
method setUpSpinners (line 109) | private void setUpSpinners() {
method initProofreader (line 139) | private void initProofreader() {
method countTokens (line 149) | @Override
method getTokenLimit (line 154) | @Override
method runInferenceForBatchTask (line 159) | @Override
FILE: android/genai/app/src/main/java/com/google/mlkit/genai/demo/java/RewritingActivity.java
class RewritingActivity (line 49) | public class RewritingActivity extends TextInputBaseActivity {
method onCreate (line 56) | @Override
method getLayoutResId (line 64) | @Override
method onDestroy (line 69) | @Override
method getBaseModelName (line 77) | @Override
method checkFeatureStatus (line 82) | @Override
method downloadFeature (line 88) | @Override
method countTokens (line 93) | @Override
method getTokenLimit (line 98) | @Override
method runInferenceImpl (line 103) | @Override
method setUpSpinners (line 118) | private void setUpSpinners() {
method initRewriter (line 151) | private void initRewriter() {
method runInferenceForBatchTask (line 161) | @Override
FILE: android/genai/app/src/main/java/com/google/mlkit/genai/demo/java/SummarizationActivity.java
class SummarizationActivity (line 48) | public class SummarizationActivity extends TextInputBaseActivity {
method onCreate (line 56) | @Override
method getLayoutResId (line 64) | @Override
method onDestroy (line 69) | @Override
method getBaseModelName (line 77) | @Override
method checkFeatureStatus (line 82) | @Override
method downloadFeature (line 88) | @Override
method runInferenceImpl (line 93) | @Override
method countTokens (line 106) | @Override
method getTokenLimit (line 111) | @Override
method setUpInputAndOutputTypeSpinners (line 116) | private void setUpInputAndOutputTypeSpinners() {
method initSummarizer (line 154) | private void initSummarizer() {
method runInferenceForBatchTask (line 168) | @Override
FILE: android/genai/app/src/main/java/com/google/mlkit/genai/demo/java/TextInputBaseActivity.java
class TextInputBaseActivity (line 29) | abstract class TextInputBaseActivity extends BaseActivity<TextItem> {
method onCreate (line 34) | @Override
method startGeneratingUi (line 51) | @Override
method endGeneratingUi (line 59) | @Override
FILE: android/internal/chooserx/src/main/java/com/mlkit/example/internal/BaseEntryChoiceActivity.java
class BaseEntryChoiceActivity (line 25) | public abstract class BaseEntryChoiceActivity extends AppCompatActivity {
method onCreate (line 27) | @Override
method getChoices (line 37) | protected abstract List<Choice> getChoices();
FILE: android/internal/chooserx/src/main/java/com/mlkit/example/internal/Choice.java
class Choice (line 21) | public class Choice {
method Choice (line 27) | public Choice(String title, String description, Intent launchIntent) {
FILE: android/internal/chooserx/src/main/java/com/mlkit/example/internal/ChoiceAdapter.java
class ChoiceAdapter (line 29) | public class ChoiceAdapter extends RecyclerView.Adapter<ChoiceAdapter.Vi...
method ChoiceAdapter (line 34) | public ChoiceAdapter(Activity activity, List<Choice> choices) {
method onCreateViewHolder (line 39) | @NonNull
method onBindViewHolder (line 47) | @Override
method getItemCount (line 53) | @Override
class ViewHolder (line 58) | public class ViewHolder extends RecyclerView.ViewHolder {
method ViewHolder (line 64) | public ViewHolder(View itemView) {
method bind (line 71) | public void bind(final Choice choice) {
FILE: android/langid/app/src/main/java/com/google/mlkit/samples/nl/languageid/java/MainActivityJava.java
class MainActivityJava (line 34) | public class MainActivityJava extends AppCompatActivity {
method onCreate (line 43) | @Override
method hideKeyboard (line 81) | private void hideKeyboard() {
method getInputText (line 91) | private String getInputText() {
method identifyLanguage (line 105) | private void identifyLanguage(final String inputText) {
method identifyPossibleLanguages (line 137) | private void identifyPossibleLanguages(final String inputText) {
FILE: android/smartreply/app/src/main/java/com/google/mlkit/samples/nl/smartreply/java/MainActivityJava.java
class MainActivityJava (line 25) | public class MainActivityJava extends AppCompatActivity {
method onCreate (line 27) | @Override
FILE: android/smartreply/app/src/main/java/com/google/mlkit/samples/nl/smartreply/java/chat/ChatFragment.java
class ChatFragment (line 44) | public class ChatFragment extends Fragment implements ReplyChipAdapter.C...
method newInstance (line 56) | public static ChatFragment newInstance() {
method onCreate (line 60) | @Override
method onCreateView (line 66) | @Nullable
method onViewCreated (line 75) | @SuppressLint("ClickableViewAccessibility")
method onCreateOptionsMenu (line 164) | @Override
method onOptionsItemSelected (line 170) | @Override
method onChipClick (line 187) | @Override
method generateChatHistoryBasic (line 192) | private void generateChatHistoryBasic() {
method generateChatHistoryWithSensitiveContent (line 205) | private void generateChatHistoryWithSensitiveContent() {
FILE: android/smartreply/app/src/main/java/com/google/mlkit/samples/nl/smartreply/java/chat/ChatViewModel.java
class ChatViewModel (line 41) | public class ChatViewModel extends AndroidViewModel {
method ChatViewModel (line 51) | public ChatViewModel(Application application) {
method getSuggestions (line 57) | public LiveData<List<SmartReplySuggestion>> getSuggestions() {
method getMessages (line 61) | public LiveData<List<Message>> getMessages() {
method getEmulatingRemoteUser (line 65) | public LiveData<Boolean> getEmulatingRemoteUser() {
method setMessages (line 69) | void setMessages(List<Message> messages) {
method switchUser (line 74) | void switchUser() {
method clearSuggestions (line 79) | private void clearSuggestions() {
method addMessage (line 83) | void addMessage(String message) {
method initSuggestionsGenerator (line 93) | private void initSuggestionsGenerator() {
method generateReplies (line 117) | private Task<List<SmartReplySuggestion>> generateReplies(
method onCleared (line 177) | @Override
FILE: android/smartreply/app/src/main/java/com/google/mlkit/samples/nl/smartreply/java/chat/MessageListAdapter.java
class MessageListAdapter (line 31) | class MessageListAdapter extends RecyclerView.Adapter<MessageListAdapter...
method MessageListAdapter (line 36) | public MessageListAdapter() {}
method onCreateViewHolder (line 38) | @Override
method onBindViewHolder (line 47) | @Override
method getItemViewType (line 53) | @Override
method getItemCount (line 62) | @Override
method setMessages (line 67) | public void setMessages(List<Message> messages) {
method getEmulatingRemoteUser (line 73) | public boolean getEmulatingRemoteUser() {
method setEmulatingRemoteUser (line 77) | public void setEmulatingRemoteUser(boolean emulatingRemoteUser) {
class MessageViewHolder (line 82) | static class MessageViewHolder extends RecyclerView.ViewHolder {
method MessageViewHolder (line 87) | MessageViewHolder(View itemView) {
method bind (line 93) | private void bind(Message message) {
FILE: android/smartreply/app/src/main/java/com/google/mlkit/samples/nl/smartreply/java/chat/ReplyChipAdapter.java
class ReplyChipAdapter (line 31) | public class ReplyChipAdapter extends RecyclerView.Adapter<ReplyChipAdap...
type ClickListener (line 34) | public interface ClickListener {
method onChipClick (line 36) | void onChipClick(@NonNull String chipText);
method ReplyChipAdapter (line 42) | public ReplyChipAdapter(@NonNull ClickListener listener) {
method onCreateViewHolder (line 46) | @NonNull
method onBindViewHolder (line 54) | @Override
method getItemCount (line 60) | @Override
method setSuggestions (line 65) | public void setSuggestions(List<SmartReplySuggestion> suggestions) {
class ViewHolder (line 72) | public class ViewHolder extends RecyclerView.ViewHolder {
method ViewHolder (line 76) | public ViewHolder(@NonNull View itemView) {
method bind (line 81) | public void bind(final SmartReplySuggestion suggestion) {
FILE: android/smartreply/app/src/main/java/com/google/mlkit/samples/nl/smartreply/java/model/Message.java
class Message (line 30) | public class Message {
method Message (line 36) | public Message(String text, boolean isLocalUser, long timestamp) {
method getIcon (line 42) | @NonNull
FILE: android/translate/app/src/main/java/com/google/mlkit/samples/nl/translate/java/MainActivity.java
class MainActivity (line 23) | public class MainActivity extends AppCompatActivity {
method onCreate (line 25) | @Override
FILE: android/translate/app/src/main/java/com/google/mlkit/samples/nl/translate/java/TranslateFragment.java
class TranslateFragment (line 45) | public class TranslateFragment extends Fragment {
method newInstance (line 47) | public static TranslateFragment newInstance() {
method onCreate (line 51) | @Override
method onCreateView (line 57) | @Nullable
method onViewCreated (line 66) | @SuppressLint("ClickableViewAccessibility")
method setProgressText (line 213) | private void setProgressText(TextView tv) {
FILE: android/translate/app/src/main/java/com/google/mlkit/samples/nl/translate/java/TranslateViewModel.java
class TranslateViewModel (line 50) | public class TranslateViewModel extends AndroidViewModel {
method create (line 60) | @Override
method entryRemoved (line 65) | @Override
method TranslateViewModel (line 79) | public TranslateViewModel(@NonNull Application application) {
method getAvailableLanguages (line 124) | List<Language> getAvailableLanguages() {
method getModel (line 133) | private TranslateRemoteModel getModel(String languageCode) {
method fetchDownloadedModels (line 138) | private void fetchDownloadedModels() {
method downloadLanguage (line 156) | void downloadLanguage(Language language) {
method requiresModelDownload (line 181) | boolean requiresModelDownload(Language lang, @Nullable List<String> do...
method deleteLanguage (line 189) | void deleteLanguage(Language language) {
method translate (line 203) | public Task<String> translate() {
class ResultOrError (line 238) | static class ResultOrError {
method ResultOrError (line 242) | ResultOrError(@Nullable String result, @Nullable Exception error) {
class Language (line 252) | static class Language implements Comparable<Language> {
method Language (line 255) | Language(String code) {
method getDisplayName (line 259) | String getDisplayName() {
method getCode (line 263) | String getCode() {
method equals (line 267) | @Override
method toString (line 281) | @NonNull
method hashCode (line 287) | @Override
method compareTo (line 292) | @Override
method onCleared (line 298) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/BitmapUtils.java
class BitmapUtils (line 43) | public class BitmapUtils {
method getBitmap (line 47) | @Nullable
method getBitmap (line 70) | @RequiresApi(VERSION_CODES.LOLLIPOP)
method rotateBitmap (line 87) | private static Bitmap rotateBitmap(
method getBitmapFromContentUri (line 106) | @Nullable
method getExifOrientationTag (line 153) | private static int getExifOrientationTag(ContentResolver resolver, Uri...
method yuv420ThreePlanesToNV21 (line 194) | private static ByteBuffer yuv420ThreePlanesToNV21(
method areUVPlanesNV21 (line 223) | private static boolean areUVPlanesNV21(Plane[] planes, int width, int ...
method unpackPlane (line 255) | private static void unpackPlane(
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/CameraImageGraphic.java
class CameraImageGraphic (line 24) | public class CameraImageGraphic extends Graphic {
method CameraImageGraphic (line 28) | public CameraImageGraphic(GraphicOverlay overlay, Bitmap bitmap) {
method draw (line 33) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/CameraSource.java
class CameraSource (line 47) | public class CameraSource {
method CameraSource (line 116) | public CameraSource(Activity activity, GraphicOverlay overlay) {
method release (line 128) | public void release() {
method start (line 145) | @RequiresPermission(Manifest.permission.CAMERA)
method start (line 169) | @RequiresPermission(Manifest.permission.CAMERA)
method stop (line 194) | public synchronized void stop() {
method setFacing (line 227) | public synchronized void setFacing(int facing) {
method getPreviewSize (line 235) | public Size getPreviewSize() {
method getCameraFacing (line 243) | public int getCameraFacing() {
method setZoom (line 247) | public boolean setZoom(float zoomRatio) {
method getZoomValue (line 276) | private static int getZoomValue(Camera.Parameters params, float zoomRa...
method createCamera (line 293) | @SuppressLint("InlinedApi")
method getIdForRequestedCamera (line 376) | private static int getIdForRequestedCamera(int facing) {
method selectSizePair (line 400) | public static SizePair selectSizePair(Camera camera, int desiredWidth,...
class SizePair (line 428) | public static class SizePair {
method SizePair (line 432) | SizePair(Camera.Size previewSize, @Nullable Camera.Size pictureSize) {
method SizePair (line 437) | public SizePair(Size previewSize, @Nullable Size pictureSize) {
method generateValidPreviewSizeList (line 452) | public static List<SizePair> generateValidPreviewSizeList(Camera camer...
method selectPreviewFpsRange (line 493) | @SuppressLint("InlinedApi")
method setRotation (line 527) | private void setRotation(Camera camera, Camera.Parameters parameters, ...
method createPreviewBuffer (line 575) | @SuppressLint("InlinedApi")
class CameraPreviewCallback (line 600) | private class CameraPreviewCallback implements Camera.PreviewCallback {
method onPreviewFrame (line 601) | @Override
method setMachineLearningFrameProcessor (line 607) | public void setMachineLearningFrameProcessor(VisionImageProcessor proc...
class FrameProcessingRunnable (line 627) | private class FrameProcessingRunnable implements Runnable {
method FrameProcessingRunnable (line 636) | FrameProcessingRunnable() {}
method setActive (line 639) | void setActive(boolean active) {
method setNextFrame (line 650) | @SuppressWarnings("ByteBufferBackingArray")
method run (line 686) | @SuppressLint("InlinedApi")
method cleanScreen (line 745) | private void cleanScreen() {
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/CameraSourcePreview.java
class CameraSourcePreview (line 31) | public class CameraSourcePreview extends ViewGroup {
method CameraSourcePreview (line 42) | public CameraSourcePreview(Context context, AttributeSet attrs) {
method start (line 53) | private void start(CameraSource cameraSource) throws IOException {
method start (line 62) | public void start(CameraSource cameraSource, GraphicOverlay overlay) t...
method stop (line 67) | public void stop() {
method release (line 73) | public void release() {
method startIfReady (line 81) | private void startIfReady() throws IOException, SecurityException {
class SurfaceCallback (line 108) | private class SurfaceCallback implements SurfaceHolder.Callback {
method surfaceCreated (line 109) | @Override
method surfaceDestroyed (line 119) | @Override
method surfaceChanged (line 124) | @Override
method onLayout (line 128) | @Override
method isPortraitMode (line 164) | private boolean isPortraitMode() {
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/CameraXViewModel.java
class CameraXViewModel (line 33) | @RequiresApi(VERSION_CODES.LOLLIPOP)
method CameraXViewModel (line 42) | public CameraXViewModel(@NonNull Application application) {
method getProcessCameraProvider (line 46) | public LiveData<ProcessCameraProvider> getProcessCameraProvider() {
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/FrameMetadata.java
class FrameMetadata (line 20) | public class FrameMetadata {
method getWidth (line 26) | public int getWidth() {
method getHeight (line 30) | public int getHeight() {
method getRotation (line 34) | public int getRotation() {
method FrameMetadata (line 38) | private FrameMetadata(int width, int height, int rotation) {
class Builder (line 45) | public static class Builder {
method setWidth (line 51) | public Builder setWidth(int width) {
method setHeight (line 56) | public Builder setHeight(int height) {
method setRotation (line 61) | public Builder setRotation(int rotation) {
method build (line 66) | public FrameMetadata build() {
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/GraphicOverlay.java
class GraphicOverlay (line 52) | public class GraphicOverlay extends View {
class Graphic (line 77) | public abstract static class Graphic {
method Graphic (line 80) | public Graphic(GraphicOverlay overlay) {
method draw (line 97) | public abstract void draw(Canvas canvas);
method drawRect (line 99) | protected void drawRect(
method drawText (line 104) | protected void drawText(Canvas canvas, String text, float x, float y...
method scale (line 109) | public float scale(float imagePixel) {
method getApplicationContext (line 114) | public Context getApplicationContext() {
method isImageFlipped (line 118) | public boolean isImageFlipped() {
method translateX (line 125) | public float translateX(float x) {
method translateY (line 136) | public float translateY(float y) {
method getTransformationMatrix (line 143) | public Matrix getTransformationMatrix() {
method postInvalidate (line 147) | public void postInvalidate() {
method updatePaintColorByZValue (line 165) | public void updatePaintColorByZValue(
method GraphicOverlay (line 212) | public GraphicOverlay(Context context, AttributeSet attrs) {
method clear (line 220) | public void clear() {
method add (line 228) | public void add(Graphic graphic) {
method remove (line 235) | public void remove(Graphic graphic) {
method setImageSourceInfo (line 251) | public void setImageSourceInfo(int imageWidth, int imageHeight, boolea...
method getImageWidth (line 263) | public int getImageWidth() {
method getImageHeight (line 267) | public int getImageHeight() {
method updateTransformationIfNeeded (line 271) | private void updateTransformationIfNeeded() {
method onDraw (line 301) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/InferenceInfoGraphic.java
class InferenceInfoGraphic (line 25) | public class InferenceInfoGraphic extends GraphicOverlay.Graphic {
method InferenceInfoGraphic (line 39) | public InferenceInfoGraphic(
method InferenceInfoGraphic (line 57) | public InferenceInfoGraphic(GraphicOverlay overlay) {
method draw (line 62) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/ScopedExecutor.java
class ScopedExecutor (line 27) | public class ScopedExecutor implements Executor {
method ScopedExecutor (line 32) | public ScopedExecutor(@NonNull Executor executor) {
method execute (line 36) | @Override
method shutdown (line 58) | public void shutdown() {
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/TemperatureMonitor.java
class TemperatureMonitor (line 17) | public final class TemperatureMonitor implements SensorEventListener {
method TemperatureMonitor (line 25) | public TemperatureMonitor(Context context) {
method stop (line 41) | public void stop() {
method logTemperature (line 45) | public void logTemperature() {
method onAccuracyChanged (line 57) | @Override
method onSensorChanged (line 60) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/VisionImageProcessor.java
type VisionImageProcessor (line 25) | public interface VisionImageProcessor {
method processBitmap (line 28) | void processBitmap(Bitmap bitmap, GraphicOverlay graphicOverlay);
method processByteBuffer (line 31) | void processByteBuffer(
method processImageProxy (line 36) | void processImageProxy(ImageProxy image, GraphicOverlay graphicOverlay...
method stop (line 39) | void stop();
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/CameraXLivePreviewActivity.java
class CameraXLivePreviewActivity (line 80) | @KeepName
method onCreate (line 120) | @Override
method onSaveInstanceState (line 191) | @Override
method onItemSelected (line 197) | @Override
method onNothingSelected (line 206) | @Override
method onCheckedChanged (line 211) | @Override
method onResume (line 240) | @Override
method onPause (line 246) | @Override
method onDestroy (line 254) | @Override
method bindAllCameraUseCases (line 262) | private void bindAllCameraUseCases() {
method bindPreviewUseCase (line 271) | private void bindPreviewUseCase() {
method bindAnalysisUseCase (line 293) | private void bindAnalysisUseCase() {
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/CameraXSourceDemoActivity.java
class CameraXSourceDemoActivity (line 51) | @KeepName
method onCreate (line 71) | @Override
method onCheckedChanged (line 105) | @Override
method onResume (line 115) | @Override
method onPause (line 131) | @Override
method onDestroy (line 139) | @Override
method createThenStartCameraXSource (line 147) | private void createThenStartCameraXSource() {
method onDetectionTaskSuccess (line 169) | private void onDetectionTaskSuccess(List<DetectedObject> results) {
method onDetectionTaskFailure (line 198) | private void onDetectionTaskFailure(Exception e) {
method isPortraitMode (line 208) | private boolean isPortraitMode() {
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/ChooserActivity.java
class ChooserActivity (line 38) | public final class ChooserActivity extends AppCompatActivity
method onCreate (line 67) | @Override
method onItemClick (line 94) | @Override
class MyArrayAdapter (line 100) | private static class MyArrayAdapter extends ArrayAdapter<Class<?>> {
method MyArrayAdapter (line 106) | MyArrayAdapter(Context context, int resource, Class<?>[] objects) {
method getView (line 113) | @Override
method setDescriptionIds (line 129) | void setDescriptionIds(int[] descriptionIds) {
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/LivePreviewActivity.java
class LivePreviewActivity (line 64) | @KeepName
method onCreate (line 92) | @Override
method onItemSelected (line 150) | @Override
method onNothingSelected (line 161) | @Override
method onCheckedChanged (line 166) | @Override
method createCameraSource (line 180) | private void createCameraSource(String model) {
method startCameraSource (line 328) | private void startCameraSource() {
method onResume (line 346) | @Override
method onPause (line 355) | @Override
method onDestroy (line 361) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/StillImageActivity.java
class StillImageActivity (line 75) | @KeepName
method onCreate (line 122) | @Override
method onResume (line 189) | @Override
method onPause (line 197) | @Override
method onDestroy (line 205) | @Override
method populateFeatureSelector (line 213) | private void populateFeatureSelector() {
method populateSizeSelector (line 258) | private void populateSizeSelector() {
method onSaveInstanceState (line 287) | @Override
method startCameraIntentForResult (line 294) | private void startCameraIntentForResult() {
method startChooseImageIntentForResult (line 310) | private void startChooseImageIntentForResult() {
method onActivityResult (line 317) | @Override
method tryReloadAndDetectInImage (line 330) | private void tryReloadAndDetectInImage() {
method getTargetedWidthHeight (line 386) | private Pair<Integer, Integer> getTargetedWidthHeight() {
method createImageProcessor (line 410) | private void createImageProcessor() {
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/VisionProcessorBase.java
class VisionProcessorBase (line 65) | public abstract class VisionProcessorBase<T> implements VisionImageProce...
method VisionProcessorBase (line 104) | protected VisionProcessorBase(Context context) {
method processBitmap (line 121) | @Override
method processByteBuffer (line 147) | @Override
method processLatestImage (line 157) | private synchronized void processLatestImage(final GraphicOverlay grap...
method processImage (line 167) | private void processImage(
method processImageProxy (line 211) | @Override
method requestDetectInImage (line 260) | private Task<T> requestDetectInImage(
method requestDetectInImage (line 270) | private Task<T> requestDetectInImage(
method setUpListener (line 280) | private Task<T> setUpListener(
method stop (line 364) | @Override
method resetLatencyStats (line 373) | private void resetLatencyStats() {
method detectInImage (line 383) | protected abstract Task<T> detectInImage(InputImage image);
method detectInImage (line 385) | protected Task<T> detectInImage(MlImage image) {
method onSuccess (line 392) | protected abstract void onSuccess(@NonNull T results, @NonNull Graphic...
method onFailure (line 394) | protected abstract void onFailure(@NonNull Exception e);
method isMlImageEnabled (line 396) | protected boolean isMlImageEnabled(Context context) {
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/barcodescanner/BarcodeGraphic.java
class BarcodeGraphic (line 31) | public class BarcodeGraphic extends Graphic {
method BarcodeGraphic (line 43) | BarcodeGraphic(GraphicOverlay overlay, Barcode barcode) {
method draw (line 65) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/barcodescanner/BarcodeScannerProcessor.java
class BarcodeScannerProcessor (line 38) | public class BarcodeScannerProcessor extends VisionProcessorBase<List<Ba...
method BarcodeScannerProcessor (line 44) | public BarcodeScannerProcessor(Context context, @Nullable ZoomCallback...
method stop (line 62) | @Override
method detectInImage (line 68) | @Override
method onSuccess (line 73) | @Override
method logExtrasForTesting (line 86) | private static void logExtrasForTesting(Barcode barcode) {
method onFailure (line 127) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/facedetector/FaceDetectorProcessor.java
class FaceDetectorProcessor (line 37) | public class FaceDetectorProcessor extends VisionProcessorBase<List<Face...
method FaceDetectorProcessor (line 43) | public FaceDetectorProcessor(Context context) {
method stop (line 50) | @Override
method detectInImage (line 56) | @Override
method onSuccess (line 61) | @Override
method logExtrasForTesting (line 69) | private static void logExtrasForTesting(Face face) {
method onFailure (line 132) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/facedetector/FaceGraphic.java
class FaceGraphic (line 35) | public class FaceGraphic extends Graphic {
method FaceGraphic (line 63) | FaceGraphic(GraphicOverlay overlay, Face face) {
method draw (line 93) | @Override
method drawFaceLandmark (line 259) | private void drawFaceLandmark(Canvas canvas, @LandmarkType int landmar...
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/facemeshdetector/FaceMeshDetectorProcessor.java
class FaceMeshDetectorProcessor (line 35) | public class FaceMeshDetectorProcessor extends VisionProcessorBase<List<...
method FaceMeshDetectorProcessor (line 41) | public FaceMeshDetectorProcessor(Context context) {
method stop (line 51) | @Override
method detectInImage (line 57) | @Override
method onSuccess (line 62) | @Override
method onFailure (line 70) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/facemeshdetector/FaceMeshGraphic.java
class FaceMeshGraphic (line 43) | public class FaceMeshGraphic extends Graphic {
method FaceMeshGraphic (line 72) | FaceMeshGraphic(GraphicOverlay overlay, FaceMesh faceMesh) {
method draw (line 90) | @Override
method getContourPoints (line 151) | private List<FaceMeshPoint> getContourPoints(FaceMesh faceMesh) {
method drawLine (line 159) | private void drawLine(Canvas canvas, PointF3D point1, PointF3D point2) {
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/labeldetector/LabelDetectorProcessor.java
class LabelDetectorProcessor (line 33) | public class LabelDetectorProcessor extends VisionProcessorBase<List<Ima...
method LabelDetectorProcessor (line 39) | public LabelDetectorProcessor(Context context, ImageLabelerOptionsBase...
method stop (line 44) | @Override
method detectInImage (line 50) | @Override
method onSuccess (line 55) | @Override
method logExtrasForTesting (line 62) | private static void logExtrasForTesting(List<ImageLabel> labels) {
method onFailure (line 74) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/labeldetector/LabelGraphic.java
class LabelGraphic (line 29) | public class LabelGraphic extends GraphicOverlay.Graphic {
method LabelGraphic (line 40) | public LabelGraphic(GraphicOverlay overlay, List<ImageLabel> labels) {
method draw (line 54) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/objectdetector/ObjectDetectorProcessor.java
class ObjectDetectorProcessor (line 33) | public class ObjectDetectorProcessor extends VisionProcessorBase<List<De...
method ObjectDetectorProcessor (line 39) | public ObjectDetectorProcessor(Context context, ObjectDetectorOptionsB...
method stop (line 44) | @Override
method detectInImage (line 50) | @Override
method onSuccess (line 55) | @Override
method onFailure (line 63) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/objectdetector/ObjectGraphic.java
class ObjectGraphic (line 30) | public class ObjectGraphic extends Graphic {
method ObjectGraphic (line 56) | public ObjectGraphic(GraphicOverlay overlay, DetectedObject object) {
method draw (line 81) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/posedetector/PoseDetectorProcessor.java
class PoseDetectorProcessor (line 38) | public class PoseDetectorProcessor
class PoseWithClassification (line 54) | protected static class PoseWithClassification {
method PoseWithClassification (line 58) | public PoseWithClassification(Pose pose, List<String> classification...
method getPose (line 63) | public Pose getPose() {
method getClassificationResult (line 67) | public List<String> getClassificationResult() {
method PoseDetectorProcessor (line 72) | public PoseDetectorProcessor(
method stop (line 91) | @Override
method detectInImage (line 97) | @Override
method detectInImage (line 116) | @Override
method onSuccess (line 135) | @Override
method onFailure (line 149) | @Override
method isMlImageEnabled (line 154) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/posedetector/PoseGraphic.java
class PoseGraphic (line 34) | public class PoseGraphic extends Graphic {
method PoseGraphic (line 54) | PoseGraphic(
method draw (line 85) | @Override
method drawPoint (line 199) | void drawPoint(Canvas canvas, PoseLandmark landmark, Paint paint) {
method drawLine (line 206) | void drawLine(Canvas canvas, PoseLandmark startLandmark, PoseLandmark ...
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/posedetector/classification/ClassificationResult.java
class ClassificationResult (line 28) | public class ClassificationResult {
method ClassificationResult (line 34) | public ClassificationResult() {
method getAllClasses (line 38) | public Set<String> getAllClasses() {
method getClassConfidence (line 42) | public float getClassConfidence(String className) {
method getMaxConfidenceClass (line 46) | public String getMaxConfidenceClass() {
method incrementClassConfidence (line 53) | public void incrementClassConfidence(String className) {
method putClassConfidence (line 58) | public void putClassConfidence(String className, float confidence) {
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/posedetector/classification/EMASmoothing.java
class EMASmoothing (line 28) | public class EMASmoothing {
method EMASmoothing (line 42) | public EMASmoothing() {
method EMASmoothing (line 46) | public EMASmoothing(int windowSize, float alpha) {
method getSmoothedResult (line 52) | public ClassificationResult getSmoothedResult(ClassificationResult cla...
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/posedetector/classification/PoseClassifier.java
class PoseClassifier (line 42) | public class PoseClassifier {
method PoseClassifier (line 54) | public PoseClassifier(List<PoseSample> poseSamples) {
method PoseClassifier (line 58) | public PoseClassifier(List<PoseSample> poseSamples, int maxDistanceTopK,
method extractPoseLandmarks (line 66) | private static List<PointF3D> extractPoseLandmarks(Pose pose) {
method confidenceRange (line 80) | public int confidenceRange() {
method classify (line 84) | public ClassificationResult classify(Pose pose) {
method classify (line 88) | public ClassificationResult classify(List<PointF3D> landmarks) {
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/posedetector/classification/PoseClassifierProcessor.java
class PoseClassifierProcessor (line 37) | public class PoseClassifierProcessor {
method PoseClassifierProcessor (line 57) | @WorkerThread
method loadPoseSamples (line 69) | private void loadPoseSamples(Context context) {
method getPoseResult (line 102) | @WorkerThread
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/posedetector/classification/PoseEmbedding.java
class PoseEmbedding (line 33) | public class PoseEmbedding {
method getPoseEmbedding (line 37) | public static List<PointF3D> getPoseEmbedding(List<PointF3D> landmarks) {
method normalize (line 42) | private static List<PointF3D> normalize(List<PointF3D> landmarks) {
method getPoseSize (line 57) | private static float getPoseSize(List<PointF3D> landmarks) {
method getEmbedding (line 81) | private static List<PointF3D> getEmbedding(List<PointF3D> lm) {
method PoseEmbedding (line 141) | private PoseEmbedding() {}
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/posedetector/classification/PoseSample.java
class PoseSample (line 28) | public class PoseSample {
method PoseSample (line 37) | public PoseSample(String name, String className, List<PointF3D> landma...
method getName (line 43) | public String getName() {
method getClassName (line 47) | public String getClassName() {
method getEmbedding (line 51) | public List<PointF3D> getEmbedding() {
method getPoseSample (line 55) | public static PoseSample getPoseSample(String csvLine, String separato...
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/posedetector/classification/RepetitionCounter.java
class RepetitionCounter (line 22) | public class RepetitionCounter {
method RepetitionCounter (line 35) | public RepetitionCounter(String className) {
method RepetitionCounter (line 39) | public RepetitionCounter(String className, float enterThreshold, float...
method addClassificationResult (line 53) | public int addClassificationResult(ClassificationResult classification...
method getClassName (line 69) | public String getClassName() {
method getNumRepeats (line 73) | public int getNumRepeats() {
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/posedetector/classification/Utils.java
class Utils (line 28) | public class Utils {
method Utils (line 29) | private Utils() {}
method add (line 31) | public static PointF3D add(PointF3D a, PointF3D b) {
method subtract (line 35) | public static PointF3D subtract(PointF3D b, PointF3D a) {
method multiply (line 39) | public static PointF3D multiply(PointF3D a, float multiple) {
method multiply (line 43) | public static PointF3D multiply(PointF3D a, PointF3D multiple) {
method average (line 48) | public static PointF3D average(PointF3D a, PointF3D b) {
method l2Norm2D (line 53) | public static float l2Norm2D(PointF3D point) {
method maxAbs (line 57) | public static float maxAbs(PointF3D point) {
method sumAbs (line 61) | public static float sumAbs(PointF3D point) {
method addAll (line 65) | public static void addAll(List<PointF3D> pointsList, PointF3D p) {
method subtractAll (line 72) | public static void subtractAll(PointF3D p, List<PointF3D> pointsList) {
method multiplyAll (line 79) | public static void multiplyAll(List<PointF3D> pointsList, float multip...
method multiplyAll (line 86) | public static void multiplyAll(List<PointF3D> pointsList, PointF3D mul...
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/segmenter/SegmentationGraphic.java
class SegmentationGraphic (line 31) | public class SegmentationGraphic extends Graphic {
method SegmentationGraphic (line 40) | public SegmentationGraphic(
method draw (line 56) | @Override
method maskColorsFromByteBuffer (line 74) | @ColorInt
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/segmenter/SegmenterProcessor.java
class SegmenterProcessor (line 33) | public class SegmenterProcessor extends VisionProcessorBase<Segmentation...
method SegmenterProcessor (line 39) | public SegmenterProcessor(Context context) {
method SegmenterProcessor (line 43) | public SegmenterProcessor(Context context, boolean isStreamMode) {
method detectInImage (line 57) | @Override
method onSuccess (line 62) | @Override
method onFailure (line 68) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/subjectsegmenter/SubjectSegmentationGraphic.java
class SubjectSegmentationGraphic (line 35) | @RequiresApi(Build.VERSION_CODES.N)
method SubjectSegmentationGraphic (line 60) | public SubjectSegmentationGraphic(
method draw (line 77) | @Override
method maskColorsFromFloatBuffer (line 93) | @ColorInt
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/subjectsegmenter/SubjectSegmenterProcessor.java
class SubjectSegmenterProcessor (line 34) | @RequiresApi(Build.VERSION_CODES.N)
method SubjectSegmenterProcessor (line 43) | public SubjectSegmenterProcessor(Context context) {
method detectInImage (line 57) | @Override
method onSuccess (line 64) | @Override
method onFailure (line 73) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/textdetector/TextGraphic.java
class TextGraphic (line 41) | public class TextGraphic extends Graphic {
method TextGraphic (line 59) | TextGraphic(
method draw (line 89) | @Override
method drawText (line 148) | private void drawText(String text, RectF rect, float textHeight, Canva...
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/java/textdetector/TextRecognitionProcessor.java
class TextRecognitionProcessor (line 37) | public class TextRecognitionProcessor extends VisionProcessorBase<Text> {
method TextRecognitionProcessor (line 46) | public TextRecognitionProcessor(
method stop (line 55) | @Override
method detectInImage (line 61) | @Override
method onSuccess (line 66) | @Override
method logExtrasForTesting (line 79) | private static void logExtrasForTesting(Text text) {
method onFailure (line 119) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/preference/CameraXLivePreviewPreferenceFragment.java
class CameraXLivePreviewPreferenceFragment (line 38) | @RequiresApi(VERSION_CODES.LOLLIPOP)
method setUpCameraPreferences (line 41) | @Override
method setUpCameraXTargetAnalysisSizePreference (line 56) | private void setUpCameraXTargetAnalysisSizePreference(
method getCameraCharacteristics (line 96) | @Nullable
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/preference/CameraXSourceDemoPreferenceFragment.java
class CameraXSourceDemoPreferenceFragment (line 27) | @RequiresApi(VERSION_CODES.LOLLIPOP)
method onCreate (line 30) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/preference/LivePreviewPreferenceFragment.java
class LivePreviewPreferenceFragment (line 35) | public class LivePreviewPreferenceFragment extends PreferenceFragment {
method onCreate (line 37) | @Override
method setUpCameraPreferences (line 46) | void setUpCameraPreferences() {
method setUpCameraPreviewSizePreference (line 63) | private void setUpCameraPreviewSizePreference(
method setUpFaceDetectionPreferencesForStreamMode (line 125) | private void setUpFaceDetectionPreferencesForStreamMode() {
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/preference/PreferenceUtils.java
class PreferenceUtils (line 43) | public class PreferenceUtils {
method saveString (line 47) | static void saveString(Context context, @StringRes int prefKeyId, @Nul...
method getCameraPreviewSizePair (line 54) | @Nullable
method getCameraXTargetResolution (line 79) | @RequiresApi(VERSION_CODES.LOLLIPOP)
method shouldHideDetectionInfo (line 97) | public static boolean shouldHideDetectionInfo(Context context) {
method getObjectDetectorOptionsForStillImage (line 103) | public static ObjectDetectorOptions getObjectDetectorOptionsForStillIm...
method getObjectDetectorOptionsForLivePreview (line 111) | public static ObjectDetectorOptions getObjectDetectorOptionsForLivePre...
method getObjectDetectorOptions (line 119) | private static ObjectDetectorOptions getObjectDetectorOptions(
method getCustomObjectDetectorOptionsForStillImage (line 143) | public static CustomObjectDetectorOptions getCustomObjectDetectorOptio...
method getCustomObjectDetectorOptionsForLivePreview (line 153) | public static CustomObjectDetectorOptions getCustomObjectDetectorOptio...
method getCustomObjectDetectorOptions (line 163) | private static CustomObjectDetectorOptions getCustomObjectDetectorOpti...
method getFaceDetectorOptions (line 188) | public static FaceDetectorOptions getFaceDetectorOptions(Context conte...
method getPoseDetectorOptionsForLivePreview (line 233) | public static PoseDetectorOptionsBase getPoseDetectorOptionsForLivePre...
method getPoseDetectorOptionsForStillImage (line 258) | public static PoseDetectorOptionsBase getPoseDetectorOptionsForStillIm...
method shouldEnableAutoZoom (line 283) | public static boolean shouldEnableAutoZoom(Context context) {
method shouldGroupRecognizedTextInBlocks (line 289) | public static boolean shouldGroupRecognizedTextInBlocks(Context contex...
method showLanguageTag (line 295) | public static boolean showLanguageTag(Context context) {
method shouldShowTextConfidence (line 301) | public static boolean shouldShowTextConfidence(Context context) {
method preferGPUForPoseDetection (line 307) | public static boolean preferGPUForPoseDetection(Context context) {
method shouldShowPoseDetectionInFrameLikelihoodLivePreview (line 313) | public static boolean shouldShowPoseDetectionInFrameLikelihoodLivePrev...
method shouldShowPoseDetectionInFrameLikelihoodStillImage (line 320) | public static boolean shouldShowPoseDetectionInFrameLikelihoodStillIma...
method shouldPoseDetectionVisualizeZ (line 327) | public static boolean shouldPoseDetectionVisualizeZ(Context context) {
method shouldPoseDetectionRescaleZForVisualization (line 333) | public static boolean shouldPoseDetectionRescaleZForVisualization(Cont...
method shouldPoseDetectionRunClassification (line 339) | public static boolean shouldPoseDetectionRunClassification(Context con...
method shouldSegmentationEnableRawSizeMask (line 345) | public static boolean shouldSegmentationEnableRawSizeMask(Context cont...
method getModeTypePreferenceValue (line 356) | private static int getModeTypePreferenceValue(
method isCameraLiveViewportEnabled (line 363) | public static boolean isCameraLiveViewportEnabled(Context context) {
method getFaceMeshUseCase (line 369) | public static int getFaceMeshUseCase(Context context) {
method PreferenceUtils (line 376) | private PreferenceUtils() {}
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/preference/SettingsActivity.java
class SettingsActivity (line 29) | public class SettingsActivity extends AppCompatActivity {
type LaunchSource (line 34) | @SuppressWarnings("NewApi") // CameraX is only available on API 21+
method LaunchSource (line 47) | LaunchSource(int titleResId, Class<? extends PreferenceFragment> pre...
method onCreate (line 53) | @Override
FILE: android/vision-quickstart/app/src/main/java/com/google/mlkit/vision/demo/preference/StillImagePreferenceFragment.java
class StillImagePreferenceFragment (line 24) | public class StillImagePreferenceFragment extends PreferenceFragment {
method onCreate (line 26) | @Override
Condensed preview — 867 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (4,267K chars).
[
{
"path": ".github/ISSUE_TEMPLATE/bug_report.md",
"chars": 977,
"preview": "---\nname: Bug report\nabout: Create a report to help us improve\ntitle: \"[Bug report] Title for the bug\"\nlabels: ''\nassign"
},
{
"path": ".github/ISSUE_TEMPLATE/feature_request.md",
"chars": 459,
"preview": "---\nname: Feature request\nabout: Suggest an idea for this project\ntitle: \"[Feature request] Title for the request\"\nlabel"
},
{
"path": ".gitignore",
"chars": 235,
"preview": "*.DS_Store\n*.idea\n*.iml\n.gradle\nlocal.properties\n\n.project\n.settings\n.classpath\n\n**/Pods/\n**/*.xcuserstate\nios-snippets/"
},
{
"path": "LICENSE",
"chars": 11357,
"preview": "\n Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 282,
"preview": "# MLKit Samples\n\nA collection of quickstart samples demonstrating the [ML Kit](https://developers.google.com/ml-kit) API"
},
{
"path": "android/.gitignore",
"chars": 182,
"preview": ".gradle\nbuild/\n.DS_Store\n*.iml\n*.apk\n*.aar\n*.zip\ngoogle-services.json\n\n.project\n.settings\n.classpath\n\nlocal.properties\n\n"
},
{
"path": "android/LICENSE",
"chars": 11340,
"preview": "\n Apache License\n Version 2.0, January 2004\n "
},
{
"path": "android/README.md",
"chars": 271,
"preview": "# MLKit Android Samples\n\nA collection of quickstart samples demonstrating the MLKit APIs on Android.\n\n[See a full list o"
},
{
"path": "android/android-snippets/README.md",
"chars": 994,
"preview": "# ML Kit Android Snippets\n\nThis is a collection of Android code snippets seen on https://developers.google.com/ml-kit. T"
},
{
"path": "android/android-snippets/app/build.gradle",
"chars": 2072,
"preview": "apply plugin: 'com.android.application'\napply plugin: 'kotlin-android'\napply plugin: 'kotlin-android-extensions'\n\nandroi"
},
{
"path": "android/android-snippets/app/proguard-rules.pro",
"chars": 667,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /U"
},
{
"path": "android/android-snippets/app/src/main/AndroidManifest.xml",
"chars": 707,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package="
},
{
"path": "android/android-snippets/app/src/main/java/com/google/example/mlkit/BarcodeScanningActivity.java",
"chars": 4100,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/android-snippets/app/src/main/java/com/google/example/mlkit/FaceDetectionActivity.java",
"chars": 7678,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/android-snippets/app/src/main/java/com/google/example/mlkit/ImageLabelingActivity.java",
"chars": 5504,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/android-snippets/app/src/main/java/com/google/example/mlkit/LanguageIdentificationActivity.java",
"chars": 4182,
"preview": "package com.google.example.mlkit;\n\nimport android.os.Bundle;\nimport android.util.Log;\n\nimport androidx.annotation.NonNul"
},
{
"path": "android/android-snippets/app/src/main/java/com/google/example/mlkit/MLKitVisionImage.java",
"chars": 5179,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/android-snippets/app/src/main/java/com/google/example/mlkit/MainActivity.java",
"chars": 759,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/android-snippets/app/src/main/java/com/google/example/mlkit/ObjectDetectionActivity.java",
"chars": 6826,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/android-snippets/app/src/main/java/com/google/example/mlkit/TextRecognitionActivity.java",
"chars": 5156,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/android-snippets/app/src/main/java/com/google/example/mlkit/kotlin/BarcodeScanningActivity.kt",
"chars": 3024,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/android-snippets/app/src/main/java/com/google/example/mlkit/kotlin/FaceDetectionActivity.kt",
"chars": 5409,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/android-snippets/app/src/main/java/com/google/example/mlkit/kotlin/ImageLabelingActivity.kt",
"chars": 3334,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/android-snippets/app/src/main/java/com/google/example/mlkit/kotlin/LanguageIdentificationActivity.kt",
"chars": 2680,
"preview": "package com.google.example.mlkit.kotlin\n\nimport android.os.Bundle\nimport android.util.Log\nimport androidx.appcompat.app."
},
{
"path": "android/android-snippets/app/src/main/java/com/google/example/mlkit/kotlin/MLKitVisionImage.kt",
"chars": 5233,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/android-snippets/app/src/main/java/com/google/example/mlkit/kotlin/MainActivity.kt",
"chars": 748,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/android-snippets/app/src/main/java/com/google/example/mlkit/kotlin/ObjectDetectionActivity.kt",
"chars": 5245,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/android-snippets/app/src/main/java/com/google/example/mlkit/kotlin/TextRecognitionActivity.kt",
"chars": 3319,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/android-snippets/app/src/main/res/layout/activity_main.xml",
"chars": 771,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android"
},
{
"path": "android/android-snippets/app/src/main/res/values/colors.xml",
"chars": 208,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"colorPrimary\">#3F51B5</color>\n <color name=\"color"
},
{
"path": "android/android-snippets/app/src/main/res/values/dimens.xml",
"chars": 211,
"preview": "<resources>\n <!-- Default screen margins, per the Android Design guidelines. -->\n <dimen name=\"activity_horizontal"
},
{
"path": "android/android-snippets/app/src/main/res/values/strings.xml",
"chars": 82,
"preview": "<resources>\n <string name=\"app_name\">MLKit Code Snippets</string>\n</resources>\n"
},
{
"path": "android/android-snippets/app/src/main/res/values/styles.xml",
"chars": 383,
"preview": "<resources>\n\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar"
},
{
"path": "android/android-snippets/app/src/main/res/values-w820dp/dimens.xml",
"chars": 358,
"preview": "<resources>\n <!-- Example customization of dimensions originally defined in res/values/dimens.xml\n (such as s"
},
{
"path": "android/android-snippets/build.gradle",
"chars": 552,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n e"
},
{
"path": "android/android-snippets/gradle/wrapper/gradle-wrapper.properties",
"chars": 232,
"preview": "#Mon Aug 24 22:29:37 PDT 2020\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "android/android-snippets/gradle.properties",
"chars": 783,
"preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will o"
},
{
"path": "android/android-snippets/gradlew",
"chars": 5916,
"preview": "#!/usr/bin/env sh\n\n#\n# Copyright 2015 the original author or authors.\n#\n# Licensed under the Apache License, Version 2.0"
},
{
"path": "android/android-snippets/gradlew.bat",
"chars": 2941,
"preview": "@rem\r\n@rem Copyright 2015 the original author or authors.\r\n@rem\r\n@rem Licensed under the Apache License, Version 2.0 (th"
},
{
"path": "android/android-snippets/settings.gradle",
"chars": 15,
"preview": "include ':app'\n"
},
{
"path": "android/automl/LICENSE",
"chars": 10757,
"preview": " Copyright 2020 Google LLC\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this"
},
{
"path": "android/automl/README.md",
"chars": 3512,
"preview": "# ML Kit AutoML Remote Model Quickstart Sample App\n\n* [Read more about training an image classification model using Auto"
},
{
"path": "android/automl/app/build.gradle",
"chars": 3223,
"preview": "apply plugin: 'com.android.application'\n\nandroid {\n compileSdkVersion 34\n\n defaultConfig {\n applicationId \""
},
{
"path": "android/automl/app/proguard-rules.pro",
"chars": 751,
"preview": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguar"
},
{
"path": "android/automl/app/src/main/AndroidManifest.xml",
"chars": 2538,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmln"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/BitmapUtils.java",
"chars": 14382,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/CameraImageGraphic.java",
"chars": 1156,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/CameraSource.java",
"chars": 28718,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/CameraSourcePreview.java",
"chars": 5505,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/CameraXLivePreviewActivity.java",
"chars": 12783,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/CameraXViewModel.java",
"chars": 2413,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/ChooserActivity.java",
"chars": 6084,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/FrameMetadata.java",
"chars": 1663,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/GraphicOverlay.java",
"chars": 8536,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/InferenceInfoGraphic.java",
"chars": 2275,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/LivePreviewActivity.java",
"chars": 8441,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/ScopedExecutor.java",
"chars": 1856,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/StillImageActivity.java",
"chars": 14553,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/VisionImageProcessor.java",
"chars": 1557,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/VisionProcessorBase.java",
"chars": 9587,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/automl/AutoMLImageLabelerProcessor.java",
"chars": 4610,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/automl/LabelGraphic.java",
"chars": 3146,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/object/ObjectDetectorProcessor.java",
"chars": 4461,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/object/ObjectGraphic.java",
"chars": 4986,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/preference/CameraXLivePreviewPreferenceFragment.java",
"chars": 4664,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/preference/LivePreviewPreferenceFragment.java",
"chars": 5040,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/preference/PreferenceUtils.java",
"chars": 5417,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/preference/SettingsActivity.java",
"chars": 2636,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/java/com/google/mlkit/vision/automl/demo/preference/StillImagePreferenceFragment.java",
"chars": 1141,
"preview": "/*\n * Copyright 2020 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/automl/app/src/main/res/drawable/logo_mlkit.xml",
"chars": 1717,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tool"
},
{
"path": "android/automl/app/src/main/res/drawable-hdpi/ic_switch_camera_white_48dp.xml",
"chars": 431,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- This is an example InsetDrawable. It should be manually reviewed. -->\n<inset"
},
{
"path": "android/automl/app/src/main/res/drawable-mdpi/ic_switch_camera_white_48dp.xml",
"chars": 391,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- This is an example InsetDrawable. It should be manually reviewed. -->\n<inset"
},
{
"path": "android/automl/app/src/main/res/drawable-xhdpi/ic_switch_camera_white_48dp.xml",
"chars": 399,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- This is an example InsetDrawable. It should be manually reviewed. -->\n<inset"
},
{
"path": "android/automl/app/src/main/res/drawable-xxhdpi/ic_switch_camera_white_48dp.xml",
"chars": 431,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- This is an example InsetDrawable. It should be manually reviewed. -->\n<inset"
},
{
"path": "android/automl/app/src/main/res/drawable-xxxhdpi/ic_switch_camera_white_48dp.xml",
"chars": 403,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- This is an example InsetDrawable. It should be manually reviewed. -->\n<inset"
},
{
"path": "android/automl/app/src/main/res/layout/activity_camerax_live_preview.xml",
"chars": 2193,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<androidx.constraintlayout.widget.ConstraintLayout\n xmlns:android=\"http://sche"
},
{
"path": "android/automl/app/src/main/res/layout/activity_chooser.xml",
"chars": 1303,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmln"
},
{
"path": "android/automl/app/src/main/res/layout/activity_live_preview.xml",
"chars": 2232,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xm"
},
{
"path": "android/automl/app/src/main/res/layout/activity_settings.xml",
"chars": 287,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n andr"
},
{
"path": "android/automl/app/src/main/res/layout/activity_still_image.xml",
"chars": 2730,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<androidx.constraintlayout.widget.ConstraintLayout\n xmlns:android=\"http://sche"
},
{
"path": "android/automl/app/src/main/res/layout/settings_style.xml",
"chars": 334,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<ImageView\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n and"
},
{
"path": "android/automl/app/src/main/res/layout/spinner_style.xml",
"chars": 337,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<TextView\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n andr"
},
{
"path": "android/automl/app/src/main/res/layout/toggle_style.xml",
"chars": 338,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <item\n "
},
{
"path": "android/automl/app/src/main/res/layout-land/activity_camerax_live_preview.xml",
"chars": 2048,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<androidx.constraintlayout.widget.ConstraintLayout\n xmlns:android=\"http://sche"
},
{
"path": "android/automl/app/src/main/res/layout-land/activity_live_preview.xml",
"chars": 1793,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "android/automl/app/src/main/res/menu/camera_button_menu.xml",
"chars": 489,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<menu xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:app=\"h"
},
{
"path": "android/automl/app/src/main/res/values/colors.xml",
"chars": 512,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"colorPrimary\">#4CAF50</color>\n <color name=\"color"
},
{
"path": "android/automl/app/src/main/res/values/dimens.xml",
"chars": 259,
"preview": "<resources>\n <!-- Default screen margins, per the Android Design guidelines. -->\n <dimen name=\"activity_horizontal"
},
{
"path": "android/automl/app/src/main/res/values/strings.xml",
"chars": 3535,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <string name=\"app_name\">MLKit-AutoML-Remote</string>\n <string name"
},
{
"path": "android/automl/app/src/main/res/values/styles.xml",
"chars": 91,
"preview": "<resources>\n <style name=\"AppTheme\" parent=\"Theme.AppCompat.NoActionBar\"/>\n</resources>\n"
},
{
"path": "android/automl/app/src/main/res/xml/preference_live_preview_automl.xml",
"chars": 1841,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<PreferenceScreen xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n "
},
{
"path": "android/automl/app/src/main/res/xml/preference_still_image.xml",
"chars": 554,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<PreferenceScreen xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n "
},
{
"path": "android/automl/build.gradle",
"chars": 687,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n e"
},
{
"path": "android/automl/gradle/wrapper/gradle-wrapper.properties",
"chars": 200,
"preview": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributi"
},
{
"path": "android/automl/gradle.properties",
"chars": 1148,
"preview": "# Project-wide Gradle settings.\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will ov"
},
{
"path": "android/automl/gradlew",
"chars": 5296,
"preview": "#!/usr/bin/env sh\n\n##############################################################################\n##\n## Gradle start up"
},
{
"path": "android/automl/gradlew.bat",
"chars": 2260,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\r\n@rem ##########################################################################\r\n@rem\r\n@r"
},
{
"path": "android/automl/settings.gradle",
"chars": 48,
"preview": "rootProject.name='ML Kit AutoML'\ninclude ':app'\n"
},
{
"path": "android/codescanner/LICENSE",
"chars": 10757,
"preview": " Copyright 2022 Google LLC\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this"
},
{
"path": "android/codescanner/README.md",
"chars": 1365,
"preview": "# Google Code Scanner API Quickstart\n\n* [Read more about Google Code Scanner API](https://developers.google.com/ml-kit/c"
},
{
"path": "android/codescanner/app/build.gradle",
"chars": 1847,
"preview": "apply plugin: 'com.android.application'\napply plugin: 'kotlin-android'\napply plugin: 'kotlin-android-extensions'\n\nandroi"
},
{
"path": "android/codescanner/app/src/main/AndroidManifest.xml",
"chars": 1323,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:to"
},
{
"path": "android/codescanner/app/src/main/java/com/google/mlkit/samples/codescanner/EntryChoiceActivity.kt",
"chars": 1372,
"preview": "/*\n * Copyright 2022 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/codescanner/app/src/main/java/com/google/mlkit/samples/codescanner/java/MainActivity.java",
"chars": 4426,
"preview": "/*\n * Copyright 2022 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/codescanner/app/src/main/java/com/google/mlkit/samples/codescanner/kotlin/MainActivity.kt",
"chars": 4068,
"preview": "/*\n * Copyright 2022 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/codescanner/app/src/main/res/drawable/logo_mlkit.xml",
"chars": 1651,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tool"
},
{
"path": "android/codescanner/app/src/main/res/layout/activity_main.xml",
"chars": 1166,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n andr"
},
{
"path": "android/codescanner/app/src/main/res/values/colors.xml",
"chars": 331,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"colorPrimary\">@color/blue</color>\n <color name=\"color"
},
{
"path": "android/codescanner/app/src/main/res/values/strings.xml",
"chars": 851,
"preview": "<resources>\n <string name=\"app_name\" translatable=\"false\">Code Scanner Demo</string>\n <string name=\"allow_manual_input"
},
{
"path": "android/codescanner/app/src/main/res/values/styles.xml",
"chars": 306,
"preview": "<resources>\n\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"Theme.MaterialComponents.Light.DarkActi"
},
{
"path": "android/codescanner/build.gradle",
"chars": 369,
"preview": "buildscript {\n ext.kotlin_version = '1.4.31'\n\n repositories {\n google()\n jcenter()\n }\n depende"
},
{
"path": "android/codescanner/gradle/wrapper/gradle-wrapper.properties",
"chars": 200,
"preview": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributi"
},
{
"path": "android/codescanner/gradle.properties",
"chars": 779,
"preview": "# Project-wide Gradle settings.\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will ov"
},
{
"path": "android/codescanner/gradlew",
"chars": 5766,
"preview": "#!/usr/bin/env sh\n\n#\n# Copyright 2015 the original author or authors.\n#\n# Licensed under the Apache License, Version 2.0"
},
{
"path": "android/codescanner/gradlew.bat",
"chars": 2763,
"preview": "@rem\r\n@rem Copyright 2015 the original author or authors.\r\n@rem\r\n@rem Licensed under the Apache License, Version 2.0 (th"
},
{
"path": "android/codescanner/settings.gradle",
"chars": 161,
"preview": "rootProject.name= \"mlkit_code_scanner_sample\"\ninclude ':app'\ninclude ':internal:chooserx'\nproject(':internal:chooserx')."
},
{
"path": "android/digitalink/README.md",
"chars": 1594,
"preview": "# ML Kit Digital Ink Recognition Quickstart\n\n- [Read more about ML Kit Digital Ink Recognition](https://developers.googl"
},
{
"path": "android/digitalink/app/build.gradle",
"chars": 1627,
"preview": "apply plugin: \"com.android.application\"\napply plugin: 'kotlin-android'\n\nandroid {\n namespace \"com.google.mlkit.sample"
},
{
"path": "android/digitalink/app/proguard-rules.pro",
"chars": 750,
"preview": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguar"
},
{
"path": "android/digitalink/app/src/main/AndroidManifest.xml",
"chars": 1693,
"preview": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package=\"com.google.mlkit.samples.vision.digita"
},
{
"path": "android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/DigitalInkMainActivity.java",
"chars": 8147,
"preview": "package com.google.mlkit.samples.vision.digitalink.recognition;\n\nimport android.os.Bundle;\nimport androidx.appcompat.app"
},
{
"path": "android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/DrawingView.java",
"chars": 7322,
"preview": "package com.google.mlkit.samples.vision.digitalink.recognition;\n\nimport android.content.Context;\nimport android.graphics"
},
{
"path": "android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/ModelManager.java",
"chars": 4240,
"preview": "package com.google.mlkit.samples.vision.digitalink.recognition;\n\nimport android.util.Log;\nimport com.google.android.gms."
},
{
"path": "android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/RecognitionTask.java",
"chars": 2026,
"preview": "package com.google.mlkit.samples.vision.digitalink.recognition;\n\nimport android.util.Log;\nimport androidx.annotation.Nul"
},
{
"path": "android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/StatusTextView.java",
"chars": 952,
"preview": "package com.google.mlkit.samples.vision.digitalink.recognition;\n\nimport android.content.Context;\nimport androidx.appcomp"
},
{
"path": "android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/StrokeManager.java",
"chars": 8787,
"preview": "package com.google.mlkit.samples.vision.digitalink.recognition;\n\nimport android.os.Handler;\nimport android.util.Log;\nimp"
},
{
"path": "android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/kotlin/DigitalInkMainActivity.kt",
"chars": 7026,
"preview": "package com.google.mlkit.samples.vision.digitalink.recognition.kotlin\n\nimport android.os.Bundle\nimport androidx.appcompa"
},
{
"path": "android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/kotlin/DrawingView.kt",
"chars": 6770,
"preview": "package com.google.mlkit.samples.vision.digitalink.recognition.kotlin\n\nimport android.content.Context\nimport android.gra"
},
{
"path": "android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/kotlin/ModelManager.kt",
"chars": 3914,
"preview": "package com.google.mlkit.samples.vision.digitalink.recognition.kotlin\n\nimport android.util.Log\nimport com.google.android"
},
{
"path": "android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/kotlin/RecognitionTask.kt",
"chars": 1863,
"preview": "package com.google.mlkit.samples.vision.digitalink.recognition.kotlin\n\nimport android.util.Log\nimport com.google.android"
},
{
"path": "android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/kotlin/StatusTextView.kt",
"chars": 853,
"preview": "package com.google.mlkit.samples.vision.digitalink.recognition.kotlin\n\nimport android.content.Context\nimport androidx.ap"
},
{
"path": "android/digitalink/app/src/main/java/com/google/mlkit/samples/vision/digitalink/recognition/kotlin/StrokeManager.kt",
"chars": 7705,
"preview": "package com.google.mlkit.samples.vision.digitalink.recognition.kotlin\n\nimport android.os.Handler\nimport android.os.Messa"
},
{
"path": "android/digitalink/app/src/main/res/layout/activity_digital_ink_main.xml",
"chars": 3157,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n andr"
},
{
"path": "android/digitalink/app/src/main/res/layout/activity_digital_ink_main_kotlin.xml",
"chars": 3171,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n andr"
},
{
"path": "android/digitalink/app/src/main/res/values/colors.xml",
"chars": 207,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"colorPrimary\">#6200EE</color>\n <color name=\"color"
},
{
"path": "android/digitalink/app/src/main/res/values/strings.xml",
"chars": 285,
"preview": "<resources>\n <string name=\"app_name\" translatable=\"false\">ML Kit Digital Ink Recognition Demo</string>\n <string na"
},
{
"path": "android/digitalink/app/src/main/res/values/styles.xml",
"chars": 381,
"preview": "<resources>\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar\""
},
{
"path": "android/digitalink/build.gradle",
"chars": 694,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\nbuildscript {\n ex"
},
{
"path": "android/digitalink/gradle/wrapper/gradle-wrapper.properties",
"chars": 232,
"preview": "#Mon Jan 24 22:29:24 UTC 2022\ndistributionBase=GRADLE_USER_HOME\ndistributionUrl=https\\://services.gradle.org/distributio"
},
{
"path": "android/digitalink/gradle.properties",
"chars": 887,
"preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will o"
},
{
"path": "android/digitalink/gradlew",
"chars": 5296,
"preview": "#!/usr/bin/env sh\n\n##############################################################################\n##\n## Gradle start up"
},
{
"path": "android/digitalink/gradlew.bat",
"chars": 2260,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\r\n@rem ##########################################################################\r\n@rem\r\n@r"
},
{
"path": "android/digitalink/settings.gradle",
"chars": 71,
"preview": "include ':app'\nrootProject.name = \"ML Kit Digital Ink Recognition Demo\""
},
{
"path": "android/documentscanner/LICENSE",
"chars": 10757,
"preview": " Copyright 2024 Google LLC\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this"
},
{
"path": "android/documentscanner/README.md",
"chars": 1372,
"preview": "# ML Kit Document Scanner API Quickstart\n\n* [Read more about ML Kit Document Scanner API](https://developers.google.com/"
},
{
"path": "android/documentscanner/app/build.gradle",
"chars": 2056,
"preview": "apply plugin: 'com.android.application'\napply plugin: 'kotlin-android'\napply plugin: 'kotlin-android-extensions'\n\nandroi"
},
{
"path": "android/documentscanner/app/src/main/AndroidManifest.xml",
"chars": 1485,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:to"
},
{
"path": "android/documentscanner/app/src/main/java/com/google/mlkit/samples/documentscanner/EntryChoiceActivity.kt",
"chars": 1396,
"preview": "/*\n * Copyright 2024 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/documentscanner/app/src/main/java/com/google/mlkit/samples/documentscanner/java/MainActivity.java",
"chars": 6953,
"preview": "/*\n * Copyright 2024 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/documentscanner/app/src/main/java/com/google/mlkit/samples/documentscanner/kotlin/MainActivity.kt",
"chars": 6613,
"preview": "/*\n * Copyright 2024 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/documentscanner/app/src/main/res/drawable/logo_mlkit.xml",
"chars": 1651,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tool"
},
{
"path": "android/documentscanner/app/src/main/res/layout/activity_main.xml",
"chars": 2454,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n andr"
},
{
"path": "android/documentscanner/app/src/main/res/values/colors.xml",
"chars": 331,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"colorPrimary\">@color/blue</color>\n <color name=\"color"
},
{
"path": "android/documentscanner/app/src/main/res/values/strings.xml",
"chars": 809,
"preview": "<resources>\n <string name=\"app_name\" translatable=\"false\">Document Scanner Demo</string>\n <string name=\"scan_button\" t"
},
{
"path": "android/documentscanner/app/src/main/res/values/styles.xml",
"chars": 304,
"preview": "<resources>\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"Theme.MaterialComponents.Light.DarkActio"
},
{
"path": "android/documentscanner/app/src/main/res/xml/file_paths.xml",
"chars": 161,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<paths xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <cache-pat"
},
{
"path": "android/documentscanner/build.gradle",
"chars": 390,
"preview": "buildscript {\n ext.kotlin_version = '1.7.20'\n\n repositories {\n mavenLocal()\n google()\n jcente"
},
{
"path": "android/documentscanner/gradle/wrapper/gradle-wrapper.properties",
"chars": 221,
"preview": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributi"
},
{
"path": "android/documentscanner/gradle.properties",
"chars": 779,
"preview": "# Project-wide Gradle settings.\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will ov"
},
{
"path": "android/documentscanner/gradlew",
"chars": 8472,
"preview": "#!/bin/sh\n\n#\n# Copyright © 2015-2021 the original authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "android/documentscanner/gradlew.bat",
"chars": 2868,
"preview": "@rem\r\n@rem Copyright 2015 the original author or authors.\r\n@rem\r\n@rem Licensed under the Apache License, Version 2.0 (th"
},
{
"path": "android/documentscanner/settings.gradle",
"chars": 166,
"preview": "rootProject.name= \"mlkit_document_scanner_sample\"\ninclude ':app'\ninclude ':internal:chooserx'\nproject(':internal:chooser"
},
{
"path": "android/entityextraction/README.md",
"chars": 2865,
"preview": "# ML Kit Entity Extraction Quickstart\n\n* [Read more about ML Kit Entity Extraction API](https://developers.google.com/ml"
},
{
"path": "android/entityextraction/app/build.gradle",
"chars": 1673,
"preview": "apply plugin: 'com.android.application'\napply plugin: 'kotlin-android'\napply plugin: 'kotlin-parcelize'\n\nandroid {\n n"
},
{
"path": "android/entityextraction/app/src/main/AndroidManifest.xml",
"chars": 1048,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package="
},
{
"path": "android/entityextraction/app/src/main/java/com/google/mlkit/samples/nl/entityextraction/EntryChoiceActivity.kt",
"chars": 797,
"preview": "package com.google.mlkit.samples.nl.entityextraction\n\nimport android.content.Intent\nimport com.google.mlkit.samples.nl.e"
},
{
"path": "android/entityextraction/app/src/main/java/com/google/mlkit/samples/nl/entityextraction/java/MainActivityJava.java",
"chars": 11704,
"preview": "package com.google.mlkit.samples.nl.entityextraction.java;\n\nimport static com.google.mlkit.nl.entityextraction.DateTimeE"
},
{
"path": "android/entityextraction/app/src/main/java/com/google/mlkit/samples/nl/entityextraction/java/ModelsActivityJava.java",
"chars": 6554,
"preview": "package com.google.mlkit.samples.nl.entityextraction.java;\n\nimport android.content.Intent;\nimport android.os.Bundle;\nimp"
},
{
"path": "android/entityextraction/app/src/main/java/com/google/mlkit/samples/nl/entityextraction/kotlin/MainActivityKotlin.kt",
"chars": 9798,
"preview": "package com.google.mlkit.samples.nl.entityextraction.kotlin\n\nimport android.app.Activity\nimport android.content.Intent\ni"
},
{
"path": "android/entityextraction/app/src/main/java/com/google/mlkit/samples/nl/entityextraction/kotlin/ModelsActivityKotlin.kt",
"chars": 5473,
"preview": "package com.google.mlkit.samples.nl.entityextraction.kotlin\n\nimport android.app.Activity\nimport android.content.Intent\ni"
},
{
"path": "android/entityextraction/app/src/main/res/drawable/ic_baseline_delete_gray_32.xml",
"chars": 350,
"preview": "<vector android:height=\"32dp\" android:tint=\"#606060\"\n android:viewportHeight=\"24\" android:viewportWidth=\"24\"\n andr"
},
{
"path": "android/entityextraction/app/src/main/res/drawable/ic_baseline_get_app_gray_32.xml",
"chars": 309,
"preview": "<vector android:height=\"32dp\" android:tint=\"#606060\"\n android:viewportHeight=\"24\" android:viewportWidth=\"24\"\n andr"
},
{
"path": "android/entityextraction/app/src/main/res/drawable/ic_baseline_get_app_white_32.xml",
"chars": 309,
"preview": "<vector android:height=\"32dp\" android:tint=\"#FFFFFF\"\n android:viewportHeight=\"24\" android:viewportWidth=\"24\"\n andr"
},
{
"path": "android/entityextraction/app/src/main/res/drawable/logo_mlkit.xml",
"chars": 1574,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:wi"
},
{
"path": "android/entityextraction/app/src/main/res/layout/activity_main.xml",
"chars": 1808,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:"
},
{
"path": "android/entityextraction/app/src/main/res/layout/activity_models.xml",
"chars": 691,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n andr"
},
{
"path": "android/entityextraction/app/src/main/res/layout/list_item.xml",
"chars": 804,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n andr"
},
{
"path": "android/entityextraction/app/src/main/res/menu/menu_choose_model.xml",
"chars": 317,
"preview": "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:app=\"http://schemas.android.com/apk/res-auto\""
},
{
"path": "android/entityextraction/app/src/main/res/values/colors.xml",
"chars": 332,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"colorPrimary\">@color/blue</color>\n <color name=\"color"
},
{
"path": "android/entityextraction/app/src/main/res/values/strings.xml",
"chars": 5142,
"preview": "<resources>\n <!-- Application name -->\n <string name=\"app_name\">MLKit-EntityExtraction</string>\n <string name=\"curren"
},
{
"path": "android/entityextraction/app/src/main/res/values/styles.xml",
"chars": 346,
"preview": "<resources>\n\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"Theme.MaterialComponents.Light.DarkActi"
},
{
"path": "android/entityextraction/build.gradle",
"chars": 369,
"preview": "buildscript {\n ext.kotlin_version = '2.1.0'\n\n repositories {\n google()\n jcenter()\n }\n dependen"
},
{
"path": "android/entityextraction/gradle.properties",
"chars": 294,
"preview": "android.useAndroidX=true\nandroid.enableJetifier=true\n\n# The setting is particularly useful for tweaking memory settings."
},
{
"path": "android/entityextraction/settings.gradle",
"chars": 169,
"preview": "rootProject.name = \"mlkit_entity_extraction_sample\"\ninclude ':app'\ninclude ':internal:chooserx'\nproject(':internal:choos"
},
{
"path": "android/genai/README.md",
"chars": 1888,
"preview": "# ML Kit GenAI APIs Quickstart\n\n* [Read more about ML Kit GenAI APIs](https://developers.google.com/ml-kit/genai)\n\n## In"
},
{
"path": "android/genai/app/build.gradle",
"chars": 2662,
"preview": "/*\n * Copyright 2025 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\""
},
{
"path": "android/genai/app/src/main/AndroidManifest.xml",
"chars": 3532,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n Copyright 2025 The Android Open Source Project\n\n Licensed under the"
},
{
"path": "android/genai/app/src/main/java/com/google/mlkit/genai/demo/ContentAdapter.kt",
"chars": 10584,
"preview": "/*\n * Copyright 2025 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/genai/app/src/main/java/com/google/mlkit/genai/demo/ContentItem.kt",
"chars": 4394,
"preview": "/*\n * Copyright 2025 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/genai/app/src/main/java/com/google/mlkit/genai/demo/EntryChoiceActivity.kt",
"chars": 4152,
"preview": "/*\n * Copyright 2025 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/genai/app/src/main/java/com/google/mlkit/genai/demo/GenerationConfigDialog.kt",
"chars": 6376,
"preview": "/*\n * Copyright 2025 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/genai/app/src/main/java/com/google/mlkit/genai/demo/GenerationConfigUtils.kt",
"chars": 4628,
"preview": "/*\n * Copyright 2025 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/genai/app/src/main/java/com/google/mlkit/genai/demo/java/BaseActivity.java",
"chars": 20766,
"preview": "/*\n * Copyright 2025 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/genai/app/src/main/java/com/google/mlkit/genai/demo/java/ImageDescriptionActivity.java",
"chars": 5739,
"preview": "/*\n * Copyright 2025 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/genai/app/src/main/java/com/google/mlkit/genai/demo/java/OpenPromptActivity.java",
"chars": 25299,
"preview": "/*\n * Copyright 2025 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/genai/app/src/main/java/com/google/mlkit/genai/demo/java/ProofreadingActivity.java",
"chars": 6050,
"preview": "/*\n * Copyright 2025 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/genai/app/src/main/java/com/google/mlkit/genai/demo/java/RewritingActivity.java",
"chars": 6120,
"preview": "/*\n * Copyright 2025 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/genai/app/src/main/java/com/google/mlkit/genai/demo/java/SummarizationActivity.java",
"chars": 6072,
"preview": "/*\n * Copyright 2025 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/genai/app/src/main/java/com/google/mlkit/genai/demo/java/TextInputBaseActivity.java",
"chars": 2133,
"preview": "/*\n * Copyright 2025 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
},
{
"path": "android/genai/app/src/main/java/com/google/mlkit/genai/demo/kotlin/BaseActivity.kt",
"chars": 18404,
"preview": "/*\n * Copyright 2025 Google LLC. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License"
}
]
// ... and 667 more files (download for full content)
About this extraction
This page contains the full source code of the googlesamples/mlkit GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 867 files (3.9 MB), approximately 1.1M tokens, and a symbol index with 951 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.