generated from NativeScript/plugin-seed
-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmlkit-core.ts
57 lines (50 loc) · 1.53 KB
/
mlkit-core.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { Observable, EventData, Page, Dialogs } from '@nativescript/core';
import { DemoSharedMlkitCore } from '@demo/shared';
import { DetectionType, MLKitView, DetectionEvent } from '@nativescript/mlkit-core';
import { BarcodeResult } from '@nativescript/mlkit-barcode-scanning';
import { FaceResult } from '@nativescript/mlkit-face-detection';
import { ImageLabelingResult } from '@nativescript/mlkit-image-labeling';
import { ObjectResult } from '@nativescript/mlkit-object-detection';
import { PoseResult } from '@nativescript/mlkit-pose-detection';
import { TextResult } from '@nativescript/mlkit-text-recognition';
export function navigatingTo(args: EventData) {
const page = <Page>args.object;
page.bindingContext = new DemoModel();
}
export class DemoModel extends DemoSharedMlkitCore {
camera: MLKitView;
detectorType = "all";
onLoaded(args) {
this.camera = args.object;
}
onDetection(event: DetectionEvent) {
console.log('onDetection', event.data, event.type);
}
toggleCamera() {
this.camera.toggleCamera();
}
requestPermission() {
this.camera.requestCameraPermission();
}
changeType(args) {
Dialogs.action('Change Detector Type', 'Cancel', [
'all',
'barcode',
'digitalInk (unsupport atm)',
'face',
'image',
'object',
'pose',
'text',
'none'
]).then(value => {
if (value === 'Cancel') { return }
if (value.indexOf('digitalInk') > -1) {
Dialogs.alert('digitalInk is currently unsupported')
this.set('detectorType', 'none');
} else {
this.set('detectorType', value);
}
})
}
}