Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 6d82eda

Browse files
Please help me create sample ML-Kit for javascript #962
1 parent ba6c96b commit 6d82eda

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

docs/ML_KIT.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ To be able to use Cloud features you need to do two things:
9393

9494
#### Still image (on-device)
9595

96+
##### TypeScript
97+
9698
```typescript
9799
import { MLKitRecognizeTextResult } from "nativescript-plugin-firebase/mlkit/textrecognition";
98100
const firebase = require("nativescript-plugin-firebase");
@@ -104,8 +106,22 @@ firebase.mlkit.textrecognition.recognizeTextOnDevice({
104106
}).catch(errorMessage => console.log("ML Kit error: " + errorMessage));
105107
```
106108
109+
##### JavaScript
110+
111+
```js
112+
var firebase = require("nativescript-plugin-firebase");
113+
114+
firebase.mlkit.textrecognition.recognizeTextOnDevice({
115+
image: imageSource // a NativeScript Image or ImageSource, see the demo for examples
116+
}).then(function(result) {
117+
console.log(result.text ? result.text : "");
118+
}).catch(function (errorMessage) { return console.log("ML Kit error: " + errorMessage); });
119+
```
120+
107121
#### Still image (cloud)
108122
123+
##### TypeScript
124+
109125
```typescript
110126
import { MLKitRecognizeTextResult } from "nativescript-plugin-firebase/mlkit/textrecognition";
111127
const firebase = require("nativescript-plugin-firebase");
@@ -117,6 +133,18 @@ firebase.mlkit.textrecognition.recognizeTextCloud({
117133
.catch(errorMessage => console.log("ML Kit error: " + errorMessage));
118134
```
119135
136+
##### JavaScript
137+
138+
```js
139+
var firebase = require("nativescript-plugin-firebase");
140+
141+
firebase.mlkit.textrecognition.recognizeTextCloud({
142+
image: imageSource // a NativeScript Image or ImageSource, see the demo for examples
143+
}).then(function(result) {
144+
console.log(result.text ? result.text : "");
145+
}).catch(function (errorMessage) { return console.log("ML Kit error: " + errorMessage); });
146+
```
147+
120148
#### Live camera feed
121149
The exact details of using the live camera view depend on whether or not you're using Angular / Vue.
122150
@@ -176,7 +204,7 @@ Declare a namespace at the top of the embedding page, and use it anywhere on the
176204
</Page>
177205
```
178206
179-
> Note that with NativeScript 4 the `Page` tag may actually be a `TabView`, but adding the namespace declaration to the TabView works just as well.
207+
> Note that since NativeScript 4 the `Page` tag may actually be a `TabView`, but adding the namespace declaration to the TabView works just as well.
180208
181209
### Face detection
182210
<img src="https://raw.githubusercontent.com/EddyVerbruggen/nativescript-plugin-firebase/master/docs/images/features/mlkit_face_detection.png" height="153px" alt="ML Kit - Face detection"/>

0 commit comments

Comments
 (0)