# what3words developer documentation: Scanning > Read what3words addresses from printed text with the camera, using the Android and iOS OCR components. Every page in this section, in menu order, as Markdown. Section page: https://developer.what3words.com/docs/scanning.md. All sections: https://developer.what3words.com/llms.txt --- # Using the Android OCR Component what3words OCR Components extract what3words addresses from images or live feeds. Topics: Android, Mobile App Section: [Scanning](https://developer.what3words.com/docs/scanning.md) Source: https://developer.what3words.com/tutorial/using-the-android-ocr-component Updated: 2026-11-27 This guide will help you integrate the what3words OCR Components into your Android application, enabling users to seamlessly scan and interpret what3words addresses from images. The **what3words OCR Components** for Android simplify the process of scanning images to detect and extract what3words addresses using [MLKit V2](https://developers.google.com/ml-kit/vision/text-recognition/v2/android). This library supports multiple sources, including user-uploaded images and live camera feeds. #### Android minimum SDK support [![Generic badge](https://img.shields.io/badge/minSdk-24-green.svg)](https://developer.android.com/about/versions/marshmallow/android-7.0/) #### Features - Detects and extracts what3words addresses from images. - Supports both live and static image scanning. - Flexible APIs to configure scanning preferences. #### GitHub Repository Access the library and detailed documentation on . [Android OCR Component](https://github.com/what3words/w3w-android-ocr-components) #### Demo ![ocr-component-demo](https://kpcwlqbjuaezxoatdmqy.supabase.co/storage/v1/object/public/devsite-media/wp/749e609ea3d9c79bd9bc7b618b79c412aa22e5154969d9150dedee3a2557d40a.gif) ## 1. Get API key You will need a what3words API key to complete this tutorial. [Get an API Key](https://accounts.what3words.com/select-plan) or [sign in](https://accounts.what3words.com/). ## 2. Installation ### Step 1: Add the Dependency Include the library in your project’s `build.gradle` file: **Gradle** ```groovy dependencies { // W3W API OCR Lib implementation 'com.what3words.android:ocr-components:' // mlkit implementation "com.google.android.gms:play-services-mlkit-text-recognition:$mlkit_core_version" implementation "com.google.android.gms:play-services-mlkit-text-recognition-chinese:$mlkit_languages_version" implementation "com.google.android.gms:play-services-mlkit-text-recognition-devanagari:$mlkit_languages_version" implementation "com.google.android.gms:play-services-mlkit-text-recognition-japanese:$mlkit_languages_version" implementation "com.google.android.gms:play-services-mlkit-text-recognition-korean:$mlkit_languages_version" } ``` Replace `` with the current version of the library, available in the [GitHub Repository](https://github.com/what3words/w3w-android-ocr-components). ### Step 2: Enable Camera Permissions Update your `AndroidManifest.xml` to request the necessary permissions: **XML** ```xml ``` ## 3. Initialisation Initialize OCR wrapper by MLKit Language **Kotlin** ```kotlin private lateinit var ocrWrapper: W3WOcrWrapper private val dataProvider: What3WordsAndroidWrapper by lazy { What3WordsV3( BuildConfig.W3W_API_KEY, this@ComposeOcrScanPopupSampleActivity ) } ``` **Kotlin** ```kotlin private fun getOcrWrapper(): W3WOcrWrapper { return W3WOcrMLKitWrapper( this, viewModel.selectedMLKitLibrary ) } ``` ## 4. Usage ### Adding a W3WOcrScanner to Your App Integrate the `W3WOcrScanner` component to enable OCR scanning in your app: **Kotlin** ```kotlin W3WOcrScanner( ocrScanManager = ocrScanManager, onDismiss = { // Handle scanner dismissal }, onSuggestionSelected = { suggestion -> // Handle address selection }, onError = { error -> // Handle the error }, ) ``` ### Creating an OcrScanManager The `OcrScanManager` handles the scanner’s state and logic, utilizing `W3WImageDataSource` and `W3WTextDataSource` for scanning and validating addresses. Note: initialize the OCR component with your API key **Kotlin** ```kotlin val w3WImageDataSource = W3WMLKitImageDataSource.create( context = context, recognizerOptions = TextRecognizerOptionsInterface.LATIN ) val w3WTextDataSource = W3WApiTextDataSource.create(context, W3W_API_KEY) val ocrScanManager = rememberOcrScanManager( w3wImageDataSource = w3WImageDataSource, w3wTextDataSource = w3WTextDataSource, ) ``` ### Setup Options You can configure the OCR scanner with either **Online** or **Offline** setups depending on your app’s requirements: 1. **Online Setup**: Use `MLKit` for scanning and `W3WApiTextDataSource` for online validation. 2. **Offline Setup**: Use `W3WTesseractImageDataSource` for offline scanning and `W3WSdkTextDataSource` for offline validation. *(Offline setup requires additional licensing; contact us for details.)* ### Using OcrScannerState for Advanced Control For more granular control, manage the scanner’s state externally with `OcrScannerState`: **Kotlin** ```kotlin val ocrScannerState = remember { OcrScannerState() } W3WOcrScanner( ocrScannerState = ocrScannerState, onError = { error -> // Handle the error }, onDismiss = { // Handle scanner dismissal }, onFrameCaptured = { image -> // Implement detection logic for what3words addresses CompletableDeferred().apply { complete(Unit) // Signal completion when processing is done } }, onSuggestionSelected = { suggestion -> // Handle address selection }, ) ``` ### Styling W3WOcrScanner Customise the appearance of `W3WOcrScanner` by overriding its default strings, colours, and text styles: **Kotlin** ```kotlin W3WOcrScanner( ... scannerStrings = W3WOcrScannerDefaults.defaultStrings( scanStateFoundTitle = stringResource(id = R.string.scan_state_found), ), scannerColors = W3WOcrScannerDefaults.defaultColors( bottomDrawerBackground = W3WTheme.colors.background ), scannerTextStyles = W3WOcrScannerDefaults.defaultTextStyles( stateTextStyle = W3WTheme.typography.headline ), suggestionColors = SuggestionWhat3wordsDefaults.defaultColors( background = W3WTheme.colors.background ), suggestionTextStyles = SuggestionWhat3wordsDefaults.defaultTextStyles( wordsTextStyle = W3WTheme.typography.headline ) ) ``` ### Camera Permission Ensure your app requests camera permissions by adding the following to your `AndroidManifest.xml`: **XML** ```xml ``` ## 5. Migration to v2.0 Upgrading to v2.0 introduces streamlined APIs and integration with the Core Library. ### Breaking Changes - **Core Library Models:** v1.x models replaced with Core Library equivalents; manual migration required. - **W3WOcrMLKitWrapper** **Removed**: Replaced by OcrScanManager for simplified API. - **MLKitOcrScanActivity** **Deprecated**: No longer supported; use Jetpack Compose for activity integration. ### New Features - **OcrScanManager:** Encapsulates scanning logic and state for easier implementation. - **Flexible Data Sources:** Support for online (MLKit + W3WApiTextDataSource) and offline setups. - **Improved Modularity:** Enhanced customisation and integration options for Jetpack Compose. ### Migration Steps 1. Replace the old library version with the latest: **Gradle** ```groovy implementation 'com.what3words:w3w-android-ocr-components:$latest' ``` **Step 2: Replace Deprecated Models** Manually update v1.x models with Core Library equivalents. Refer to the Core Library documentation for details. **Step 3: Use OcrScanManager** Replace W3WOcrMLKitWrapper with the new OcrScanManager for simplified state and logic management: **Kotlin** ```kotlin val ocrScanManager = rememberOcrScanManager( w3wImageDataSource = W3WMLKitImageDataSource.create(context, TextRecognizerOptionsInterface.LATIN), w3wTextDataSource = W3WApiTextDataSource.create(context, W3W_API_KEY), ) W3WOcrScanner(ocrScanManager = ocrScanManager, ...) ``` **Step 4: Remove MLKitOcrScanActivity** MLKitOcrScanActivity has been deprecated. Use Jetpack Compose for standalone scanning activities. ## 6. Sample App The OCR component repository includes a [sample app](https://github.com/what3words/w3w-android-samples/tree/main/ocr-sample) demonstrating the usage of the what3words OCR component. --- # Using the iOS OCR Component what3words OCR Components extract what3words addresses from images or live feeds. Topics: Swift, Mobile App Section: [Scanning](https://developer.what3words.com/docs/scanning.md) Source: https://developer.what3words.com/tutorial/using-the-ios-ocr-component Updated: 2026-11-27 This guide will help you integrate the what3words OCR Components into your iOS application, enabling users to seamlessly scan and interpret what3words addresses from images, using iOS’ Vision Framework or the what3words OCR SDK. #### Features - Detects and extracts what3words addresses from images. - Supports both live and static image scanning. - Flexible APIs to configure scanning preferences. #### GitHub Repository Access the library and detailed documentation on . [iOS OCR Component](https://github.com/what3words/w3w-swift-components-ocr/) #### Demo ![ocr-component-demo](https://kpcwlqbjuaezxoatdmqy.supabase.co/storage/v1/object/public/devsite-media/wp/749e609ea3d9c79bd9bc7b618b79c412aa22e5154969d9150dedee3a2557d40a.gif) ## 1. Get API key You will need a what3words API key to complete this tutorial. [Get an API Key](https://accounts.what3words.com/select-plan) or [sign in](https://accounts.what3words.com/). ## 2. Installation **Swift Package Manager** 1. Add the W3W OCR Swift Components to your project in Xcode, and navigate to **File > Add Packages**. 2. Enter the package URL: [https://github.com/what3words/w3w-swift-components-ocr.git](https://github.com/what3words/w3w-swift-components-ocr.git) 3. Select the latest version and integrate it into your project. Import the library in your Swift files: **Swift** ```swift import W3WSwiftComponentsOcr ``` ## 3. Initialisation ### Using iOS’ Vision Framework To use the Vision Framework for OCR, initialize the `W3WOcrNative` class with the what3words API: **Swift** ```swift let api = What3WordsV4(apiKey: "YourApiKey") let ocr = W3WOcrNative(api) let ocrViewController = W3WOcrViewController(ocr: ocr) ``` ### Using the what3words OCR SDK For offline functionality, use the what3words OCR SDK by specifying the path to OCR data files and an optional language code: **Swift** ```swift let ocr = W3WOcr(dataPath: "/path/to/ocr/datafiles", language: "en") let ocrViewController = W3WOcrViewController(ocr: ocr) ``` ## 4. Usage ### Displaying the OCR Scanner Use the following example to present the OCR scanner in a `UIViewController`: **Swift** ```swift @IBAction func scanButtonPressed(_ sender: Any) { let ocrViewController = W3WOcrViewController(ocr: ocr, w3w: api) // Present the scanner present(ocrViewController, animated: true) // Start scanning ocrViewController.start() // Handle address selection ocrViewController.onSuggestionSelected = { suggestion in print(suggestion) ocrViewController.stop() ocrViewController.dismiss(animated: true) } // Handle errors ocrViewController.onError = { error in print(error) } } ``` ### Customisation You can customise the appearance of the OCR scanner by applying themes through the `W3WThemes` framework: **Swift** ```swift import W3WThemes let theme = W3WTheme.forOcr( backgroundColor: UIColor.white.w3wColor, cameraBackgroundColor: UIColor.darkGray.w3wColor, headerTextColor: UIColor.red.w3wColor, fonts: W3WFonts(font: UIFont(name: "Courier", size: 24.0)) ) let ocrViewController = W3WOcrViewController(ocr: ocr, theme: theme, w3w: api) ``` #### Customisable Properties: - **Colours**: `backgroundColor`, `headerTextColor`, etc. - **Fonts**: Customisable with `W3WFonts`. - **Line Styles**: Modify `defaultLineColor`, `successLineColor`, and thickness options. ### Camera Permission Ensure camera permissions are added to your app’s `Info.plist`: **XML** ```xml NSCameraUsageDescription We need access to your camera to scan what3words addresses. ``` ## 5. Sample App The OCR component repository includes a [sample app](https://github.com/what3words/w3w-swift-samples) demonstrating the usage of the what3words OCR component.