Capacitor plugin for Optical Character Recognition (OCR)
npm install @jcesarmobile/capacitor-ocrCapacitor plugin for Optical Character Recognition (OCR).
It does in device text recognition.
On iOS it uses Vision framework provided by Apple.
On Android it uses mlkit provided by Google.
It has a dependency to com.google.mlkit:text-recognition, default version is 16.0.1, but can be configured with a textRecognitionVersion variable in your variables.gradle file.
``bash`
npm install @jcesarmobile/capacitor-ocr
npx cap sync
An example app is available in example-app folder.
`typescript`
process(options: { image: string; }) => Promise
Process the text on the provided image.
Can be a file URL (returned by Camera plugin by using CameraResultType.Uri)
or a base64 data URL (returned by Camera plugin by using CameraResultType.DataUrl).
Example:
{ image: 'file:///path/to/image.jpg' }
{ image: 'data:image/png;base64,iVBORw0KG...' }
| Param | Type |
| ------------- | ------------------------------- |
| options | { image: string; } |
Returns: Promise<RecognitionResults>
--------------------
#### RecognitionResults
| Prop | Type | Description | Since |
| ------------- | -------------------------------- | ------------------------ | ----- |
| results | RecognitionResult[] | List of recognized texts | 0.0.1 |
#### RecognitionResult
| Prop | Type | Description | Since |
| ---------------- | ------------------- | -------------------------------------- | ----- |
| text | string | The recognized text. | 0.0.1 |
| confidence` | number | The confidence of the recognized text. | 0.0.1 |