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

Commit d31c10a

Browse files
AutoMLAdd support for MLKit's AutoML #1500
1 parent 07e19c9 commit d31c10a

25 files changed

+699
-24
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Left
2+
Right
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"modelFile": "model.tflite",
3+
"labelsFile": "dict.txt",
4+
"modelType": "IMAGE_LABELING"
5+
}
3.03 MB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Left
2+
Right
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"modelFile": "model.tflite",
3+
"labelsFile": "dict.txt",
4+
"modelType": "IMAGE_LABELING"
5+
}
3.03 MB
Binary file not shown.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<ActionBar class="action-bar">
2+
<Label class="action-bar-title" text="AutoML"></Label>
3+
</ActionBar>
4+
5+
<GridLayout>
6+
7+
<MLKitAutoML
8+
width="100%"
9+
height="100%"
10+
opacity="0.8"
11+
processEveryNthFrame="60"
12+
confidenceThreshold="0.4"
13+
(scanResult)="onAutoMLResult($event)">
14+
</MLKitAutoML>
15+
16+
<Label
17+
[text]="leftOrRight"
18+
style="font-size: 160; color: white"
19+
horizontalAlignment="center"
20+
verticalAlignment="center">
21+
</Label>
22+
23+
</GridLayout>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Component } from "@angular/core";
2+
import { MLKitAutoMLResult } from "nativescript-plugin-firebase/mlkit/automl";
3+
import { AbstractMLKitViewComponent } from "~/tabs/mlkit/abstract.mlkitview.component";
4+
5+
@Component({
6+
selector: "mlkit-automl",
7+
moduleId: module.id,
8+
templateUrl: "./automl.component.html",
9+
})
10+
export class AutoMLComponent extends AbstractMLKitViewComponent {
11+
leftOrRight = "";
12+
13+
onAutoMLResult(scanResult: any): void {
14+
const value: MLKitAutoMLResult = scanResult.value;
15+
16+
if (value.labels.length === 0) {
17+
this.leftOrRight = "";
18+
} else {
19+
value.labels.forEach(label => {
20+
console.log(`${label.text}: ${label.confidence}`);
21+
if (label.text === "Left" && label.confidence >= 0.51) {
22+
this.leftOrRight = label.text;
23+
} else if (label.text === "Right" && label.confidence >= 0.55) {
24+
this.leftOrRight = label.text;
25+
}
26+
});
27+
}
28+
}
29+
}

demo-ng/app/tabs/mlkit/barcodescanning/barcodescanning.component.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
width="100%"
88
height="100%"
99
formats="QR_CODE, UPC_A, EAN_13"
10-
beepOnScan="true"
10+
beepOnScan="false"
1111
supportInverseBarcodes="false"
12-
android:processEveryNthFrame="5"
13-
ios:processEveryNthFrame="10"
12+
processEveryNthFrame="10"
1413
[torchOn]="torchOn"
1514
[pause]="pause"
1615
(scanResult)="onBarcodeScanResult($event)">

demo-ng/app/tabs/mlkit/barcodescanning/barcodescanning.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ export class BarcodeScanningComponent extends AbstractMLKitViewComponent {
2222

2323
if (this.barcodes.length > 0) {
2424
console.log("this.barcodes: " + JSON.stringify(this.barcodes));
25-
console.log("pausing the scanner for 1 second (to show the 'pause' feature)");
26-
this.pause = true;
27-
setTimeout(() => this.pause = false, 1000)
25+
// this.pause = true;
26+
// setTimeout(() => this.pause = false, 500)
2827
}
2928
}
3029
}

0 commit comments

Comments
 (0)