### Efficient Graphics Overlay Rendering for ML Kit Outputs Source: https://developers.google.com/ml-kit/guides/vision/text-recognition/v2/android To optimize performance when overlaying graphics based on ML Kit detector output, combine the image rendering and graphics overlay steps into a single operation. This approach ensures that the display surface is updated only once per input frame, reducing rendering overhead. Examples can be found in the `CameraSourcePreview` and `GraphicOverlay` classes of the quickstart sample app. ```APIDOC Rendering: Get ML Kit result, then render image and overlay in a single step. Goal: Render to display surface only once per input frame. Example: `CameraSourcePreview` (Java in quickstart sample app) Example: `GraphicOverlay` (Java in quickstart sample app) ``` -------------------------------- ### ML Kit Android API Model Installation Path Compatibility Source: https://developers.google.com/ml-kit/guides/tips/installation-paths This table details the supported model installation methods (Unbundled, Bundled, Dynamically downloaded) for various ML Kit features on Android. '✅' indicates support for that installation path. ```APIDOC Text recognition v2: Unbundled: ✅ Bundled: ✅ Dynamically downloaded: Face detection: Unbundled: ✅ Bundled: ✅ Dynamically downloaded: Face mesh detection: Unbundled: Bundled: ✅ Dynamically downloaded: Pose detection: Unbundled: Bundled: ✅ Dynamically downloaded: Selfie segmentation: Unbundled: Bundled: ✅ Dynamically downloaded: Barcode scanning: Unbundled: ✅ Bundled: ✅ Dynamically downloaded: Image labeling: Unbundled: ✅ Bundled: ✅ Dynamically downloaded: Object detection and tracking: Unbundled: Bundled: ✅ Dynamically downloaded: Digital ink recognition: Unbundled: Bundled: Dynamically downloaded: ✅ Document scanner: Unbundled: ✅ Bundled: Dynamically downloaded: Subject segmentation: Unbundled: ✅ Bundled: Dynamically downloaded: Google code scanner: Unbundled: ✅ Bundled: Dynamically downloaded: Language identification: Unbundled: ✅ Bundled: ✅ Dynamically downloaded: Translation: Unbundled: Bundled: Dynamically downloaded: ✅ Smart Reply: Unbundled: ✅ Bundled: ✅ Dynamically downloaded: Entity Extraction: Unbundled: Bundled: Dynamically downloaded: ✅ ``` -------------------------------- ### ML Kit Text Recognition API Overview and Usage Source: https://developers.google.com/ml-kit/guides/vision/text-recognition/v2/android This section provides a comprehensive overview of ML Kit's Text Recognition API, detailing its capabilities for extracting text from images and videos on Android devices. It covers installation options (bundled vs. unbundled models), methods for creating input images, the text recognition process using `TextRecognizer`, and the structure of the output `Text` object, including `TextBlock`, `Line`, `Element`, and `Symbol` data. Performance considerations related to image quality and resolution are also highlighted. ```APIDOC ML Kit's Text Recognition API: Purpose: Extract text from images and videos (Android API 21+). Installation Options: - Bundled: Larger app size, faster initialization (~4MB per script). - Unbundled: Smaller app size, dynamic download (~260KB per script). Supported Scripts: Latin, Chinese, Devanagari, Japanese, Korean. Input Image Creation: - `InputImage` from media, file URI, byte data, or bitmap. Processing: - Use `TextRecognizer`. Output: - `Text` object containing `TextBlock`, `Line`, `Element`, `Symbol` data. - Each element includes extracted text and geometric information. Performance Factors: - Input image quality (resolution, focus) impacts accuracy. - Optimize by throttling detector calls and adjusting resolution. ``` -------------------------------- ### Create ML Kit InputImage from Bitmap Source: https://developers.google.com/ml-kit/guides/vision/text-recognition/v2/android Provides code examples for creating an `InputImage` object directly from an Android `Bitmap` object, including the image's rotation degree. ```Kotlin val image = InputImage.fromBitmap(bitmap, 0) ``` ```Java InputImage image = InputImage.fromBitmap(bitmap, rotationDegree); ``` -------------------------------- ### Entity Extraction API Output Examples Source: https://developers.google.com/ml-kit/guides/language/entity-extraction Demonstrates various entity types detected by the ML Kit Entity Extraction API from different input texts, including addresses, dates, email addresses, phone numbers, and payment card numbers. ```APIDOC Input text: "Meet me at 1600 Amphitheatre Parkway, Mountain View, CA, 94043 Let’s organize a meeting to discuss." Detected entities: - Type: Address Text: "1600 Ampitheatre Parkway, Mountain View, CA 94043" Input text: "You can contact the test team tomorrow at info@google.com to determine the best timeline." Detected entities: - Type: Date-Time Text: "June 24th, 2020" - Type: Email address Text: "info@google.com" Input text: "Your order has shipped from Google. To follow the progress of your delivery please use this tracking number: 9612804152073070474837" Detected entities: - Type: Tracking number Text: "9612804152073070474837" Input text: "Call the restaurant at 555-555-1234 to pay for dinner. My card number is 4111-1111-1111-1111." Detected entities: - Type: Phone number Text: "555-555-1234" - Type: Payment card Text: "4111 1111 1111 1111" ``` -------------------------------- ### Configure Install-Time Model Download in AndroidManifest.xml Source: https://developers.google.com/ml-kit/guides/tips/installation-paths This snippet shows how to enable automatic download of ML Kit models (e.g., Barcode Scanning) at app installation time. By adding a declaration to your app's AndroidManifest.xml, you can configure specific models to be downloaded immediately after the app is installed from the Play Store. Multiple models can be specified by comma-separating their names. ```XML ... ``` -------------------------------- ### Configure AndroidManifest for ML Kit Play Services Model Download Source: https://developers.google.com/ml-kit/guides/vision/text-recognition/v2/android This snippet shows how to configure your `AndroidManifest.xml` file to automatically download ML Kit text recognition models from Google Play Services upon app installation. It specifies the `ocr` dependency or multiple script-specific dependencies. ```XML ... ``` -------------------------------- ### Create ML Kit InputImage from File URI Source: https://developers.google.com/ml-kit/guides/vision/text-recognition/v2/android Shows how to create an `InputImage` object from a file URI, useful for images selected by the user from a gallery. Includes error handling for `IOException`. ```Kotlin val image: InputImage try { image = InputImage.fromFilePath(context, uri) } catch (e: IOException) { e.printStackTrace() } ``` ```Java InputImage image; try { image = InputImage.fromFilePath(context, uri); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Update ML Kit Image Labeler Model Initialization - Java Source: https://developers.google.com/ml-kit/guides/vision/image-labeling/automl/migrate-automl Illustrates the migration of local and remote image labeler model initialization in Java, transitioning from `AutoMLImageLabeler` classes to `LocalModel`, `CustomRemoteModel`, and `CustomImageLabelerOptions`. ```Java AutoMLImageLabelerLocalModel localModel = new AutoMLImageLabelerLocalModel.Builder() .setAssetFilePath("automl/manifest.json") // or .setAbsoluteFilePath(absolute file path to manifest file) .build(); AutoMLImageLabelerOptions optionsWithLocalModel = new AutoMLImageLabelerOptions.Builder(localModel) .setConfidenceThreshold(0.5f) .build(); AutoMLImageLabelerRemoteModel remoteModel = new AutoMLImageLabelerRemoteModel.Builder("automl_remote_model").build(); AutoMLImageLabelerOptions optionsWithRemoteModel = new AutoMLImageLabelerOptions.Builder(remoteModel) .build(); ``` ```Java LocalModel localModel = new LocalModel.Builder() .setAssetManifestFilePath("automl/manifest.json") // or .setAbsoluteManifestFilePath(absolute file path to manifest file) .build(); CustomImageLabelerOptions optionsWithLocalModel = new CustomImageLabelerOptions.Builder(localModel) .setConfidenceThreshold(0.5f) .build(); FirebaseModelSource firebaseModelSource = new FirebaseModelSource.Builder("automl_remote_model").build(); CustomRemoteModel remoteModel = new CustomRemoteModel.Builder(firebaseModelSource).build(); CustomImageLabelerOptions optionsWithRemoteModel = new CustomImageLabelerOptions.Builder(remoteModel).build(); ``` -------------------------------- ### Configure AndroidManifest for ML Kit Pipeline Auto-Download Source: https://developers.google.com/ml-kit/guides/vision/image-labeling/custom-models/android Add this meta-data declaration to your app's `AndroidManifest.xml` file to enable automatic download of the ML Kit custom image labeling pipeline after app installation from the Play Store. This ensures the pipeline is available when the app first runs. ```XML ... ``` -------------------------------- ### ML Kit Entity Extraction API Specification Source: https://developers.google.com/ml-kit/guides/language/entity-extraction Detailed specification of the ML Kit Entity Extraction API, including its beta status, core functionality, focus on precision, and a comprehensive list of supported entity types with examples, along with the natural languages supported for entity detection. ```APIDOC ML Kit Entity Extraction API Status: Beta - Not subject to SLA or deprecation policy. - Changes may break backward compatibility. Purpose: - Improves user experience by understanding text. - Allows adding helpful shortcuts based on context. - Recognizes specific entities within static text and while typing. - Enables different actions for the user based on entity type. Focus: Precision over recognition (some instances might not be detected to ensure accuracy). Supported Entities: - Address: e.g., "350 third street, Cambridge MA" - Date-Time: e.g., "2019/09/29, let's meet tomorrow at 6pm" - Email address: e.g., "entity-extraction@google.com" - Flight Number (IATA flight codes only): e.g., "LX37" - IBAN: e.g., "CH52 0483 0000 0000 0000 9" - ISBN (version 13 only): e.g., "978-1101904190" - Money/Currency (Arabic numerals only): e.g., "$12, 25 USD" - Payment / Credit Cards: e.g., "4111 1111 1111 1111" - Phone Number: e.g., "(555) 225-3556 12345" - Tracking Number (standardized international formats): e.g., "1Z204E380338943508" - URL: e.g., "www.google.com https://en.wikipedia.org/wiki/Platypus" Supported Languages for Detection: - Arabic - Portuguese - English (US, UK) - Dutch - French - German - Italian - Japanese - Korean - Polish - Russian - Chinese (Simplified, Traditional) - Spanish - Thai - Turkish (Note: Address and phone number detection depends on the selected language.) ``` -------------------------------- ### Swift ML Kit Face Detection API: Classes Overview Source: https://developers.google.com/ml-kit/guides/reference/swift/mlkittextrecognitioncommon/api/reference/Classes/TextBlock API reference overview for classes within ML Kit's Face Detection module for Swift. ```APIDOC Classes Overview ``` -------------------------------- ### Create ML Kit InputImage from MediaImage Source: https://developers.google.com/ml-kit/guides/vision/text-recognition/v2/android Demonstrates how to create an `InputImage` object for ML Kit from a `media.Image` object, along with a pre-calculated rotation degree. This is a common method for handling camera output. ```Kotlin val image = InputImage.fromMediaImage(mediaImage, rotation) ``` ```Java InputImage image = InputImage.fromMediaImage(mediaImage, rotation); ``` -------------------------------- ### Swift ML Kit Face Detection API: Protocols Source: https://developers.google.com/ml-kit/guides/reference/swift/mlkittextrecognitioncommon/api/reference/Classes/TextBlock API reference for protocols defined within ML Kit's Face Detection module for Swift. ```APIDOC Protocols ``` -------------------------------- ### ML Kit Smart Reply Library Installation Options Source: https://developers.google.com/ml-kit/guides/language/smart-reply/android Comparison of bundled and unbundled ML Kit Smart Reply libraries for Android, detailing their names, implementation, app size impact, and initialization time. The unbundled version is currently in beta. ```APIDOC Library Comparison: Bundled: Library name: com.google.mlkit:smart-reply Implementation: Model is statically linked to your app at build time. App size impact: About 5.7 MB size increase. Initialization time: Model is available immediately. Unbundled (Beta): Library name: com.google.android.gms:play-services-mlkit-smart-reply Implementation: Model is dynamically downloaded via Google Play Services. App size impact: About 200 KB size increase. Initialization time: Might have to wait for model to download before first use. ``` -------------------------------- ### Configure ML Kit ImageLabeler Source: https://developers.google.com/ml-kit/guides/vision/image-labeling/android Demonstrates how to obtain an instance of ImageLabeler using ImageLabeling.getClient(). Examples include using default options and setting a custom confidence threshold. ```Kotlin // 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) ``` ```Java // 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); ``` -------------------------------- ### Throttle ML Kit Detector Calls with Camera and Camera2 APIs Source: https://developers.google.com/ml-kit/guides/vision/text-recognition/v2/android To prevent performance bottlenecks when using the Camera or Camera2 API, implement a throttling mechanism for detector calls. If a new video frame becomes available while the detector is busy, the frame should be dropped to avoid queuing and processing stale data. Refer to the `VisionProcessorBase` class in the ML Kit quickstart sample for an example implementation. ```APIDOC Camera API: Throttle detector calls to drop frames if detector is busy. Reference: `android.hardware.Camera` Reference: `android.hardware.camera2.package-summary` Example: `VisionProcessorBase` (Kotlin/Java in quickstart sample app) ``` -------------------------------- ### Start Barcode Scanning and Handle Results (ML Kit) Source: https://developers.google.com/ml-kit/guides/code-scanner This snippet demonstrates how to initiate a barcode scan using the GmsBarcodeScanner's startScan() method. It includes listeners for successful completion, cancellation, and failure, allowing for robust error handling and user feedback during the scanning process. ```Kotlin scanner.startScan() .addOnSuccessListener { barcode -> // Task completed successfully } .addOnCanceledListener { // Task canceled } .addOnFailureListener { e -> // Task failed with an exception } ``` ```Java scanner .startScan() .addOnSuccessListener( barcode -> { // Task completed successfully }) .addOnCanceledListener( () -> { // Task canceled }) .addOnFailureListener( e -> { // Task failed with an exception }); ``` -------------------------------- ### Create InputImage from Bitmap (Kotlin & Java) Source: https://developers.google.com/ml-kit/guides/vision/image-labeling/custom-models/android Provides examples for creating an InputImage object directly from an Android Bitmap object. This is a straightforward method when you already have the image loaded into a Bitmap, requiring only the Bitmap and its rotation degree. ```Kotlin val image = InputImage.fromBitmap(bitmap, 0) ``` ```Java InputImage image = InputImage.fromBitmap(bitmap, rotationDegree); ``` -------------------------------- ### Swift ML Kit Entity Extraction API: Enumerations Overview Source: https://developers.google.com/ml-kit/guides/reference/swift/mlkittextrecognitioncommon/api/reference/Classes/TextBlock API reference overview for enumerations within ML Kit's Entity Extraction module for Swift. ```APIDOC Enumerations Overview ``` -------------------------------- ### Old ML Kit Model Initialization in Java Source: https://developers.google.com/ml-kit/guides/migration/android Illustrates the previous API for initializing various ML Kit models in Java, covering image labelers, object detectors, face detectors, and custom AutoML models. ```java // Construct image labeler with base model and default options. FirebaseVisionImageLabeler imagelLabeler = FirebaseVision.getInstance().getOnDeviceImageLabeler(); // Construct object detector with base model and default options. FirebaseVisionObjectDetector objectDetector = FirebaseVision.getInstance().getOnDeviceObjectDetector(); // Construct face detector with given options FirebaseVisionFaceDetector faceDetector = FirebaseVision.getInstance().getVisionFaceDetector(options); // Construct image labeler with local AutoML model FirebaseAutoMLLocalModel localModel = new FirebaseAutoMLLocalModel.Builder() .setAssetFilePath("automl/manifest.json") .build(); FirebaseVisionImageLabeler autoMLImageLabeler = FirebaseVision.getInstance() .getOnDeviceAutoMLImageLabeler( FirebaseVisionOnDeviceAutoMLImageLabelerOptions.Builder(localModel) .setConfidenceThreshold(0.3F) .build()); ``` -------------------------------- ### ML Kit InputImage API Documentation Source: https://developers.google.com/ml-kit/guides/vision/object-detection/android Provides details on preparing input images for the ObjectDetector's process() method. It outlines recommended image sources and specifically documents the InputImage.fromMediaImage() method for creating input images from media.Image objects. ```APIDOC ObjectDetector: process() method: Takes InputImage as parameter. InputImage Class: Purpose: Represents an input image for ML Kit detectors. Recommended Sources: Bitmap, NV21 ByteBuffer, YUV_420_888 media.Image. Methods: fromMediaImage(media.Image image, int rotation): Description: Creates an InputImage object from a media.Image object. Parameters: image: The media.Image object (e.g., from device camera). rotation: The image's rotation value (e.g., from CameraX). Return Type: InputImage ``` -------------------------------- ### Run Image Labeler on InputImage (Kotlin) Source: https://developers.google.com/ml-kit/guides/vision/image-labeling/custom-models/android Demonstrates how to pass the prepared InputImage object to the ImageLabeler's process() method to initiate image labeling. It includes handling for both successful completion and potential failures using addOnSuccessListener and addOnFailureListener. ```Kotlin labeler.process(image) .addOnSuccessListener { labels -> // Task completed successfully // ... } .addOnFailureListener { e -> // Task failed with an exception // ... } ``` -------------------------------- ### Initialize ML Kit Image Labeler Models (Old Objective-C API) Source: https://developers.google.com/ml-kit/guides/vision/image-labeling/automl/migrate-automl This snippet illustrates the initialization of local and remote AutoML image labeler models using the older Objective-C API. It involves `MLKAutoMLImageLabelerLocalModel` and `MLKAutoMLImageLabelerRemoteModel`. ```Objective-C MLKAutoMLImageLabelerLocalModel *localModel = [[MLKAutoMLImageLabelerLocalModel alloc] initWithManifestPath:"automl/manifest.json"]; MLKAutoMLImageLabelerOptions *optionsWithLocalModel = [[MLKAutoMLImageLabelerOptions alloc] initWithLocalModel:localModel]; MLKAutoMLImageLabelerRemoteModel *remoteModel = [[MLKAutoMLImageLabelerRemoteModel alloc] initWithManifestPath:"automl/manifest.json"]; MLKAutoMLImageLabelerOptions *optionsWithRemoteModel = [[MLKAutoMLImageLabelerOptions alloc] initWithRemoteModel:remoteModel]; ``` -------------------------------- ### Swift ML Kit Entity Extraction API: Classes Overview Source: https://developers.google.com/ml-kit/guides/reference/swift/mlkittextrecognitioncommon/api/reference/Classes/TextBlock API reference overview for classes within ML Kit's Entity Extraction module for Swift. ```APIDOC Classes Overview ``` -------------------------------- ### Google ML Kit Swift API Modules and Components Overview Source: https://developers.google.com/ml-kit/guides/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/WritingArea Comprehensive listing of modules, classes, protocols, constants, and type definitions available in the Google ML Kit Swift API. Each entry represents a link to its respective overview or definition page. ```APIDOC MLKitImageLabeling: Type Definitions Classes: Overview CommonImageLabelerOptions ImageLabelerOptions MLKitImageLabelingCommon: Classes: Overview CommonImageLabelerOptions ImageLabel ImageLabeler Protocols Type Definitions MLKitImageLabelingCustom: Classes: Overview CommonImageLabelerOptions CustomImageLabelerOptions MLKitLanguageID: Classes: Overview IdentifiedLanguage LanguageIdentification LanguageIdentificationOptions Constants Type Definitions MLKitObjectDetection: Classes: Overview CommonObjectDetectorOptions ObjectDetectorOptions Constants Type Definitions MLKitObjectDetectionCommon: Classes: Overview CommonObjectDetectorOptions Object ObjectDetector ObjectLabel Constants Protocols Type Definitions MLKitObjectDetectionCustom: Classes: Overview CommonObjectDetectorOptions CustomObjectDetectorOptions Constants Type Definitions MLKitPoseDetection: Classes: Overview CommonPoseDetectorOptions PoseDetectorOptions Constants Type Definitions MLKitPoseDetectionAccurate: Classes: Overview ``` -------------------------------- ### Swift ML Kit Entity Extraction API: Categories Overview Source: https://developers.google.com/ml-kit/guides/reference/swift/mlkittextrecognitioncommon/api/reference/Classes/TextBlock API reference overview for categories within ML Kit's Entity Extraction module for Swift. ```APIDOC Categories Overview ``` -------------------------------- ### Retrieve Detailed Face Mesh Information in Kotlin Source: https://developers.google.com/ml-kit/guides/vision/face-mesh-detection/android This Kotlin example illustrates how to iterate through detected FaceMesh objects and extract various details. It demonstrates accessing the bounding box, iterating through all individual face mesh points to get their index and position, and retrieving triangle information to understand the mesh's structure. ```Kotlin for (faceMesh in faceMeshs) { val bounds: Rect = faceMesh.boundingBox() // Gets all points val faceMeshpoints = faceMesh.allPoints for (faceMeshpoint in faceMeshpoints) { val index: Int = faceMeshpoints.index() val position = faceMeshpoint.position } // Gets triangle info val triangles: List> = faceMesh.allTriangles for (triangle in triangles) { // 3 Points connecting to each other and representing a triangle area. val connectedPoints = triangle.allPoints() } } ``` -------------------------------- ### Initialize Barcode Detector Source: https://developers.google.com/ml-kit/guides/mobile-vision-migration/ios Examples for initializing the barcode detector using both the legacy Google Mobile Vision (GMV) and the newer ML Kit APIs, demonstrating how to set desired barcode formats. ```Objective-C NSDictionary *options = @{ GMVDetectorBarcodeFormats : @(GMVDetectorBarcodeFormatCode128 | GMVDetectorBarcodeFormatQRCode) }; GMVDetector *barcodeDetector = [GMVDetector detectorOfType:GMVDetectorTypeBarcode options:options]; ``` ```Objective-C MLKBarcodeScannerOptions *options = [[MLKBarcodeScannerOptions alloc] init]; options.formats = MLKBarcodeFormatCode128 | MLKBarcodeFormatQRCode; MLKBarcodeScanner *barcodeScanner = [MLKBarcodeScanner barcodeScannerWithOptions:options]; ``` -------------------------------- ### Migrating Object Detector API Source: https://developers.google.com/ml-kit/guides/migration/ios Details the transition for obtaining an object detector. The old API's `Vision.vision().objectDetector()` is replaced by `ObjectDetector.objectDetector(options:)`, now requiring options for initialization. ```Swift let detector = Vision.vision().objectDetector() ``` ```Swift let detector = ObjectDetector.objectDetector(options: ObjectDetectorOptions()) ``` ```Objective-C FIRVisionObjectDetector *detector = [[FIRVision vision] objectDetector]; ``` ```Objective-C MLKObjectDetectorOptions *options = [[MLKObjectDetectorOptions alloc] init]; MLKObjectDetector *detector = [MLKObjectDetector objectDetectorWithOptions:options]; ``` -------------------------------- ### Swift ML Kit API Reference Structure Source: https://developers.google.com/ml-kit/guides/reference/swift/mlkittextrecognitioncommon/api/reference/Classes/TextBlock Provides a hierarchical overview of the Swift API documentation for Google ML Kit, listing modules and their contained classes, categories, constants, protocols, and type definitions. ```APIDOC MLKitPoseDetectionAccurate: Classes: - AccuratePoseDetectorOptions - CommonPoseDetectorOptions Constants: Type Definitions: MLKitPoseDetectionCommon: Classes: - Overview - CommonPoseDetectorOptions - Pose - PoseDetector - PoseLandmark Constants: Protocols: Type Definitions: MLKitSegmentationCommon: Classes: - Overview - CommonSegmenterOptions - SegmentationMask - Segmenter Constants: Protocols: Type Definitions: MLKitSegmentationSelfie: Classes: - Overview - CommonSegmenterOptions - SelfieSegmenterOptions Constants: Type Definitions: MLKitSmartReply: Classes: - Overview - SmartReply - SmartReplySuggestion - SmartReplySuggestionResult - TextMessage Constants: Type Definitions: MLKitTextRecognition (v2): Categories: - Overview - MLKTextRecognizer(Latin) Classes: - Overview - CommonTextRecognizerOptions - TextRecognizer - TextRecognizerOptions Protocols: Type Definitions: MLKitTextRecognitionChinese: Classes: - Overview - ChineseTextRecognizerOptions - CommonTextRecognizerOptions MLKitTextRecognitionCommon: Classes: - Overview - CommonTextRecognizerOptions ``` -------------------------------- ### Old ML Kit Model Initialization in Kotlin Source: https://developers.google.com/ml-kit/guides/migration/android Demonstrates the previous API for initializing various ML Kit models in Kotlin, including image labelers, object detectors, face detectors, and custom AutoML models. ```kotlin // Construct image labeler with base model and default options. val imageLabeler = FirebaseVision.getInstance().onDeviceImageLabeler // Construct object detector with base model and default options. val objectDetector = FirebaseVision.getInstance().onDeviceObjectDetector // Construct face detector with given options val faceDetector = FirebaseVision.getInstance().getVisionFaceDetector(options) // Construct image labeler with local AutoML model val localModel = FirebaseAutoMLLocalModel.Builder() .setAssetFilePath("automl/manifest.json") .build() val autoMLImageLabeler = FirebaseVision.getInstance() .getOnDeviceAutoMLImageLabeler( FirebaseVisionOnDeviceAutoMLImageLabelerOptions.Builder(localModel) .setConfidenceThreshold(0.3F) .build() ) ``` -------------------------------- ### Extract Recognized Text from ML Kit Text Object (Java) Source: https://developers.google.com/ml-kit/guides/vision/text-recognition/v2/android This Java snippet illustrates how to iterate through the 'Text' object's hierarchy (TextBlock, Line, Element, Symbol) to extract recognized text and associated attributes like bounding boxes and corner points. It provides a comprehensive example of accessing all levels of the text recognition result. ```Java 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(); } } } } TextRecognitionActivity.java ``` -------------------------------- ### Initialize ML Kit Image Labeler Models (New Swift API) Source: https://developers.google.com/ml-kit/guides/vision/image-labeling/automl/migrate-automl This snippet demonstrates the new Swift API for initializing local and remote custom image labeler models. It utilizes `LocalModel`, `CustomRemoteModel`, and `FirebaseModelSource`. ```Swift guard let localModel = LocalModel(manifestPath: "automl/manifest.json") else { return } let optionsWithLocalModel = CustomImageLabelerOptions(localModel: localModel) let firebaseModelSource = FirebaseModelSource(name: "automl_remote_model") let remoteModel = CustomRemoteModel(remoteModelSource: firebaseModelSource) let optionsWithRemoteModel = CustomImageLabelerOptions(remoteModel: remoteModel) ``` -------------------------------- ### Get ML Kit Digital Ink Recognition Model Identifiers by Region Subtag (Objective-C) Source: https://developers.google.com/ml-kit/guides/reference/ios/mlkitdigitalinkrecognition/api/reference/Classes/MLKDigitalInkRecognitionModelIdentifier This method returns a set of MLKDigitalInkRecognitionModelIdentifier instances specific to a given region subtag. For example, providing 'CH' would return models for 'deCh', 'frCh', 'itCh', and 'rmCh'. The Objective-C code snippet for this method was not explicitly provided in the input text. ```APIDOC MLKDigitalInkRecognitionModelIdentifier: +modelIdentifiersForRegionSubtag(regionSubtag: NSString): Description: Returns the set of model identifiers that are specific to the given region subtag. E.g. for "CH", this would return a set of model identifiers containing deCh (German, Switzerland), frCh (French, Switzerland), itCh (Italian, Switzerland), and rmCh (Romansh, Switzerland). Parameters: regionSubtag: A region subtag, e.g. "CH" for Switzerland. Returns: NSSet: A set of model identifiers that are specific to the provided regionSubtag, may be empty. ``` -------------------------------- ### Initialize Text Recognizer in GMV and ML Kit Source: https://developers.google.com/ml-kit/guides/mobile-vision-migration/ios Demonstrates the different initialization patterns for text recognition detectors/recognizers when migrating from Google Mobile Vision (GMV) to ML Kit. This shows the updated approach for setting up the text recognition component. ```Objective-C GMVDetector *textDetector = [GMVDetector detectorOfType:GMVDetectorTypeText options:nil]; ``` ```Objective-C MLKTextRecognizer *textRecognizer = [MLKTextRecognizer textRecognizer]; ``` -------------------------------- ### ML Kit Swift API Modules and Components Overview Source: https://developers.google.com/ml-kit/guides/reference/swift/mlkitbarcodescanning/api/reference/Classes/BarcodeEmail Provides an overview of the various modules available in Google's ML Kit for Swift, listing their contained classes, protocols, constants, and type definitions. This serves as an index to the detailed API documentation. ```APIDOC MLKitImageLabeling: Type Definitions: Available Classes: - CommonImageLabelerOptions - ImageLabelerOptions MLKitImageLabelingCommon: Classes: - CommonImageLabelerOptions - ImageLabel - ImageLabeler Protocols: Available Type Definitions: Available MLKitImageLabelingCustom: Classes: - CommonImageLabelerOptions - CustomImageLabelerOptions MLKitLanguageID: Classes: - IdentifiedLanguage - LanguageIdentification - LanguageIdentificationOptions Constants: Available Type Definitions: Available MLKitObjectDetection: Classes: - CommonObjectDetectorOptions - ObjectDetectorOptions Constants: Available Type Definitions: Available MLKitObjectDetectionCommon: Classes: - CommonObjectDetectorOptions - Object - ObjectDetector - ObjectLabel Constants: Available Protocols: Available Type Definitions: Available MLKitObjectDetectionCustom: Classes: - CommonObjectDetectorOptions - CustomObjectDetectorOptions Constants: Available Type Definitions: Available MLKitPoseDetection: Classes: - CommonPoseDetectorOptions - PoseDetectorOptions Constants: Available Type Definitions: Available MLKitPoseDetectionAccurate: Classes: Available ``` -------------------------------- ### Get Digital Ink Recognition Model Identifiers for Language Subtag (Swift API) Source: https://developers.google.com/ml-kit/guides/reference/swift/mlkitdigitalinkrecognition/api/reference/Classes/DigitalInkRecognitionModelIdentifier Returns a set of DigitalInkRecognitionModelIdentifier instances that support a given 2 or 3-letter ISO 639 language code (subtag), such as 'en' for English. For example, 'en' would return models like 'enUs', 'enUk', 'enKe'. If no models are found for the subtag, an empty set is returned. ```APIDOC DigitalInkRecognitionModelIdentifier: modelIdentifiers(forLanguageSubtag languageSubtag: String) -> Set Parameters: languageSubtag: A 2 or 3-letter ISO 639 language code, e.g. "en" for English. Returns: A set of model identifiers that support the provided languageSubtag, may be empty. ``` -------------------------------- ### Optimize Graphics Overlay Rendering (iOS) Source: https://developers.google.com/ml-kit/guides/vision/barcode-scanning/ios To improve performance when overlaying graphics on processed images, first obtain the results from ML Kit, then render both the image and the overlay in a single step. This approach ensures that the display surface is updated only once per processed input frame, reducing rendering overhead. Refer to the updatePreviewOverlayViewWithLastFrame function in the ML Kit quickstart sample for an implementation example. ```APIDOC Rendering Strategy: 1. Get results from ML Kit. 2. Render image and overlay in a single step. Example Function (reference): - updatePreviewOverlayViewWithLastFrame (found in ML Kit quickstart sample) ``` -------------------------------- ### Instantiate ObjectDetector with Default or Custom Options Source: https://developers.google.com/ml-kit/guides/vision/object-detection/ios Shows how to obtain an instance of `ObjectDetector`, either using default settings or by providing a custom `ObjectDetectorOptions` configuration. ```Swift let objectDetector = ObjectDetector.objectDetector() // Or, to change the default settings: let objectDetector = ObjectDetector.objectDetector(options: options) ``` ```Objective-C MLKObjectDetector *objectDetector = [MLKObjectDetector objectDetector]; // Or, to change the default settings: MLKObjectDetector *objectDetector = [MLKObjectDetector objectDetectorWithOptions:options]; ``` -------------------------------- ### Get ML Kit Digital Ink Recognition Model Identifiers by Language Subtag (Objective-C) Source: https://developers.google.com/ml-kit/guides/reference/ios/mlkitdigitalinkrecognition/api/reference/Classes/MLKDigitalInkRecognitionModelIdentifier This method retrieves a set of MLKDigitalInkRecognitionModelIdentifier instances that support a given 2 or 3-letter ISO 639 language code (language subtag). For example, providing 'en' would return models for 'enUs', 'enUk', etc. An empty set is returned if no matching models are found. ```APIDOC MLKDigitalInkRecognitionModelIdentifier: +modelIdentifiersForLanguageSubtag(languageSubtag: NSString): Description: Returns the set of model identifiers that support the given language subtag. E.g. for "en", this would return a set of model identifiers containing enUs (English, United States), enUk (English, United Kingdom), enKe (English, Kenya), etc. If no model identifiers supporting the language subtag can be found, returns an empty set. Parameters: languageSubtag: A 2 or 3-letter ISO 639 language code, e.g. "en" for English. Returns: NSSet: A set of model identifiers that support the provided languageSubtag, may be empty. ``` ```Objective-C + (nonnull NSSet *) modelIdentifiersForLanguageSubtag:(nonnull NSString *)languageSubtag; ``` -------------------------------- ### Migrating On-Device Image Labeler API Source: https://developers.google.com/ml-kit/guides/migration/ios Demonstrates the migration path for initializing an on-device image labeler. The old API used `Vision.vision().onDeviceImageLabeler`, while the new API directly uses `ImageLabeler.imageLabeler` with `ImageLabelerOptions`. ```Swift let options = VisionOnDeviceImageLabelerOptions() options.confidenceThreshold = 0.75 let labeler = Vision.vision().onDeviceImageLabeler(options: options) ``` ```Swift let options = ImageLabelerOptions() options.confidenceThreshold = NSNumber(value:0.75) let labeler = ImageLabeler.imageLabeler(options: options) ``` ```Objective-C FIRVisionOnDeviceImageLabelerOptions *options = [[FIRVisionOnDeviceImageLabelerOptions alloc] init]; options.confidenceThreshold = 0.75; FIRVisionImageLabeler *labeler = [[FIRVision vision] onDeviceImageLabelerWithOptions:options]; ``` ```Objective-C MLKImageLabelerOptions *options = [[MLKImageLabelerOptions alloc] init]; options.confidenceThreshold = @(0.75); MLKImageLabeler *labeler = [MLKImageLabeler imageLabelerWithOptions:options]; ``` -------------------------------- ### Initialize ML Kit Custom Image Labeler Options (Objective-C) Source: https://developers.google.com/ml-kit/guides/vision/image-labeling/automl/migrate-automl This snippet demonstrates how to initialize MLKCustomImageLabelerOptions for ML Kit's custom image labeling feature in Objective-C. It shows configurations for both a locally bundled model using MLKLocalModel and a remotely hosted model fetched via MLKFirebaseModelSource and MLKCustomRemoteModel. This setup is part of migrating to the new custom model API, replacing the deprecated AutoML Vision Edge API. ```Objective-C MLKLocalModel *localModel = [[MLKLocalModel alloc] initWithManifestPath:"automl/manifest.json"]; MLKCustomImageLabelerOptions *optionsWithLocalModel = [[MLKCustomImageLabelerOptions alloc] initWithLocalModel:localModel]; MLKFirebaseModelSource *firebaseModelSource = [[MLKFirebaseModelSource alloc] initWithName:"automl_remote_model"]; MLKCustomRemoteModel *remoteModel = [[MLKCustomRemoteModel alloc] initWithRemoteModelSource:firebaseModelSource]; MLKCustomImageLabelerOptions *optionsWithRemoteModel = [[MLKCustomImageLabelerOptions alloc] initWithRemoteModel:remoteModel]; ``` -------------------------------- ### Enable Install-Time Code Scanner Module Download (Android Manifest) Source: https://developers.google.com/ml-kit/guides/code-scanner This XML snippet, placed within the `` tag of the Android Manifest, configures Google Play services to automatically download the ML Kit code scanner module to the device when the app is installed from the Play Store. This ensures the module is available upon first use. ```XML ... ... ``` -------------------------------- ### Configure ML Kit Barcode Model Install-Time Download for Android Source: https://developers.google.com/ml-kit/guides/vision/barcode-scanning/android Configures your Android app's AndroidManifest.xml to automatically download the ML Kit barcode model from the Play Store upon app installation when using the Google Play Services dependency. This ensures the model is available immediately after installation. ```XML ... ``` -------------------------------- ### Include ML Kit Translate Pod in Podfile Source: https://developers.google.com/ml-kit/guides/language/translation/ios Add the GoogleMLKit/Translate pod to your Podfile to integrate the ML Kit translation API into your iOS project. This step is required before using the API and ensures the necessary dependencies are installed. After installing or updating your project's Pods, open your Xcode project using its `.xcworkspace`. ```Ruby pod 'GoogleMLKit/Translate', '8.0.0' ``` -------------------------------- ### ML Kit Swift API Reference Overview Source: https://developers.google.com/ml-kit/guides/reference/swift/mlkitsmartreply/api/reference/Classes/SmartReplySuggestionResult Provides a hierarchical overview of the Google ML Kit Swift API, detailing the available frameworks, their classes, categories, protocols, type definitions, constants, and functions. This serves as an index to the comprehensive API documentation. ```APIDOC MLKitTextRecognitionCommon: Classes: - Text - TextBlock - TextElement - TextLine - TextRecognizedLanguage - TextRecognizer Protocols: (See Protocols Overview) Type Definitions: (See Type Definitions Overview) MLKitTextRecognitionDevanagari: Classes: - CommonTextRecognizerOptions - DevanagariTextRecognizerOptions MLKitTextRecognitionJapanese: Classes: - CommonTextRecognizerOptions - JapaneseTextRecognizerOptions MLKitTextRecognitionKorean: Classes: - CommonTextRecognizerOptions - KoreanTextRecognizerOptions MLKitTranslate: Categories: - MLKModelManager(Translate) Classes: - ModelManager - RemoteModel - TranslateRemoteModel - Translator - TranslatorOptions Constants: (See Constants Overview) Type Definitions: (See Type Definitions Overview) Functions: (See Functions Overview) MLKitVision: Classes: - MLImage - Vision3DPoint - VisionImage - VisionPoint Constants: (See Constants Overview) Protocols: (See Protocols Overview) Type Definitions: (See Type Definitions Overview) MLImage: Classes: - MLImage Constants: (See Constants Overview) Type Definitions: (See Type Definitions Overview) ``` -------------------------------- ### ML Kit Face Detection API Migration Guide (GMV to ML Kit) Source: https://developers.google.com/ml-kit/guides/mobile-vision-migration/android This API documentation provides a comprehensive mapping of deprecated `android.gms.vision.face` classes and methods to their equivalent `mlkit.vision.face` counterparts. It serves as a guide for developers migrating existing applications from Google Mobile Vision to the newer ML Kit Face Detection API, detailing class, method, and constant name changes. ```APIDOC Old API: android.gms.vision.face.FaceDetector New API: mlkit.vision.face.FaceDetector Old API: android.gms.vision.face.SparseArray detect(Frame frame) New API: mlkit.vision.face.Task> process(@NonNull InputImage image) Old API: FaceDetector.Builder.setClassificationType(int classificationType) New API: FaceDetectorOptions.Builder.setClassificationMode(int classificationMode) Old API: NO_CLASSIFICATIONS, ALL_CLASSIFICATIONS New API: CLASSIFICATION_MODE_NONE, CLASSIFICATION_MODE_ALL Old API: FaceDetector.Builder.setLandmarkType(int landmarkType) New API: FaceDetectorOptions.Builder.setLandmarkMode(int landmarkMode) Old API: NO_LANDMARKS, ALL_LANDMARKS, CONTOUR_LANDMARKS New API: LANDMARK_MODE_NONE, LANDMARK_MODE_ALL (use #setContourMode to replace GMV CONTOUR_LANDMARKS) Old API: FaceDetector.Builder.setTrackingEnabled(boolean trackingEnabled) New API: FaceDetectorOptions.Builder.enableTracking() Old API: FaceDetector.Builder.setMinFaceSize(float proportionalMinFaceSize) New API: FaceDetectorOptions.Builder.setMinFaceSize(float minFaceSize) Old API: FaceDetector.Builder.setMode(int mode) New API: FaceDetectorOptions.Builder.setPerformanceMode(int performanceMode) Old API: FAST_MODE, ACCURATE_MODE New API: PERFORMANCE_MODE_FAST, PERFORMANCE_MODE_ACCURATE Old API: FaceDetector.Builder.setProminentFaceOnly(boolean prominentFaceOnly) New API: This feature is covered by face contour mode. Old API: Face New API: Face Old API: Contour New API: FaceContour Old API: Landmark New API: FaceLandmark Old API: Face.getContours() New API: Face.getAllContours() Old API: Face.getEulerY() New API: Face.getHeadEulerAngleY() Old API: Face.getEulerZ() New API: Face.getHeadEulerAngleZ() Old API: Face.getId() New API: Face.getTrackingId() Old API: Face.getIsLeftEyeOpenProbability() New API: Face.getLeftEyeOpenProbability() Old API: Face.getIsRightEyeOpenProbability() New API: Face.getRightEyeOpenProbability() Old API: Face.getIsSmilingProbability() New API: Face.getSmilingProbability() Old API: Face.getLandmarks() New API: Face.getLandmark(int landmarkType) Old API: Face.getPosition() Face.getHeight() Face.getWidth() New API: Face.getBoundingBox() ``` -------------------------------- ### Initialize Barcode Detector in ML Kit (Java) Source: https://developers.google.com/ml-kit/guides/mobile-vision-migration/android This snippet demonstrates the basic initialization of the BarcodeDetector in ML Kit. It shows how to create a new instance of the detector using its Builder pattern, which is a common practice for configuring ML Kit components. ```Java barcodeDetector = new BarcodeDetector.Builder(context).build()); ``` -------------------------------- ### ML Kit Swift API Reference Overview Source: https://developers.google.com/ml-kit/guides/reference/swift/mlkitbarcodescanning/api/reference/Classes Lists the available ML Kit modules and their respective API components such as classes, constants, protocols, and type definitions, providing a high-level overview of the Swift API structure. ```APIDOC MLKitPoseDetectionAccurate: Classes: - AccuratePoseDetectorOptions - CommonPoseDetectorOptions Constants Type Definitions MLKitPoseDetectionCommon: Classes: - Overview - CommonPoseDetectorOptions - Pose - PoseDetector - PoseLandmark Constants Protocols Type Definitions MLKitSegmentationCommon: Classes: - Overview - CommonSegmenterOptions - SegmentationMask - Segmenter Constants Protocols Type Definitions MLKitSegmentationSelfie: Classes: - Overview - CommonSegmenterOptions - SelfieSegmenterOptions Constants Type Definitions MLKitSmartReply: Classes: - Overview - SmartReply - SmartReplySuggestion - SmartReplySuggestionResult - TextMessage Constants Type Definitions MLKitTextRecognition (v2): Categories: - Overview - MLKTextRecognizer(Latin) Classes: - Overview - CommonTextRecognizerOptions - TextRecognizer - TextRecognizerOptions Protocols Type Definitions MLKitTextRecognitionChinese: Classes: - Overview - ChineseTextRecognizerOptions - CommonTextRecognizerOptions MLKitTextRecognitionCommon: Classes: - Overview - CommonTextRecognizerOptions ``` -------------------------------- ### Unavailable Initializer Source: https://developers.google.com/ml-kit/guides/reference/swift/mlkitentityextraction/api/reference/Classes/ModelManager The default initializer is unavailable. Use the `modelManager()` class method to get an instance. ```Objective-C -init ``` -------------------------------- ### Create ML Kit TextRecognizer Instance Source: https://developers.google.com/ml-kit/guides/vision/text-recognition/v2/android This snippet demonstrates how to create an instance of `TextRecognizer` for various script types (Latin, Chinese, Devanagari, Japanese, Korean) using ML Kit. It shows the initialization process for both Kotlin and Java. ```Kotlin // When using Latin script library val recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS) // When using Chinese script library val recognizer = TextRecognition.getClient(ChineseTextRecognizerOptions.Builder().build()) // When using Devanagari script library val recognizer = TextRecognition.getClient(DevanagariTextRecognizerOptions.Builder().build()) // When using Japanese script library val recognizer = TextRecognition.getClient(JapaneseTextRecognizerOptions.Builder().build()) // When using Korean script library val recognizer = TextRecognition.getClient(KoreanTextRecognizerOptions.Builder().build()) ``` ```Java // When using Latin script library TextRecognizer recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS); // When using Chinese script library TextRecognizer recognizer = TextRecognition.getClient(new ChineseTextRecognizerOptions.Builder().build()); // When using Devanagari script library TextRecognizer recognizer = TextRecognition.getClient(new DevanagariTextRecognizerOptions.Builder().build()); // When using Japanese script library TextRecognizer recognizer = TextRecognition.getClient(new JapaneseTextRecognizerOptions.Builder().build()); // When using Korean script library TextRecognizer recognizer = TextRecognition.getClient(new KoreanTextRecognizerOptions.Builder().build()); ``` -------------------------------- ### Get MLKEntityExtractionRemoteModel Identifier Property Source: https://developers.google.com/ml-kit/guides/reference/ios/mlkitentityextraction/api/reference/Classes/MLKEntityExtractionRemoteModel Retrieves the unique model identifier for the `MLKEntityExtractionRemoteModel` instance. This property is read-only. ```APIDOC MLKEntityExtractionRemoteModel.modelIdentifier: Type: MLKEntityExtractionModelIdentifier Access: readonly Description: The model identifier of this model. ``` ```Objective-C @property (nonatomic, readonly) MLKEntityExtractionModelIdentifier _Nonnull modelIdentifier; ``` -------------------------------- ### Get ModelManager Instance Source: https://developers.google.com/ml-kit/guides/reference/swift/mlkitentityextraction/api/reference/Classes/ModelManager Returns a singleton instance of `ModelManager`. This is the recommended way to obtain a `ModelManager` object. ```Swift class func modelManager() -> Self Return Value: A ModelManager instance. ``` -------------------------------- ### Process ML Kit InputImage for Text Recognition Source: https://developers.google.com/ml-kit/guides/vision/text-recognition/v2/android Demonstrates how to pass the prepared `InputImage` object to an ML Kit recognizer's `process` method. It includes success and failure listeners for asynchronous task handling, specifically for text recognition. ```Kotlin val result = recognizer.process(image) .addOnSuccessListener { visionText -> // Task completed successfully // ... } .addOnFailureListener { e -> // Task failed with an exception // ... } ``` -------------------------------- ### MLKTextBlock Class API Reference Source: https://developers.google.com/ml-kit/guides/reference/swift/mlkittextrecognitioncommon/api/reference/Classes/TextBlock Detailed API documentation for the `MLKTextBlock` class, outlining its properties, their types, descriptions, and availability. ```Objective-C class TextBlock : NSObject ``` ```APIDOC MLKTextBlock Class: Description: A text block recognized in an image that consists of an array of text lines. Properties: text: Type: String (Swift: String) Description: String representation of the text block that was recognized. lines: Type: [MLKTextLine] (Swift: [MLKTextLine]) Description: An array of text lines that make up the block. frame: Type: CGRect (Swift: CGRect) Description: The rectangle that contains the text block relative to the image in the default coordinate space. recognizedLanguages: Type: [MLKTextRecognizedLanguage] (Swift: [MLKTextRecognizedLanguage]) Description: An array of recognized languages in the text block. If no languages were recognized, the array is empty. cornerPoints: Type: [NSValue] (Swift: [NSValue]) Description: The four corner points of the text block in clockwise order starting with the top left point relative to the image in the default coordinate space. The `NSValue` objects are `CGPoint`s. Methods: -init: Description: Unavailable. ``` -------------------------------- ### Get GmsBarcodeScanner Instance (ML Kit) Source: https://developers.google.com/ml-kit/guides/code-scanner This snippet illustrates how to obtain an instance of GmsBarcodeScanner, which is used to initiate barcode scanning. It shows both obtaining a default client and a client configured with custom options, providing flexibility for different scanning needs. ```Kotlin val scanner = GmsBarcodeScanning.getClient(this) // Or with a configured options // val scanner = GmsBarcodeScanning.getClient(this, options) ``` ```Java GmsBarcodeScanner scanner = GmsBarcodeScanning.getClient(this); // Or with a configured options // GmsBarcodeScanner scanner = GmsBarcodeScanning.getClient(context, options); ``` -------------------------------- ### Get EntityExtractor Instance with Options Source: https://developers.google.com/ml-kit/guides/reference/swift/mlkitentityextraction/api/reference/Classes/EntityExtractor Retrieves a thread-safe `EntityExtractor` instance configured with specific options, allowing customization of its behavior. ```Swift class func entityExtractor(options: MLKEntityExtractorOptions) -> EntityExtractor ``` ```APIDOC entityExtractor(options:) Description: Gets an `EntityExtractor` instance configured with the given options. This method is thread safe. Parameters: options: MLKEntityExtractorOptions - The options for the entity extractor. Returns: EntityExtractor - An `EntityExtractor` instance with the given options. ``` -------------------------------- ### Initialize ML Kit Object Detector Source: https://developers.google.com/ml-kit/guides/vision/object-detection/custom-models/ios This snippet demonstrates how to create an instance of the ObjectDetector using specified options, preparing it for image processing. ```Swift let objectDetector = ObjectDetector.objectDetector(options: options) ``` ```Objective-C MLKObjectDetector *objectDetector = [MLKObjectDetector objectDetectorWithOptions:options]; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.