Appery Text Recognition Plugin
Text Recognition Cordova Plugin
TextRecognizer.recognizeText
Parameters
- {string} filePath - path to image
- {function} success - callback function which takes a parameter data which will be invoked on success
- {function} error - callback function which takes a parameter err which will be invoked on failure
Supported Options
property | value | description |
---|---|---|
useBase64 | false (default) / true | Whether or not filePath is a base64 encoded string. |
Example:
window.ApperyioMLCordovaPlugin.TextRecognizer.recognizeText('filePath', successCallback, errorCallback)
Realtime text recognition from camera
TextRecognizer.startRealTimeRecognition
Parameters
- {function} success - callback function which takes a parameter data which will be invoked on success
- {function} error - callback function which takes a parameter err which will be invoked on failure
- {object} options - options for face detector
Supported Options
property | value | description |
---|---|---|
showDetectedText | true (default) / false | Whether or not show detected text on video overlay |
frameImageData | true (default) / false | Whether include base64 of captured text photo or not |
frameImageResultType | CameraResultType.BASE64_STRING (default) / CameraResultType.DATA_URL | include captured photo as only base64 string or as full data url |
delay | 500 (default) | Time interval in msec, for performing recognition each interval value |
encodingType | EncodingType.JPEG (default) / EncodingType.PNG | format of output image |
cameraDirection | CameraDirection.BACK (default) / CameraDirection.FRONT | Use back or front camera of device during text recognition |
detectedTextImageData | true (default) / false | return or not cropped text image data in base64 format depends on frameImageResultType option value for every detected text block; if true, each item of response "textBlocks" array contains "textBlockImage" field with the data |
Example:
window.ApperyioMLCordovaPlugin.TextRecognizer.startRealTimeRecognition(successCallback, errorCallback, {
showDetectedText: true,
frameImageData: true,
frameImageResultType: 0, // BASE64_STRING: 0 (default), DATA_URL: 1
encodingType: 1, // JPEG : 0 (default) Return JPEG encoded image, PNG : 1 Return PNG encoded image
cameraDirection: 1, // BACK : 0 (default) Use the back-facing camera, FRONT : 1 Use the front-facing camera
delay: 100,
detectedTextImageData: true
})
Sample JSON callback:
{
"text": "Firebase Docs Guides\nRecognize Text in Images with ML Kit on Android\nYou can use ML Kit to recognize text in images. ML Kit\nhas both a general-purpose APl suitable for recognizing\ntext in images, such as the text of a street sign, and an\nAPl optimized for recognizing the text of documents. The\ngeneral-purpose APl has both on-device and cloud-based\nmodels. Document text recognition is available only as a\ncloud-based model. See the overview for a comparison of\nthe cloud and on-device models.\nRecognize Textin Images with ML K.\nCess\nFirecasts\nFor Firebase Developers\nSee the ML Kit quickstart sample on GitHub for an\nexample of this APl in use, or try the codelab .\nBefore you begin\n1. If you haven't already, add Firebase to your Android project.\n2. In your project-level build.gradle file, make sure to include Google's Maven repository in both your\nbuildscript and allprojects sections.\n3. Add the dependencies for the ML Kit Android libraries to your module (app-level) Gradle file (usually\napp\/build.gradle):",
"textBlocks": [
{
"text": "Firebase Docs Guides",
"boundingBox": {
"left": 36,
"right": 209,
"top": 41,
"bottom": 56
},
"cornerPoints": [
{
"pointX": 36,
"pointY": 41
},
{
"pointX": 209,
"pointY": 41
},
{
"pointX": 209,
"pointY": 56
},
{
"pointX": 36,
"pointY": 56
}
],
"lines": [
{
"text": "Firebase Docs Guides",
"boundingBox": {
"left": 36,
"right": 209,
"top": 41,
"bottom": 56
},
"cornerPoints": [
{
"pointX": 36,
"pointY": 41
},
{
"pointX": 209,
"pointY": 41
},
{
"pointX": 209,
"pointY": 56
},
{
"pointX": 36,
"pointY": 56
}
]
}
]
}
]
}
TextRecognizer.stopRealTimeRecognition
Parameters
- {function} success - callback function which takes a parameter data which will be invoked on success
- {function} error - callback function which takes a parameter err which will be invoked on failure
Example:
window.ApperyioMLCordovaPlugin.TextRecognizer.stopRealTimeRecognition(successCallback, errorCallback)
Invocation example using toPromise helper method
let result = await this.$a.toPromise(window.ApperyioMLCordovaPlugin?.TextRecognizer?.recognizeText, {
beginParameters: ['IMAGE BASE64'],
endParameters: [{
useBase64: true
}]
})
YouTube Video: Text Recognition Plugin
You can also check this Appery.io YouTube video that shows how to create an app with the Text Recognition feature:
Updated 4 months ago