npm install @nativescript/mlkit-core
Important
Ensure you've included xmlns:ui="@nativescript/mlkit-core" on the Page element
<ui:MLKitView cameraPosition="back" detectionType="all" detection="onDetection" />
import { MLKitModule } from '@nativescript/mlkit-core/angular';
@NgModule({
imports: [
MLKitModule
],
declarations: [
AppComponent
],
bootstrap: [AppComponent]
})
<MLKitView
cameraPosition="back"
detectionType="all"
(detection)="onDetection($event)"
></MLKitView>
import Vue from 'nativescript-vue'
import MLKit from '@nativescript/mlkit-core/vue'
Vue.use(MLKit)
<MLKitView cameraPosition="back" detectionType="all" @detection="onDetection" />
Important
Detection works only for optional modules installed
npm install @nativescript/mlkit-barcode-scanning
import { DetectionType, DetectionEvent } from '@nativescript/mlkit-core';
import { BarcodeResult } from '@nativescript/mlkit-barcode-scanning';
onDetection(event: DetectionEvent){
if(event.type === DetectionType.Barcode){
const barcode: BarcodeResult[] = event.data;
}
}
npm install @nativescript/mlkit-face-detection
import { DetectionType, DetectionEvent } from '@nativescript/mlkit-core';
import { FaceResult } from '@nativescript/mlkit-face-detection';
onDetection(event: DetectionEvent){
if(event.type === DetectionType.Face){
const faces: FaceResult[] = event.data;
}
}
npm install @nativescript/mlkit-image-labeling
import { DetectionType, DetectionEvent } from '@nativescript/mlkit-core';
import { ImageLabelingResult } from '@nativescript/mlkit-image-labeling';
onDetection(event: DetectionEvent){
if(event.type === DetectionType.Image){
const labels: ImageLabelingResult[] = event.data;
}
}
npm install @nativescript/mlkit-object-detection
import { DetectionType, DetectionEvent } from '@nativescript/mlkit-core';
import { ObjectResult } from '@nativescript/mlkit-object-detection'
onDetection(event: DetectionEvent){
if(event.type === DetectionType.Object){
const objects: ObjectResult[] = event.data;
}
}
npm install @nativescript/mlkit-pose-detection
import { DetectionType, DetectionEvent } from '@nativescript/mlkit-core';
import { PoseResult } from '@nativescript/mlkit-pose-detection';
onDetection(event: DetectionEvent){
if(event.type === DetectionType.Pose){
const poses: PoseResult = event.data;
}
}
npm install @nativescript/mlkit-text-recognition
import { DetectionType, DetectionEvent } from '@nativescript/mlkit-core';
import { TextResult } from '@nativescript/mlkit-text-recognition';
onDetection(event: DetectionEvent){
if(event.type === DetectionType.Text){
const text: TextResult = event.data;
}
}
Apache License Version 2.0