diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1 @@
+node_modules
diff --git a/.eslintrc b/.eslintrc
deleted file mode 100644
index 3856c8c..0000000
--- a/.eslintrc
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "root": true,
- "parser": "@typescript-eslint/parser",
- "parserOptions": {
- "ecmaVersion": 2018,
- "sourceType": "module",
- "project": "./tsconfig.base.json"
- },
- "ignorePatterns": ["**/*"],
- "plugins": ["@typescript-eslint", "@nrwl/nx"],
- "extends": [
- "eslint:recommended",
- "plugin:@typescript-eslint/eslint-recommended",
- "plugin:@typescript-eslint/recommended",
- "prettier",
- "prettier/@typescript-eslint"
- ],
- "rules": {
- "@typescript-eslint/explicit-member-accessibility": "off",
- "@typescript-eslint/explicit-function-return-type": "off",
- "@typescript-eslint/no-parameter-properties": "off",
- "@nrwl/nx/enforce-module-boundaries": [
- "error",
- {
- "enforceBuildableLibDependency": true,
- "allow": [],
- "depConstraints": [
- { "sourceTag": "*", "onlyDependOnLibsWithTags": ["*"] }
- ]
- }
- ]
- },
- "overrides": [
- {
- "files": ["*.tsx"],
- "rules": {
- "@typescript-eslint/no-unused-vars": "off"
- }
- }
- ]
-}
diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 0000000..f6532b7
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,47 @@
+{
+ "root": true,
+ "ignorePatterns": ["**/*"],
+ "plugins": ["@nx"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {
+ "@nx/enforce-module-boundaries": [
+ "error",
+ {
+ "enforceBuildableLibDependency": true,
+ "allow": [],
+ "depConstraints": [
+ {
+ "sourceTag": "*",
+ "onlyDependOnLibsWithTags": ["*"]
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier", "plugin:@nx/typescript"],
+ "rules": {
+ "@typescript-eslint/no-extra-semi": "error",
+ "no-extra-semi": "off"
+ }
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "extends": ["plugin:@nx/javascript"],
+ "rules": {
+ "@typescript-eslint/no-extra-semi": "error",
+ "no-extra-semi": "off"
+ }
+ },
+ {
+ "files": ["references.d.ts"],
+ "rules": {
+ "@typescript-eslint/triple-slash-reference": "off"
+ }
+ }
+ ]
+}
diff --git a/.gitignore b/.gitignore
index ea0c923..8b7e40c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,3 +42,6 @@ Thumbs.db
*.tgz
packages/**/angular/dist
+
+.nx/cache
+.nx/workspace-data
diff --git a/.husky/pre-commit b/.husky/pre-commit
old mode 100644
new mode 100755
diff --git a/.nxignore b/.nxignore
new file mode 100644
index 0000000..80a8f0e
--- /dev/null
+++ b/.nxignore
@@ -0,0 +1 @@
+apps/**/*_off
\ No newline at end of file
diff --git a/.prettierignore b/.prettierignore
index 413ca14..342760a 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -3,3 +3,6 @@
/dist
/coverage
native-src
+
+/.nx/cache
+/.nx/workspace-data
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..cc58686
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,17 @@
+{
+ "NativescriptExtend.fileAssociations": [
+ {
+ "systemId": "c:\\Users\\sweet\\Documents\\PacktCourses_books\\NATIVESCRIPT\\contributions\\mlkit\\schema\\tns.xsd",
+ "pattern": "**/**/*.xml"
+ },
+ {
+ "systemId": "http://www.w3.org/2001/XMLSchema.xsd",
+ "pattern": "c:\\Users\\sweet\\Documents\\PacktCourses_books\\NATIVESCRIPT\\contributions\\mlkit\\schema\\tns.xsd"
+ }
+ ],
+ "files.exclude": {
+ "schema": true
+ },
+ "NativescriptExtend.format.enabled": true,
+ "NativescriptExtend.validation.enabled": true
+}
diff --git a/README.md b/README.md
index 8e77002..002102a 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,21 @@
- [@nativescript/mlkit-barcode-scanning](packages/mlkit-barcode-scanning/README.md)
- [@nativescript/mlkit-core](packages/mlkit-core/README.md)
+- [@nativescript/mlkit-custom-object-detection](packages/mlkit-custom-object-detection/README.md)
- [@nativescript/mlkit-digital-ink-recognition](packages/mlkit-digital-ink-recognition/README.md)
- [@nativescript/mlkit-face-detection](packages/mlkit-face-detection/README.md)
- [@nativescript/mlkit-image-labeling](packages/mlkit-image-labeling/README.md)
- [@nativescript/mlkit-object-detection](packages/mlkit-object-detection/README.md)
- [@nativescript/mlkit-pose-detection](packages/mlkit-pose-detection/README.md)
+- [@nativescript/mlkit-selfie-segmentation](packages/mlkit-selfie-segmentation/README.md)
- [@nativescript/mlkit-text-recognition](packages/mlkit-text-recognition/README.md)
+# How to run it with IOS simulator?
+
+Since Xcode 26 also older IOS emulators (till 17.5) crash when MLKit libs are included in the binary. You can now
+therefore control inclusion of the libs via a command line switch.
+
+NSSkipMLKitFromIOSSimulator=1 ns prepare ios
+
# How to use?
This workspace manages the suite of plugins listed above.
diff --git a/apps/demo-angular/.eslintrc.json b/apps/demo-angular/.eslintrc.json
new file mode 100644
index 0000000..53c06c8
--- /dev/null
+++ b/apps/demo-angular/.eslintrc.json
@@ -0,0 +1,18 @@
+{
+ "extends": ["../../.eslintrc.json"],
+ "ignorePatterns": ["!**/*", "node_modules/**/*"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "rules": {}
+ }
+ ]
+}
diff --git a/apps/demo-angular/package.json b/apps/demo-angular/package.json
index c47c5da..e75453a 100644
--- a/apps/demo-angular/package.json
+++ b/apps/demo-angular/package.json
@@ -9,10 +9,12 @@
"@nativescript/mlkit-image-labeling": "file:../../dist/packages/mlkit-image-labeling",
"@nativescript/mlkit-object-detection": "file:../../dist/packages/mlkit-object-detection",
"@nativescript/mlkit-digital-ink-recognition": "file:../../dist/packages/mlkit-digital-ink-recognition",
- "@nativescript/mlkit-pose-detection": "file:../../dist/packages/mlkit-pose-detection"
+ "@nativescript/mlkit-pose-detection": "file:../../dist/packages/mlkit-pose-detection",
+ "@nativescript/mlkit-selfie-segmentation": "file:../../dist/packages/mlkit-selfie-segmentation",
+ "@nativescript/mlkit-custom-object-detection": "file:../../dist/packages/mlkit-custom-object-detection"
},
"devDependencies": {
- "@nativescript/android": "~8.1.1",
- "@nativescript/ios": "~8.1.0"
+ "@nativescript/android": "~8.9.0",
+ "@nativescript/ios": "~8.9.0"
}
}
diff --git a/apps/demo-angular/project.json b/apps/demo-angular/project.json
new file mode 100644
index 0000000..27b0323
--- /dev/null
+++ b/apps/demo-angular/project.json
@@ -0,0 +1,43 @@
+{
+ "name": "demo-angular",
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
+ "sourceRoot": "apps/demo-angular/src",
+ "projectType": "application",
+ "prefix": "demo",
+ "targets": {
+ "build": {
+ "executor": "@nativescript/nx:build",
+ "options": {
+ "noHmr": true,
+ "production": true,
+ "uglify": true,
+ "release": true,
+ "forDevice": true,
+ "tsConfig": "apps/demo-angular/tsconfig.json"
+ },
+ "dependsOn": [
+ {
+ "target": "build.all",
+ "dependencies": true
+ }
+ ]
+ },
+ "clean": {
+ "executor": "@nativescript/nx:clean",
+ "options": {}
+ },
+ "lint": {
+ "executor": "@nx/eslint:lint"
+ },
+ "debug": {
+ "executor": "@nativescript/nx:debug",
+ "options": {
+ "noHmr": true,
+ "uglify": false,
+ "release": false,
+ "forDevice": false,
+ "prepare": false
+ }
+ }
+ }
+}
diff --git a/apps/demo-angular/src/app-routing.module.ts b/apps/demo-angular/src/app-routing.module.ts
index 012c8b4..805d6ed 100644
--- a/apps/demo-angular/src/app-routing.module.ts
+++ b/apps/demo-angular/src/app-routing.module.ts
@@ -5,20 +5,22 @@ import { NativeScriptRouterModule } from '@nativescript/angular';
import { HomeComponent } from './home.component';
const routes: Routes = [
- { path: '', redirectTo: '/home', pathMatch: 'full' },
- { path: 'home', component: HomeComponent },
- { path: 'mlkit-barcode-scanning', loadChildren: () => import('./plugin-demos/mlkit-barcode-scanning.module').then(m => m.MlkitBarcodeScanningModule) },
- { path: 'mlkit-core', loadChildren: () => import('./plugin-demos/mlkit-core.module').then(m => m.MlkitCoreModule) },
- { path: 'mlkit-digital-ink-recognition', loadChildren: () => import('./plugin-demos/mlkit-digital-ink-recognition.module').then(m => m.MlkitDigitalInkRecognitionModule) },
- { path: 'mlkit-face-detection', loadChildren: () => import('./plugin-demos/mlkit-face-detection.module').then(m => m.MlkitFaceDetectionModule) },
- { path: 'mlkit-image-labeling', loadChildren: () => import('./plugin-demos/mlkit-image-labeling.module').then(m => m.MlkitImageLabelingModule) },
- { path: 'mlkit-object-detection', loadChildren: () => import('./plugin-demos/mlkit-object-detection.module').then(m => m.MlkitObjectDetectionModule) },
- { path: 'mlkit-pose-detection', loadChildren: () => import('./plugin-demos/mlkit-pose-detection.module').then(m => m.MlkitPoseDetectionModule) },
- { path: 'mlkit-text-recognition', loadChildren: () => import('./plugin-demos/mlkit-text-recognition.module').then(m => m.MlkitTextRecognitionModule) }
+ { path: '', redirectTo: '/home', pathMatch: 'full' },
+ { path: 'home', component: HomeComponent },
+ { path: 'mlkit-barcode-scanning', loadChildren: () => import('./plugin-demos/mlkit-barcode-scanning.module').then((m) => m.MlkitBarcodeScanningModule) },
+ { path: 'mlkit-core', loadChildren: () => import('./plugin-demos/mlkit-core.module').then((m) => m.MlkitCoreModule) },
+ { path: 'mlkit-custom-object-detection', loadChildren: () => import('./plugin-demos/mlkit-custom-object-detection.module').then((m) => m.MlkitCustomObjectDetectionModule) },
+ { path: 'mlkit-digital-ink-recognition', loadChildren: () => import('./plugin-demos/mlkit-digital-ink-recognition.module').then((m) => m.MlkitDigitalInkRecognitionModule) },
+ { path: 'mlkit-face-detection', loadChildren: () => import('./plugin-demos/mlkit-face-detection.module').then((m) => m.MlkitFaceDetectionModule) },
+ { path: 'mlkit-image-labeling', loadChildren: () => import('./plugin-demos/mlkit-image-labeling.module').then((m) => m.MlkitImageLabelingModule) },
+ { path: 'mlkit-object-detection', loadChildren: () => import('./plugin-demos/mlkit-object-detection.module').then((m) => m.MlkitObjectDetectionModule) },
+ { path: 'mlkit-pose-detection', loadChildren: () => import('./plugin-demos/mlkit-pose-detection.module').then((m) => m.MlkitPoseDetectionModule) },
+ { path: 'mlkit-selfie-segmentation', loadChildren: () => import('./plugin-demos/mlkit-selfie-segmentation.module').then((m) => m.MlkitSelfieSegmentationModule) },
+ { path: 'mlkit-text-recognition', loadChildren: () => import('./plugin-demos/mlkit-text-recognition.module').then((m) => m.MlkitTextRecognitionModule) },
];
@NgModule({
- imports: [NativeScriptRouterModule.forRoot(routes)],
- exports: [NativeScriptRouterModule],
+ imports: [NativeScriptRouterModule.forRoot(routes)],
+ exports: [NativeScriptRouterModule],
})
export class AppRoutingModule {}
diff --git a/apps/demo-angular/src/app.module.ts b/apps/demo-angular/src/app.module.ts
index c869e4d..0c96880 100644
--- a/apps/demo-angular/src/app.module.ts
+++ b/apps/demo-angular/src/app.module.ts
@@ -4,11 +4,12 @@ import { NativeScriptModule } from '@nativescript/angular';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { HomeComponent } from './home.component';
+import { MLKitModule } from '@nativescript/mlkit-core/angular';
@NgModule({
schemas: [NO_ERRORS_SCHEMA],
declarations: [AppComponent, HomeComponent],
bootstrap: [AppComponent],
- imports: [NativeScriptModule, AppRoutingModule],
+ imports: [NativeScriptModule, AppRoutingModule, MLKitModule],
})
export class AppModule {}
diff --git a/apps/demo-angular/src/app.scss b/apps/demo-angular/src/app.scss
index effb718..567ca58 100644
--- a/apps/demo-angular/src/app.scss
+++ b/apps/demo-angular/src/app.scss
@@ -1,22 +1,28 @@
@import 'nativescript-theme-core/scss/light';
@import 'nativescript-theme-core/scss/index';
-button, label, stack-layout {
- horizontal-align: center;
+button,
+label,
+stack-layout {
+ horizontal-align: center;
}
button {
- font-size: 36;
+ font-size: 16;
}
.title {
- font-size: 30;
- margin: 20;
+ font-size: 30;
+ margin: 20;
}
.message {
- font-size: 20;
- color: #284848;
- text-align: center;
- margin: 0 20;
-}
+ font-size: 20;
+ color: #284848;
+ text-align: center;
+ margin: 0 20;
+}
+
+.rounded {
+ border-radius: 20;
+}
diff --git a/apps/demo-angular/src/home.component.html b/apps/demo-angular/src/home.component.html
index b6ad279..4984906 100644
--- a/apps/demo-angular/src/home.component.html
+++ b/apps/demo-angular/src/home.component.html
@@ -2,10 +2,10 @@
-
+
-
+
diff --git a/apps/demo-angular/src/home.component.ts b/apps/demo-angular/src/home.component.ts
index 3107a08..fa930da 100644
--- a/apps/demo-angular/src/home.component.ts
+++ b/apps/demo-angular/src/home.component.ts
@@ -1,34 +1,41 @@
import { Component } from '@angular/core';
+import { RouterExtensions } from '@nativescript/angular';
@Component({
- selector: 'demo-home',
- templateUrl: 'home.component.html',
+ selector: 'demo-home',
+ templateUrl: 'home.component.html',
})
export class HomeComponent {
- demos = [
- {
- name: 'mlkit-barcode-scanning'
- },
- {
- name: 'mlkit-core'
- },
- {
- name: 'mlkit-digital-ink-recognition'
- },
- {
- name: 'mlkit-face-detection'
- },
- {
- name: 'mlkit-image-labeling'
- },
- {
- name: 'mlkit-object-detection'
- },
- {
- name: 'mlkit-pose-detection'
- },
- {
- name: 'mlkit-text-recognition'
- }
-];
-}
\ No newline at end of file
+ demos = [
+ {
+ name: 'mlkit-barcode-scanning',
+ },
+ {
+ name: 'mlkit-core',
+ },
+ {
+ name: 'mlkit-custom-object-detection',
+ },
+ {
+ name: 'mlkit-digital-ink-recognition',
+ },
+ {
+ name: 'mlkit-face-detection',
+ },
+ {
+ name: 'mlkit-image-labeling',
+ },
+ {
+ name: 'mlkit-object-detection',
+ },
+ {
+ name: 'mlkit-pose-detection',
+ },
+ {
+ name: 'mlkit-selfie-segmentation',
+ },
+ {
+ name: 'mlkit-text-recognition',
+ },
+ ];
+}
diff --git a/apps/demo-angular/src/plugin-demos/mlkit-barcode-scanning.component.ts b/apps/demo-angular/src/plugin-demos/mlkit-barcode-scanning.component.ts
index 3d7e352..a52a1aa 100644
--- a/apps/demo-angular/src/plugin-demos/mlkit-barcode-scanning.component.ts
+++ b/apps/demo-angular/src/plugin-demos/mlkit-barcode-scanning.component.ts
@@ -1,6 +1,5 @@
import { Component, NgZone } from '@angular/core';
import { DemoSharedMlkitBarcodeScanning } from '@demo/shared';
-import { } from '@nativescript/mlkit-barcode-scanning';
@Component({
selector: 'demo-mlkit-barcode-scanning',
diff --git a/apps/demo-angular/src/plugin-demos/mlkit-core.component.html b/apps/demo-angular/src/plugin-demos/mlkit-core.component.html
index a0143fc..fb8867a 100644
--- a/apps/demo-angular/src/plugin-demos/mlkit-core.component.html
+++ b/apps/demo-angular/src/plugin-demos/mlkit-core.component.html
@@ -1,8 +1,15 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/demo-angular/src/plugin-demos/mlkit-core.component.ts b/apps/demo-angular/src/plugin-demos/mlkit-core.component.ts
index 9dd6f9a..552752f 100644
--- a/apps/demo-angular/src/plugin-demos/mlkit-core.component.ts
+++ b/apps/demo-angular/src/plugin-demos/mlkit-core.component.ts
@@ -1,19 +1,83 @@
import { Component, NgZone } from '@angular/core';
import { DemoSharedMlkitCore } from '@demo/shared';
-import { } from '@nativescript/mlkit-core';
+import { Dialogs, ImageSource } from '@nativescript/core';
+import { DetectionEvent, DetectionType, detectWithStillImage, MLKitView } from '@nativescript/mlkit-core';
@Component({
- selector: 'demo-mlkit-core',
- templateUrl: 'mlkit-core.component.html',
+ selector: 'demo-mlkit-core',
+ templateUrl: 'mlkit-core.component.html',
})
export class MlkitCoreComponent {
-
+
+ camera: MLKitView;
+ detectorType = DetectionType.All;
+ isPaused = true;
+ torchOn = true;
demoShared: DemoSharedMlkitCore;
-
- constructor(private _ngZone: NgZone) {}
+
+ constructor(private _ngZone: NgZone) { }
ngOnInit() {
this.demoShared = new DemoSharedMlkitCore();
}
+ onLoaded(args) {
+ this.camera = args.object;
+ }
+
+ onDetection(event: DetectionEvent) {
+ console.log('onDetection', event.data, event.type);
+ }
+
+ toggleCamera(args) {
+ this.camera.toggleCamera();
+ }
+
+ requestPermission(args) {
+ 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.detectorType = DetectionType.None;
+ } else {
+ this.detectorType = value as any;
+ }
+ })
+ }
+
+ togglePause(args) {
+ this.camera.pause = !this.camera.pause;
+ this.isPaused = this.camera.pause;
+ }
+
+ toggleTorch(args) {
+ this.camera.torchOn = !this.camera.torchOn;
+ this.torchOn = this.camera.torchOn;
+ }
+
+ async processStill(args) {
+ try {
+ const src = await ImageSource.fromUrl('https://www.jqueryscript.net/images/jQuery-Plugin-To-Generate-International-Article-Number-Barcode-EAN13.jpg');
+ const result = await detectWithStillImage(src, {
+ detectorType: DetectionType.Barcode
+ });
+ console.log('processStill', result.barcode[0]);
+ } catch (e) {
+ console.log(e);
+ }
+ }
}
\ No newline at end of file
diff --git a/apps/demo-angular/src/plugin-demos/mlkit-custom-object-detection.component.html b/apps/demo-angular/src/plugin-demos/mlkit-custom-object-detection.component.html
new file mode 100644
index 0000000..28a1691
--- /dev/null
+++ b/apps/demo-angular/src/plugin-demos/mlkit-custom-object-detection.component.html
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/apps/demo-angular/src/plugin-demos/mlkit-custom-object-detection.component.ts b/apps/demo-angular/src/plugin-demos/mlkit-custom-object-detection.component.ts
new file mode 100644
index 0000000..b1c21b1
--- /dev/null
+++ b/apps/demo-angular/src/plugin-demos/mlkit-custom-object-detection.component.ts
@@ -0,0 +1,17 @@
+import { Component, NgZone } from '@angular/core';
+import { DemoSharedMlkitCustomObjectDetection } from '@demo/shared';
+import {} from '@nativescript/mlkit-custom-object-detection';
+
+@Component({
+ selector: 'demo-mlkit-custom-object-detection',
+ templateUrl: 'mlkit-custom-object-detection.component.html',
+})
+export class MlkitCustomObjectDetectionComponent {
+ demoShared: DemoSharedMlkitCustomObjectDetection;
+
+ constructor(private _ngZone: NgZone) {}
+
+ ngOnInit() {
+ this.demoShared = new DemoSharedMlkitCustomObjectDetection();
+ }
+}
diff --git a/apps/demo-angular/src/plugin-demos/mlkit-custom-object-detection.module.ts b/apps/demo-angular/src/plugin-demos/mlkit-custom-object-detection.module.ts
new file mode 100644
index 0000000..955dddf
--- /dev/null
+++ b/apps/demo-angular/src/plugin-demos/mlkit-custom-object-detection.module.ts
@@ -0,0 +1,10 @@
+import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
+import { NativeScriptCommonModule, NativeScriptRouterModule } from '@nativescript/angular';
+import { MlkitCustomObjectDetectionComponent } from './mlkit-custom-object-detection.component';
+
+@NgModule({
+ imports: [NativeScriptCommonModule, NativeScriptRouterModule.forChild([{ path: '', component: MlkitCustomObjectDetectionComponent }])],
+ declarations: [MlkitCustomObjectDetectionComponent],
+ schemas: [NO_ERRORS_SCHEMA],
+})
+export class MlkitCustomObjectDetectionModule {}
diff --git a/apps/demo-angular/src/plugin-demos/mlkit-digital-ink-recognition.component.ts b/apps/demo-angular/src/plugin-demos/mlkit-digital-ink-recognition.component.ts
index c065655..b909a9f 100644
--- a/apps/demo-angular/src/plugin-demos/mlkit-digital-ink-recognition.component.ts
+++ b/apps/demo-angular/src/plugin-demos/mlkit-digital-ink-recognition.component.ts
@@ -1,6 +1,5 @@
import { Component, NgZone } from '@angular/core';
import { DemoSharedMlkitDigitalInkRecognition } from '@demo/shared';
-import { } from '@nativescript/mlkit-digital-ink-recognition';
@Component({
selector: 'demo-mlkit-digital-ink-recognition',
diff --git a/apps/demo-angular/src/plugin-demos/mlkit-face-detection.component.ts b/apps/demo-angular/src/plugin-demos/mlkit-face-detection.component.ts
index 4ff6154..142b48a 100644
--- a/apps/demo-angular/src/plugin-demos/mlkit-face-detection.component.ts
+++ b/apps/demo-angular/src/plugin-demos/mlkit-face-detection.component.ts
@@ -1,6 +1,5 @@
import { Component, NgZone } from '@angular/core';
import { DemoSharedMlkitFaceDetection } from '@demo/shared';
-import { } from '@nativescript/mlkit-face-detection';
@Component({
selector: 'demo-mlkit-face-detection',
diff --git a/apps/demo-angular/src/plugin-demos/mlkit-image-labeling.component.ts b/apps/demo-angular/src/plugin-demos/mlkit-image-labeling.component.ts
index a6bc368..c7104da 100644
--- a/apps/demo-angular/src/plugin-demos/mlkit-image-labeling.component.ts
+++ b/apps/demo-angular/src/plugin-demos/mlkit-image-labeling.component.ts
@@ -1,6 +1,5 @@
import { Component, NgZone } from '@angular/core';
import { DemoSharedMlkitImageLabeling } from '@demo/shared';
-import { } from '@nativescript/mlkit-image-labeling';
@Component({
selector: 'demo-mlkit-image-labeling',
diff --git a/apps/demo-angular/src/plugin-demos/mlkit-object-detection.component.ts b/apps/demo-angular/src/plugin-demos/mlkit-object-detection.component.ts
index 49199df..155af82 100644
--- a/apps/demo-angular/src/plugin-demos/mlkit-object-detection.component.ts
+++ b/apps/demo-angular/src/plugin-demos/mlkit-object-detection.component.ts
@@ -1,6 +1,5 @@
import { Component, NgZone } from '@angular/core';
import { DemoSharedMlkitObjectDetection } from '@demo/shared';
-import { } from '@nativescript/mlkit-object-detection';
@Component({
selector: 'demo-mlkit-object-detection',
diff --git a/apps/demo-angular/src/plugin-demos/mlkit-pose-detection.component.ts b/apps/demo-angular/src/plugin-demos/mlkit-pose-detection.component.ts
index aaeef32..f81c0b3 100644
--- a/apps/demo-angular/src/plugin-demos/mlkit-pose-detection.component.ts
+++ b/apps/demo-angular/src/plugin-demos/mlkit-pose-detection.component.ts
@@ -1,6 +1,5 @@
import { Component, NgZone } from '@angular/core';
import { DemoSharedMlkitPoseDetection } from '@demo/shared';
-import { } from '@nativescript/mlkit-pose-detection';
@Component({
selector: 'demo-mlkit-pose-detection',
diff --git a/apps/demo-angular/src/plugin-demos/mlkit-selfie-segmentation.component.html b/apps/demo-angular/src/plugin-demos/mlkit-selfie-segmentation.component.html
new file mode 100644
index 0000000..41a41ae
--- /dev/null
+++ b/apps/demo-angular/src/plugin-demos/mlkit-selfie-segmentation.component.html
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/apps/demo-angular/src/plugin-demos/mlkit-selfie-segmentation.component.ts b/apps/demo-angular/src/plugin-demos/mlkit-selfie-segmentation.component.ts
new file mode 100644
index 0000000..9587a51
--- /dev/null
+++ b/apps/demo-angular/src/plugin-demos/mlkit-selfie-segmentation.component.ts
@@ -0,0 +1,18 @@
+import { Component, NgZone } from '@angular/core';
+import { DemoSharedMlkitSelfieSegmentation } from '@demo/shared';
+
+@Component({
+ selector: 'demo-mlkit-selfie-segmentation',
+ templateUrl: 'mlkit-selfie-segmentation.component.html',
+})
+export class MlkitSelfieSegmentationComponent {
+
+ demoShared: DemoSharedMlkitSelfieSegmentation;
+
+ constructor(private _ngZone: NgZone) {}
+
+ ngOnInit() {
+ this.demoShared = new DemoSharedMlkitSelfieSegmentation();
+ }
+
+}
\ No newline at end of file
diff --git a/apps/demo-angular/src/plugin-demos/mlkit-selfie-segmentation.module.ts b/apps/demo-angular/src/plugin-demos/mlkit-selfie-segmentation.module.ts
new file mode 100644
index 0000000..dbcc65e
--- /dev/null
+++ b/apps/demo-angular/src/plugin-demos/mlkit-selfie-segmentation.module.ts
@@ -0,0 +1,10 @@
+import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
+import { NativeScriptCommonModule, NativeScriptRouterModule } from '@nativescript/angular';
+import { MlkitSelfieSegmentationComponent } from './mlkit-selfie-segmentation.component';
+
+@NgModule({
+ imports: [NativeScriptCommonModule, NativeScriptRouterModule.forChild([{ path: '', component: MlkitSelfieSegmentationComponent }])],
+ declarations: [MlkitSelfieSegmentationComponent],
+ schemas: [ NO_ERRORS_SCHEMA]
+})
+export class MlkitSelfieSegmentationModule {}
diff --git a/apps/demo-angular/src/plugin-demos/mlkit-text-recognition.component.ts b/apps/demo-angular/src/plugin-demos/mlkit-text-recognition.component.ts
index e432847..d8b7453 100644
--- a/apps/demo-angular/src/plugin-demos/mlkit-text-recognition.component.ts
+++ b/apps/demo-angular/src/plugin-demos/mlkit-text-recognition.component.ts
@@ -1,6 +1,5 @@
import { Component, NgZone } from '@angular/core';
import { DemoSharedMlkitTextRecognition } from '@demo/shared';
-import { } from '@nativescript/mlkit-text-recognition';
@Component({
selector: 'demo-mlkit-text-recognition',
diff --git a/apps/demo-angular/tsconfig.json b/apps/demo-angular/tsconfig.json
index e3e8d80..b6e2648 100644
--- a/apps/demo-angular/tsconfig.json
+++ b/apps/demo-angular/tsconfig.json
@@ -1,26 +1,23 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
- "rootDirs": [
- ".",
- "../.."
- ],
- "baseUrl": ".",
"paths": {
- "~/*": [
- "src/*"
- ],
- "@nativescript/*": [
- "../../dist/packages/*"
- ],
- "@demo/shared": [
- "../../tools/demo/index.ts"
- ]
+ "~/*": ["src/*"],
+ "@demo/shared": ["tools/demo/index.ts"],
+ "@nativescript/mlkit-text-recognition": ["packages/mlkit-text-recognition/index.ts"],
+ "@nativescript/mlkit-core": ["packages/mlkit-core/index.d.ts"],
+ "@nativescript/mlkit-core/angular": ["packages/mlkit-core/angular/index.ts"],
+ "@nativescript/mlkit-custom-object-detection": ["../../packages/mlkit-custom-object-detection/index.d.ts"],
+ "@nativescript/mlkit-barcode-scanning": ["packages/mlkit-barcode-scanning/index.ts"],
+ "@nativescript/mlkit-face-detection": ["packages/mlkit-face-detection/index.ts"],
+ "@nativescript/mlkit-image-labeling": ["packages/mlkit-image-labeling/index.ts"],
+ "@nativescript/mlkit-object-detection": ["packages/mlkit-object-detection/index.ts"],
+ "@nativescript/mlkit-digital-ink-recognition": ["packages/mlkit-digital-ink-recognition/index.ts"],
+ "@nativescript/mlkit-pose-detection": ["packages/mlkit-pose-detection/index.ts"],
+ "@nativescript/mlkit-selfie-segmentation": ["packages/mlkit-selfie-segmentation/index.ts"],
+ "@nativescript/*": ["../../dist/packages/*"]
}
},
- "files": [
- "./references.d.ts",
- "./src/main.ts",
- "./src/polyfills.ts"
- ]
-}
\ No newline at end of file
+ "files": ["./references.d.ts", "./src/main.ts", "./src/polyfills.ts"],
+ "include": ["../../packages/**/references.d.ts"]
+}
diff --git a/apps/demo/.eslintrc.json b/apps/demo/.eslintrc.json
new file mode 100644
index 0000000..53c06c8
--- /dev/null
+++ b/apps/demo/.eslintrc.json
@@ -0,0 +1,18 @@
+{
+ "extends": ["../../.eslintrc.json"],
+ "ignorePatterns": ["!**/*", "node_modules/**/*"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "rules": {}
+ }
+ ]
+}
diff --git a/apps/demo/package.json b/apps/demo/package.json
index fb7666d..1f5b1f1 100644
--- a/apps/demo/package.json
+++ b/apps/demo/package.json
@@ -12,10 +12,12 @@
"@nativescript/mlkit-image-labeling": "file:../../packages/mlkit-image-labeling",
"@nativescript/mlkit-object-detection": "file:../../packages/mlkit-object-detection",
"@nativescript/mlkit-pose-detection": "file:../../packages/mlkit-pose-detection",
- "@nativescript/mlkit-text-recognition": "file:../../packages/mlkit-text-recognition"
+ "@nativescript/mlkit-selfie-segmentation": "file:../../packages/mlkit-selfie-segmentation",
+ "@nativescript/mlkit-text-recognition": "file:../../packages/mlkit-text-recognition",
+ "@nativescript/mlkit-custom-object-detection": "file:../../packages/mlkit-custom-object-detection"
},
"devDependencies": {
- "@nativescript/android": "~8.1.1",
- "@nativescript/ios": "~8.1.0"
+ "@nativescript/android": "~8.9.0",
+ "@nativescript/ios": "~8.9.0"
}
}
diff --git a/apps/demo/project.json b/apps/demo/project.json
new file mode 100644
index 0000000..e7043ac
--- /dev/null
+++ b/apps/demo/project.json
@@ -0,0 +1,43 @@
+{
+ "name": "demo",
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
+ "sourceRoot": "apps/demo/src",
+ "projectType": "application",
+ "prefix": "demo",
+ "targets": {
+ "build": {
+ "executor": "@nativescript/nx:build",
+ "options": {
+ "noHmr": true,
+ "production": true,
+ "uglify": true,
+ "release": true,
+ "forDevice": true,
+ "tsConfig": "apps/demo/tsconfig.json"
+ },
+ "dependsOn": [
+ {
+ "target": "build.all",
+ "dependencies": true
+ }
+ ]
+ },
+ "clean": {
+ "executor": "@nativescript/nx:clean",
+ "options": {}
+ },
+ "lint": {
+ "executor": "@nx/eslint:lint"
+ },
+ "debug": {
+ "executor": "@nativescript/nx:debug",
+ "options": {
+ "noHmr": true,
+ "uglify": false,
+ "release": false,
+ "forDevice": false,
+ "prepare": false
+ }
+ }
+ }
+}
diff --git a/apps/demo/references.d.ts b/apps/demo/references.d.ts
index 22bac92..5ed0bb2 100644
--- a/apps/demo/references.d.ts
+++ b/apps/demo/references.d.ts
@@ -1 +1,2 @@
///
+///
diff --git a/apps/demo/src/app.scss b/apps/demo/src/app.scss
index d0ac013..9951432 100644
--- a/apps/demo/src/app.scss
+++ b/apps/demo/src/app.scss
@@ -1,2 +1,5 @@
@import 'nativescript-theme-core/scss/light';
-@import 'nativescript-theme-core/scss/index';
\ No newline at end of file
+@import 'nativescript-theme-core/scss/index';
+.rounded {
+ border-radius: 20;
+}
diff --git a/apps/demo/src/main-page.xml b/apps/demo/src/main-page.xml
index 38021d5..797d99d 100644
--- a/apps/demo/src/main-page.xml
+++ b/apps/demo/src/main-page.xml
@@ -14,6 +14,8 @@
+
+
diff --git a/apps/demo/src/plugin-demos/mlkit-core.ts b/apps/demo/src/plugin-demos/mlkit-core.ts
index 9e20c43..a9c3899 100644
--- a/apps/demo/src/plugin-demos/mlkit-core.ts
+++ b/apps/demo/src/plugin-demos/mlkit-core.ts
@@ -1,57 +1,142 @@
-import { Observable, EventData, Page, Dialogs } from '@nativescript/core';
+import { Observable, EventData, Page, Dialogs, ImageSource, Frame, Image } from '@nativescript/core';
import { DemoSharedMlkitCore } from '@demo/shared';
-import { DetectionType, MLKitView, DetectionEvent } from '@nativescript/mlkit-core';
+import { DetectionType, MLKitView, DetectionEvent, detectWithStillImage } 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';
+import { BoundingBoxSettings, TNSObjectDetectionResult } from '@nativescript/mlkit-core/common';
+
export function navigatingTo(args: EventData) {
- const page = args.object;
- page.bindingContext = new DemoModel();
+ const 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);
- }
- })
- }
-}
+ camera: MLKitView;
+ detectorType = DetectionType.Barcode;
+ isPaused = false;
+ torchOn = false;
+ _bbox: { x: number; y: number; width: number; height: number };
+ bboxSettings: BoundingBoxSettings = {
+ drawBBoxes: true,
+ drawEdgeMarks: true,
+ drawLabels: true,
+ bBoxLineColor: '#FF0000FF',
+ bBoxLineWidth: 1,
+ bBoxCornerness: 7,
+ edgeMarkLengthFactor: 0.2,
+ edgeMarkLineWidth: 5,
+ showConfidence: true,
+ labelTextColor: '#FFFFFFFF',
+ labelBackgroundColor: '#00000090',
+ labelCornerness: 5,
+ labelAlignment: 'center',
+ labelMappings: { laptop: 'Laptop' },
+ };
+
+ onLoaded(args) {
+ this.camera = args.object;
+ this.set('isPaused', this.camera.pause);
+ this.set('torchOn', this.camera.torchOn);
+ }
+
+ onDetection(event: DetectionEvent) {
+ console.log('onDetection', event.data, event.type);
+ if (event.type === DetectionType.Barcode) {
+ const first = event.data[0] as BarcodeResult;
+ console.log('bounds', first.bounds);
+ }
+ if (event.type === DetectionType.CustomObject) {
+ const first = event.data[0] as TNSObjectDetectionResult;
+ if (first?.bounds) {
+ this._bbox = first.bounds;
+ }
+ }
+ }
+
+ public drawBBox(args: EventData) {
+ const page = Frame.topmost()?.currentPage;
+ const imgView = page.getViewById('imageView') as Image;
+ const mlkitview = page.getViewById('mlKitView') as MLKitView;
+ imgView.visibility = 'visible';
+ if (this._bbox && mlkitview.latestImage) {
+ imgView.src = this.extractRectFromImageBuffer(mlkitview.latestImage, this._bbox);
+ }
+ }
+
+ private extractRectFromImageBuffer(imageSource: ImageSource, rect: { x: number; y: number; width: number; height: number }): ImageSource | null {
+ if (global.isIOS) {
+ const uiImage = imageSource.ios; // Get the UIImage
+ const buffer = uiImage.CIImage?.extent || uiImage.CGImage;
+ if (!buffer) {
+ console.error("UIImage doesn't have a valid buffer representation");
+ return null;
+ }
+ const context = CIContext.context();
+ const scale = uiImage.scale || 1;
+ // CGImage origin is not at top right but bottom left, we therefore have to adopt y axis and bbox ref. point
+ const y_inCGImageCoords = buffer.size.height - rect.y - rect.height;
+ const scaledRect = CGRectMake(rect.x * scale, y_inCGImageCoords * scale, rect.width * scale, rect.height * scale);
+ const croppedCGImage = context.createCGImageFromRect(uiImage.CIImage, scaledRect);
+
+ if (!croppedCGImage) {
+ console.error('Failed to crop CGImage from buffer');
+ return null;
+ }
+ const croppedUIImage = UIImage.alloc().initWithCGImageScaleOrientation(croppedCGImage, scale, uiImage.imageOrientation);
+ const croppedImageSource = new ImageSource();
+ croppedImageSource.setNativeSource(croppedUIImage);
+ return croppedImageSource;
+ }
+ }
+ toggleCamera() {
+ this.camera.toggleCamera();
+ }
+
+ toggleTorch() {
+ this.camera.torchOn = !this.camera.torchOn;
+ this.set('torchOn', this.camera.torchOn);
+ }
+
+ requestPermission() {
+ this.camera.requestCameraPermission();
+ }
+
+ changeType(args) {
+ (Frame.topmost()?.currentPage.getViewById('imageView') as Image).visibility = 'hidden';
+ Dialogs.action('Change Detector Type', 'Cancel', ['all', 'barcode', 'digitalInk (unsupport atm)', 'face', 'image', 'object', 'customObject', '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);
+ }
+ });
+ }
+
+ togglePause(args) {
+ (Frame.topmost()?.currentPage.getViewById('imageView') as Image).visibility = 'hidden';
+ this.camera.pause = !this.camera.pause;
+ this.set('isPaused', this.camera.pause);
+ }
+
+ async processStill(args) {
+ try {
+ const src = await ImageSource.fromUrl('https://www.jqueryscript.net/images/jQuery-Plugin-To-Generate-International-Article-Number-Barcode-EAN13.jpg');
+
+ const result = await detectWithStillImage(src, {
+ detectorType: DetectionType.Barcode,
+ });
+ console.log('processStill', result.barcode[0]);
+ } catch (e) {
+ console.log(e);
+ }
+ }
+}
diff --git a/apps/demo/src/plugin-demos/mlkit-core.xml b/apps/demo/src/plugin-demos/mlkit-core.xml
index bd63e52..4a7c82b 100644
--- a/apps/demo/src/plugin-demos/mlkit-core.xml
+++ b/apps/demo/src/plugin-demos/mlkit-core.xml
@@ -1,13 +1,34 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/demo/src/plugin-demos/mlkit-custom-object-detection.ts b/apps/demo/src/plugin-demos/mlkit-custom-object-detection.ts
new file mode 100644
index 0000000..c8ca0ef
--- /dev/null
+++ b/apps/demo/src/plugin-demos/mlkit-custom-object-detection.ts
@@ -0,0 +1,10 @@
+import { Observable, EventData, Page } from '@nativescript/core';
+import { DemoSharedMlkitCustomObjectDetection } from '@demo/shared';
+import {} from '@nativescript/mlkit-custom-object-detection';
+
+export function navigatingTo(args: EventData) {
+ const page = args.object;
+ page.bindingContext = new DemoModel();
+}
+
+export class DemoModel extends DemoSharedMlkitCustomObjectDetection {}
diff --git a/apps/demo/src/plugin-demos/mlkit-custom-object-detection.xml b/apps/demo/src/plugin-demos/mlkit-custom-object-detection.xml
new file mode 100644
index 0000000..0c9e74e
--- /dev/null
+++ b/apps/demo/src/plugin-demos/mlkit-custom-object-detection.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apps/demo/src/plugin-demos/mlkit-selfie-segmentation.ts b/apps/demo/src/plugin-demos/mlkit-selfie-segmentation.ts
new file mode 100644
index 0000000..0356cf7
--- /dev/null
+++ b/apps/demo/src/plugin-demos/mlkit-selfie-segmentation.ts
@@ -0,0 +1,12 @@
+import { Observable, EventData, Page } from '@nativescript/core';
+import { DemoSharedMlkitSelfieSegmentation } from '@demo/shared';
+import { } from '@nativescript/mlkit-selfie-segmentation';
+
+export function navigatingTo(args: EventData) {
+ const page = args.object;
+ page.bindingContext = new DemoModel();
+}
+
+export class DemoModel extends DemoSharedMlkitSelfieSegmentation {
+
+}
diff --git a/apps/demo/src/plugin-demos/mlkit-selfie-segmentation.xml b/apps/demo/src/plugin-demos/mlkit-selfie-segmentation.xml
new file mode 100644
index 0000000..1cfb6ff
--- /dev/null
+++ b/apps/demo/src/plugin-demos/mlkit-selfie-segmentation.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apps/demo/tsconfig.json b/apps/demo/tsconfig.json
index d7667fb..52d6045 100644
--- a/apps/demo/tsconfig.json
+++ b/apps/demo/tsconfig.json
@@ -1,21 +1,23 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
- "rootDirs": [
- ".",
- "../.."
- ],
+ "rootDirs": [".", "../.."],
"baseUrl": ".",
"paths": {
- "~/*": [
- "src/*"
- ],
- "@nativescript/*": [
- "../../packages/*"
- ],
- "@demo/shared": [
- "../../tools/demo/index.ts"
- ]
+ "~/*": ["src/*"],
+ "@demo/shared": ["../../tools/demo/index.ts"],
+ "@nativescript/mlkit-text-recognition": ["../../packages/mlkit-text-recognition/index.ts"],
+ "@nativescript/mlkit-core": ["../../packages/mlkit-core/index.d.ts"],
+ "@nativescript/mlkit-core/angular": ["../../packages/mlkit-core/angular/index.ts"],
+ "@nativescript/mlkit-custom-object-detection": ["../../packages/mlkit-custom-object-detection/index.d.ts"],
+ "@nativescript/mlkit-barcode-scanning": ["../../packages/mlkit-barcode-scanning/index.ts"],
+ "@nativescript/mlkit-face-detection": ["../../packages/mlkit-face-detection/index.ts"],
+ "@nativescript/mlkit-image-labeling": ["../../packages/mlkit-image-labeling/index.ts"],
+ "@nativescript/mlkit-object-detection": ["../../packages/mlkit-object-detection/index.ts"],
+ "@nativescript/mlkit-digital-ink-recognition": ["../../packages/mlkit-digital-ink-recognition/index.ts"],
+ "@nativescript/mlkit-pose-detection": ["../../packages/mlkit-pose-detection/index.ts"],
+ "@nativescript/mlkit-selfie-segmentation": ["../../packages/mlkit-selfie-segmentation/index.ts"],
+ "@nativescript/*": ["../../packages/*"]
}
}
-}
\ No newline at end of file
+}
diff --git a/apps/demo/webpack.config.js b/apps/demo/webpack.config.js
index 05d00ce..b996540 100644
--- a/apps/demo/webpack.config.js
+++ b/apps/demo/webpack.config.js
@@ -12,11 +12,11 @@ module.exports = (env) => {
});
// Example if you need to share images across demo apps:
- // webpack.Utils.addCopyRule({
- // from: '../../../tools/images',
- // to: 'images',
- // context: webpack.Utils.project.getProjectFilePath('node_modules')
- // });
+ webpack.Utils.addCopyRule({
+ from: '../../../tools/images',
+ to: 'images',
+ context: webpack.Utils.project.getProjectFilePath('node_modules')
+ });
return webpack.resolveConfig();
};
diff --git a/jest.config.js b/jest.config.js
deleted file mode 100644
index 7d4f7bc..0000000
--- a/jest.config.js
+++ /dev/null
@@ -1,3 +0,0 @@
-const { getJestProjects } = require('@nrwl/jest');
-
-module.exports = { projects: [...getJestProjects()] };
\ No newline at end of file
diff --git a/jest.config.ts b/jest.config.ts
new file mode 100644
index 0000000..5f64584
--- /dev/null
+++ b/jest.config.ts
@@ -0,0 +1,3 @@
+const { getJestProjects } = require('@nx/jest');
+
+export default { projects: [...getJestProjects()] };
diff --git a/nx.json b/nx.json
index 1d041ac..fd4b82d 100644
--- a/nx.json
+++ b/nx.json
@@ -1,55 +1,58 @@
{
- "npmScope": "nativescript",
- "affected": {
- "defaultBase": "master"
+ "workspaceLayout": {
+ "appsDir": "apps",
+ "libsDir": "packages"
},
- "implicitDependencies": {
- "workspace.json": "*",
- "package.json": {
- "dependencies": "*",
- "devDependencies": "*"
- },
- "tsconfig.base.json": "*",
- "tslint.json": "*",
- "nx.json": "*"
+ "tasksRunnerOptions": {
+ "default": {
+ "options": {
+ "runtimeCacheInputs": ["node -v"]
+ }
+ }
},
- "projects": {
- "demo": {
- "tags": []
- },
- "demo-angular": {
- "tags": []
- },
- "all": {
- "tags": []
- },
- "mlkit-text-recognition": {
- "tags": []
- },
- "mlkit-core": {
- "tags": []
- },
- "mlkit-barcode-scanning": {
- "tags": []
- },
- "mlkit-face-detection": {
- "tags": []
+ "$schema": "./node_modules/nx/schemas/nx-schema.json",
+ "namedInputs": {
+ "default": ["{projectRoot}/**/*", "sharedGlobals"],
+ "sharedGlobals": ["{workspaceRoot}/workspace.json", "{workspaceRoot}/tsconfig.base.json", "{workspaceRoot}/tslint.json", "{workspaceRoot}/nx.json"],
+ "production": ["default", "!{projectRoot}/.eslintrc.json", "!{projectRoot}/src/test-setup.[jt]s"]
+ },
+ "targetDefaults": {
+ "build": {
+ "inputs": ["production", "^production"],
+ "cache": true
},
- "mlkit-image-labeling": {
- "tags": []
+ "lint": {
+ "inputs": ["default", "{workspaceRoot}/.eslintrc.json"],
+ "cache": true
},
- "mlkit-object-detection": {
- "tags": []
+ "build.all": {
+ "cache": true
},
- "mlkit-digital-ink-recognition": {
- "tags": []
+ "test": {
+ "cache": true
},
- "mlkit-pose-detection": {
- "tags": []
+ "e2e": {
+ "cache": true
}
},
- "workspaceLayout": {
- "appsDir": "apps",
- "libsDir": "packages"
- }
+ "useDaemonProcess": false,
+ "parallel": 1,
+ "useInferencePlugins": false,
+ "defaultBase": "master",
+ "release": {
+ "releaseTagPattern": "{version}-{projectName}",
+ "projects": ["packages/*"],
+ "projectsRelationship": "independent",
+ "changelog": {
+ "workspaceChangelog": false,
+ "projectChangelogs": {
+ "renderOptions": {
+ "authors": true,
+ "commitReferences": true,
+ "versionTitleDate": true
+ }
+ }
+ }
+ },
+ "useLegacyCache": true
}
diff --git a/package.json b/package.json
index 679f3df..12236f5 100644
--- a/package.json
+++ b/package.json
@@ -3,8 +3,8 @@
"version": "0.0.0",
"license": "MIT",
"scripts": {
- "postinstall": "husky install && npx ts-patch install",
- "setup": "npx rimraf node_modules package-lock.json dist tmp yarn.lock && yarn config set ignore-engines true && ns package-manager set npm && yarn",
+ "postinstall": "husky && npx ts-patch install",
+ "setup": "npx rimraf node_modules package-lock.json dist tmp yarn.lock && npm install",
"start": "nps",
"add": "nx g @nativescript/plugin-tools:add-package",
"add-angular": "nx g @nativescript/plugin-tools:add-angular",
@@ -16,28 +16,29 @@
},
"private": true,
"devDependencies": {
- "@angular/animations": "^12.0.0",
- "@angular/common": "^12.0.0",
- "@angular/compiler": "^12.0.0",
- "@angular/compiler-cli": "^12.0.0",
- "@angular/core": "^12.0.0",
- "@angular/forms": "^12.0.0",
- "@angular/platform-browser": "^12.0.0",
- "@angular/platform-browser-dynamic": "^12.0.0",
- "@angular/router": "^12.0.0",
- "@nativescript/angular": "^12.0.0",
- "@nativescript/core": "^8.0.0",
- "@nativescript/plugin-tools": "2.3.0",
- "@nativescript/types": "^8.0.0",
- "@nativescript/webpack": "~5.0.0",
- "@ngtools/webpack": "^12.0.0",
- "husky": "^5.1.3",
+ "@angular/animations": "^19.0.0",
+ "@angular/common": "^19.0.0",
+ "@angular/compiler": "^19.0.0",
+ "@angular/compiler-cli": "^19.0.0",
+ "@angular/core": "^19.0.0",
+ "@angular/forms": "^19.0.0",
+ "@angular/platform-browser": "^19.0.0",
+ "@angular/platform-browser-dynamic": "^19.0.0",
+ "@angular/router": "^19.0.0",
+ "@nativescript/angular": "^19.0.0",
+ "@nativescript/core": "~8.9.0",
+ "@nativescript/plugin-tools": "5.5.3",
+ "@nativescript/types": "~8.9.0",
+ "@nativescript/webpack": "~5.0.5",
+ "@ngtools/webpack": "^19.0.0",
+ "husky": "~9.0.0",
"nativescript-vue": "~2.9.0",
"nativescript-vue-template-compiler": "~2.9.0",
- "ng-packagr": "^12.0.0",
- "rxjs": "~6.6.0",
- "typescript": "~4.3.5",
- "zone.js": "~0.11.1"
+ "ng-packagr": "^19.0.0",
+ "rxjs": "~7.8.0",
+ "typescript": "~5.6.0",
+ "zone.js": "~0.15.0",
+ "@angular-devkit/build-angular": "^19.0.0"
},
"lint-staged": {
"**/*.{js,ts,scss,json,html}": [
diff --git a/packages/mlkit-barcode-scanning/.eslintrc.json b/packages/mlkit-barcode-scanning/.eslintrc.json
new file mode 100644
index 0000000..53c06c8
--- /dev/null
+++ b/packages/mlkit-barcode-scanning/.eslintrc.json
@@ -0,0 +1,18 @@
+{
+ "extends": ["../../.eslintrc.json"],
+ "ignorePatterns": ["!**/*", "node_modules/**/*"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "rules": {}
+ }
+ ]
+}
diff --git a/packages/mlkit-barcode-scanning/CHANGELOG.md b/packages/mlkit-barcode-scanning/CHANGELOG.md
new file mode 100644
index 0000000..279d75e
--- /dev/null
+++ b/packages/mlkit-barcode-scanning/CHANGELOG.md
@@ -0,0 +1,45 @@
+## 3.0.4 (2025-10-23)
+
+### 🩹 Fixes
+
+- switch to remove mlkit libs from simulator builds ([#84](https://github.com/NativeScript/mlkit/pull/84))
+
+### ❤️ Thank You
+
+- cjohn001 @cjohn001
+
+## 3.0.1 (2025-07-22)
+
+### 🚀 Features
+
+- SDK updates for Android and IOS ([#83](https://github.com/NativeScript/mlkit/pull/83))
+
+### 🩹 Fixes
+
+- correct plugin link ([#75](https://github.com/NativeScript/mlkit/pull/75))
+
+### ❤️ Thank You
+
+- cjohn001 @cjohn001
+- Nandesora Tjihero @Ombuweb
+
+# 3.0.0 (2025-01-29)
+
+### 🚀 Features
+
+- iOS SDK 5+ and Android SDK updates ([#63](https://github.com/NativeScript/mlkit/pull/63))
+- **core:** allow aspectRatio configuration ([10fea40](https://github.com/NativeScript/mlkit/commit/10fea40))
+- allow retrieval of last processed image ([f98e08d](https://github.com/NativeScript/mlkit/commit/f98e08d))
+- still image detection, pause & torch ([c7ee498](https://github.com/NativeScript/mlkit/commit/c7ee498))
+
+### 🩹 Fixes
+
+- unify camera permission handling, detection background handling, detection sig, support processEveryNthFrame, onTorch handling ([98c2ebc](https://github.com/NativeScript/mlkit/commit/98c2ebc))
+- detection, torch & pause ([31d601d](https://github.com/NativeScript/mlkit/commit/31d601d))
+- android barcode detection, formats, ios detection & torch ([353ede1](https://github.com/NativeScript/mlkit/commit/353ede1))
+- detection event ([16642aa](https://github.com/NativeScript/mlkit/commit/16642aa))
+
+### ❤️ Thank You
+
+- Nathan Walker
+- Osei Fortune @triniwiz
\ No newline at end of file
diff --git a/packages/mlkit-barcode-scanning/README.md b/packages/mlkit-barcode-scanning/README.md
index c0e3c0a..858ed9e 100644
--- a/packages/mlkit-barcode-scanning/README.md
+++ b/packages/mlkit-barcode-scanning/README.md
@@ -1,12 +1,263 @@
# @nativescript/mlkit-barcode-scanning
-```javascript
-ns plugin add @nativescript/mlkit-barcode-scanning
+This plugin is used with [@nativescript/mlkit-core](../plugins/mlkit-core/). It enables barcode scanning and provides the [BarcodeResult](#barcoderesult) type for the barcode-scanned data.
+
+## Contents
+
+* [Installation](#installation)
+* [Use @nativescript/mlkit-barcode-scanning](#use-nativescriptmlkit-barcode-scanning)
+ * [Demo app](#demo-app)
+* [API](#api)
+ * [BarcodeResult](#barcoderesult)
+
+
+## Installation
+
+```shell
+npm install @nativescript/mlkit-barcode-scanning
```
-## Usage
+## Use @nativescript/mlkit-barcode-scanning
+
+Follow these steps to scan a barcode:
+
+1. Add [MLKitView](../mlkit-core/) to your page and set the `detectionType` property to `"barcode"`.
+
+```xml
+
+
+
+
+```
+2. To receive the scanned barcode data, handle the `detection` event and get the data if the event's type is `"barcode"`.
+
+```ts
+import { Observable } from "@nativescript/core"
+import { DetectionEvent, DetectionType } from "@nativescript/mlkit-core";
+import { BarcodeResult } from "@nativescript/mlkit-barcode-scanning";
+
+export class BarcodeScannerViewModel extends Observable {
+ barcode = ""
+...
+ onDetection(event: DetectionEvent){
+
+ if(event.type == DetectionType.Barcode){
+ const barcodeData: BarcodeResult = event.data[0] as BarcodeResult;
+ this.set("barcode", barcodeData?.rawValue)
+ }
+}
+}
+
+```
+#### Demo app
+You can try a demo app at [StackBlitz](https://stackblitz.com/edit/nativescript-stackblitz-templates-svbcbz?file=app/main-page.xml) with the [NativeScript Preview app](https://preview.nativescript.org/).
+
+## API
+
+### Interfaces
+
+#### BarcodeResult
+
+The scanned barcode data object has the following properties:
+
+| Property | Type | Optional
+|:---------|:-----|:------------------
+| `format` | [BarcodeFormats](#barcodeformats) | _No_
+| `calendarEvent` | [CalenderEvent](#calenderevent) | _Yes_
+| `contactInfo` | [ContactInfo](#contactinfo) | _Yes_
+| `bounds` | [Bounds](#bounds) | _Yes_
+| `points` | [Point](#point)[] | _Yes_
+| `displayValue` | `string` | _Yes_
+| `driverLicense`| [DriverLicense](#driverlicense) | _Yes_
+| `email` | [Email](#email) | _Yes_
+| `geoPoint` | [GeoPoint](#geopoint) | _Yes_
+| `phone`| [Phone](#phone) | _Yes_
+| `rawBytes`| `any[]` | _Yes_
+| `rawValue` | `string` | _Yes_
+| `sms`| [Sms](#sms) | _Yes_
+| `url`| [UrlBookmark](#urlbookmark) | _Yes_
+| `valueType`| [ValueType]() | _Yes_
+| `wifi`| [WiFi](#wifi) | _Yes_
+
+#### WiFi
+
+| Property | Type | Optional
+|:---------|:-----|:-------
+| `encryptionType` | `string` | _No_
+| `password`| `string` | _No_
+| `ssid`| `string` | _No_
+
+#### UrlBookmark
+| Property | Type | Optional
+|:---------|:-----|:-------
+| `title` | `string` | _Yes_
+| `url`| `string` | _Yes_
+
+#### Sms
+| Property | Type | Optional
+|:---------|:-----|:-------
+| `message` | `string` | _No_
+| `honeNumber`| `string` | _No_
+
+#### Phone
+| Property | Type | Optional
+|:---------|:-----|:-------
+| `number` | `string` | _No_
+| `type`| [PhoneType](#phonetype) | _No_
+
+#### Email
+| Property | Type | Optional
+|:---------|:-----|:-------
+| `address` | `string` | _No_
+| `subject` | `string` | _No_
+| `body` | `string` | _No_
+| `type` | [EmailType](#emailtype)
+
+#### DriverLicense
+| Property | Type | Optional
+|:---------|:-----|:-------
+| `documentType`| `string` | _No_
+| `firstName`| `string` | _No_
+| `middleName`| `string` | _No_
+| `lastName`| `string` | _No_
+| `gender`| `string` | _No_
+| `addressStreet`| `string` | _No_
+| `addressCity`| `string` | _No_
+| `addressState`| `string` | _No_
+| `addressZip`| `string` | _No_
+| `licenseNumber`| `string` | _No_
+| `issueDate`| `string` | _No_
+| `expiryDate`| `string` | _No_
+| `birthDate`| `string` | _No_
+| `issuingCountry`| `string` | _No_
+
+#### CalenderEvent
+
+| Property | Type | Optional
+|:---------|:-----|:-------
+| `description`| `string` | _Yes_
+| `location`| `string` | _Yes_
+| `organizer`| `string` | _Yes_
+| `status`| `string` | _Yes_
+| `summary`| `string` | _Yes_
+| `start`| `string` | _Yes_
+| `end`| `string` | _Yes_
+#### Address
+
+| Property | Type | Optional
+|:---------|:-----|:-------
+| `addressLines`| `string[]`| _No_
+| `type` | [AddressType](#addresstype) | _No_
+
+#### ContactInfo
+
+| Property | Type | Optional
+|:---------|:-----|:-------
+| `addresses`| [Address](#address)[] | _No_
+
+#### Origin
+
+| Property | Type | Optional
+|:---------|:-----|:-------
+| `x`| `number` | _No_
+| `y`| `number` | _No_
+
+#### Size
+| Property | Type | Optional
+|:---------|:-----|:-------
+| `width`| `number` | _No_
+| `height`| `number` | _No_
+
+#### Bounds
+| Property | Type | Optional
+|:---------|:-----|:-------
+| `origin` | [Origin](#origin) | _No_
+| `size` | [Size](#size) | _No_
+
+#### Point
+
+| Property | Type | Optional
+|:---------|:-----|:-------
+| `x`| `number` | _No_
+| `y`| `number` | _No_
+
+#### GeoPoint
+| Property | Type | Optional
+|:---------|:-----|:-------
+| `lat`| `number` | _No_
+| `lng`| `number` | _No_
+
+### Enums
+
+#### EncryptionType
+
+- `Open` = `'open'`
+- `WPA` = `'wpa'`
+- `WEP` = `'wep'`
+- `Unknown` = `'unknown'`
+
+#### PhoneType
+
+- `Unknown` = `"unknown"`
+- `Home` = `"home"`
+- `Work` = `"work"`
+- `Fax` = `"fax"`
+- `Mobile` = `"mobile"`
+
+#### EmailType
+
+- `Unknown` = `"unknown"`
+- `Home` = `"home"`
+- `Work` = `"work"`
+
+#### AddressType
+
+- `Unknown` = `"unknown"`
+- `Home` = `"home"`
+- `Work` = `"work"`
+
+#### ValueType
+
+- `ContactInfo`= `"contactInfo"`
+- `Email`= `"email"`
+- `ISBN`= `"isbn"`
+- `Phone`= `"phone"`
+- `Product`= `"product"`
+- `Text`= `"text"`
+- `Sms`= `"sms"`
+- `URL`= `"url"`
+- `WiFi`= `"wifi"`
+- `Geo`= `"geo"`
+- `CalenderEvent`= `"calender"`
+- `DriverLicense`= `"driverLicense"`
+- `Unknown`= `"unknown"`
+
+#### BarcodeFormats
+
+- `ALL` = `'all'`
+- `CODE_128` = `'code_128'`
+- `CODE_39` = `'code_39'`
+- `CODE_93` = `'code_93'`
+- `CODABAR` = `'codabar'`
+- `DATA_MATRIX` = `'data_matrix'`
+- `EAN_13` = '`ean_13'`
+- `EAN_8` = `'ean_8'`
+- `ITF` = `'itf'`
+- `QR_CODE` = `'qr_code'`
+- `UPC_A` = `'upc_a'`
+- `UPC_E` = `'upc_e'`
+- `PDF417` = `'pdf417'`
+- `AZTEC` = `'aztec'`
+- `UNKOWN` = `'unknown'`
-// TODO
## License
diff --git a/packages/mlkit-barcode-scanning/package.json b/packages/mlkit-barcode-scanning/package.json
index 32f2fcf..dfc30b7 100644
--- a/packages/mlkit-barcode-scanning/package.json
+++ b/packages/mlkit-barcode-scanning/package.json
@@ -1,35 +1,35 @@
{
- "name": "@nativescript/mlkit-barcode-scanning",
- "version": "1.0.0-alpha.1",
- "description": "NativeScript MLKit Barcode Scanner module",
- "main": "index",
- "typings": "index.d.ts",
- "nativescript": {
- "platforms": {
- "ios": "6.0.0",
- "android": "6.0.0"
- }
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/NativeScript/mlkit.git"
- },
- "keywords": [
- "NativeScript",
- "JavaScript",
- "TypeScript",
- "iOS",
- "Android"
- ],
- "author": {
- "name": "NativeScript",
- "email": "oss@nativescript.org"
- },
- "bugs": {
- "url": "https://github.com/NativeScript/mlkit/issues"
- },
- "license": "Apache-2.0",
- "homepage": "https://github.com/NativeScript/mlkit",
- "readmeFilename": "README.md",
- "bootstrapper": "@nativescript/plugin-seed"
+ "name": "@nativescript/mlkit-barcode-scanning",
+ "version": "3.0.4",
+ "description": "NativeScript MLKit Barcode Scanner module",
+ "main": "index",
+ "typings": "index.d.ts",
+ "nativescript": {
+ "platforms": {
+ "ios": "6.0.0",
+ "android": "6.0.0"
+ }
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/NativeScript/mlkit.git"
+ },
+ "keywords": [
+ "NativeScript",
+ "JavaScript",
+ "TypeScript",
+ "iOS",
+ "Android"
+ ],
+ "author": {
+ "name": "NativeScript",
+ "email": "oss@nativescript.org"
+ },
+ "bugs": {
+ "url": "https://github.com/NativeScript/mlkit/issues"
+ },
+ "license": "Apache-2.0",
+ "homepage": "https://github.com/NativeScript/mlkit",
+ "readmeFilename": "README.md",
+ "bootstrapper": "@nativescript/plugin-seed"
}
diff --git a/packages/mlkit-barcode-scanning/platforms/android/include.gradle b/packages/mlkit-barcode-scanning/platforms/android/include.gradle
index 62e0f59..dd568a5 100644
--- a/packages/mlkit-barcode-scanning/platforms/android/include.gradle
+++ b/packages/mlkit-barcode-scanning/platforms/android/include.gradle
@@ -1,3 +1,4 @@
dependencies {
- implementation 'io.github.triniwiz.fancycamera:barcodeScanning:1.0.0-alpha0'
-}
\ No newline at end of file
+ implementation 'io.github.triniwiz:barcode-scanning:4.0.0-alpha.13'
+ implementation 'com.google.mlkit:barcode-scanning:17.3.0'
+}
diff --git a/packages/mlkit-barcode-scanning/platforms/ios/Podfile b/packages/mlkit-barcode-scanning/platforms/ios/Podfile
index f5b5cac..44f5253 100644
--- a/packages/mlkit-barcode-scanning/platforms/ios/Podfile
+++ b/packages/mlkit-barcode-scanning/platforms/ios/Podfile
@@ -1,2 +1,7 @@
-platform :ios, '10.0'
-pod 'GoogleMLKit/BarcodeScanning', '2.3.0'
\ No newline at end of file
+platform :ios, '15.5.0'
+
+if ENV.key?('NSSkipMLKitFromIOSSimulator')
+ puts '⏭️ Skipping GoogleMLKit/BarcodeScanning (simulator build)'
+else
+ pod 'GoogleMLKit/BarcodeScanning'
+end
diff --git a/packages/mlkit-barcode-scanning/project.json b/packages/mlkit-barcode-scanning/project.json
new file mode 100644
index 0000000..4391c7a
--- /dev/null
+++ b/packages/mlkit-barcode-scanning/project.json
@@ -0,0 +1,59 @@
+{
+ "name": "mlkit-barcode-scanning",
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
+ "projectType": "library",
+ "sourceRoot": "packages/mlkit-barcode-scanning",
+ "targets": {
+ "build": {
+ "executor": "@nx/js:tsc",
+ "options": {
+ "outputPath": "dist/packages/mlkit-barcode-scanning",
+ "tsConfig": "packages/mlkit-barcode-scanning/tsconfig.json",
+ "packageJson": "packages/mlkit-barcode-scanning/package.json",
+ "main": "packages/mlkit-barcode-scanning/index.ts",
+ "assets": [
+ "packages/mlkit-barcode-scanning/*.md",
+ "LICENSE",
+ {
+ "glob": "**/*",
+ "input": "packages/mlkit-barcode-scanning/platforms/",
+ "output": "./platforms/"
+ }
+ ]
+ },
+ "dependsOn": [
+ {
+ "target": "build.all",
+ "dependencies": true
+ }
+ ]
+ },
+ "build.all": {
+ "executor": "nx:run-commands",
+ "options": {
+ "commands": ["node tools/scripts/build-finish.ts mlkit-barcode-scanning"],
+ "parallel": false
+ },
+ "outputs": ["{workspaceRoot}/dist/packages/mlkit-barcode-scanning"],
+ "dependsOn": [
+ {
+ "target": "build.all",
+ "dependencies": true
+ },
+ {
+ "target": "build"
+ }
+ ]
+ },
+ "focus": {
+ "executor": "nx:run-commands",
+ "options": {
+ "commands": ["nx g @nativescript/plugin-tools:focus-packages mlkit-barcode-scanning"],
+ "parallel": false
+ }
+ },
+ "lint": {
+ "executor": "@nx/eslint:lint"
+ }
+ }
+}
diff --git a/packages/mlkit-core/.eslintrc.json b/packages/mlkit-core/.eslintrc.json
new file mode 100644
index 0000000..53c06c8
--- /dev/null
+++ b/packages/mlkit-core/.eslintrc.json
@@ -0,0 +1,18 @@
+{
+ "extends": ["../../.eslintrc.json"],
+ "ignorePatterns": ["!**/*", "node_modules/**/*"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "rules": {}
+ }
+ ]
+}
diff --git a/packages/mlkit-core/CHANGELOG.md b/packages/mlkit-core/CHANGELOG.md
new file mode 100644
index 0000000..63e3c58
--- /dev/null
+++ b/packages/mlkit-core/CHANGELOG.md
@@ -0,0 +1,55 @@
+## 3.0.4 (2025-10-23)
+
+### 🩹 Fixes
+
+- switch to remove mlkit libs from simulator builds ([#84](https://github.com/NativeScript/mlkit/pull/84))
+- properly convert `DetectionType` to `TNSMLKitDetectionType` for detectWithStillImage ([c0aa539](https://github.com/NativeScript/mlkit/commit/c0aa539))
+
+### ❤️ Thank You
+
+- cjohn001 @cjohn001
+- Samuel Schultze
+
+## 3.0.1 (2025-02-04)
+
+### 🩹 Fixes
+
+- check if bbox params are set ([#72](https://github.com/NativeScript/mlkit/pull/72))
+
+### ❤️ Thank You
+
+- cjohn001 @cjohn001
+
+# 3.0.0 (2025-01-29)
+
+### 🚀 Features
+
+- custom object detectors + fix related to automatic zooming on ios ([#71](https://github.com/NativeScript/mlkit/pull/71))
+- iOS SDK 5+ and Android SDK updates ([#63](https://github.com/NativeScript/mlkit/pull/63))
+- **core:** allow aspectRatio configuration ([10fea40](https://github.com/NativeScript/mlkit/commit/10fea40))
+- allow retrieval of last processed image ([f98e08d](https://github.com/NativeScript/mlkit/commit/f98e08d))
+- still image detection, pause & torch ([c7ee498](https://github.com/NativeScript/mlkit/commit/c7ee498))
+- pause & torch ([a39ac7e](https://github.com/NativeScript/mlkit/commit/a39ac7e))
+
+### 🩹 Fixes
+
+- **ios:** mlkit import ([#59](https://github.com/NativeScript/mlkit/pull/59))
+- **ios:** latest Image orientation ([e6c694c](https://github.com/NativeScript/mlkit/commit/e6c694c))
+- **core:** module guard checks ([1e851e6](https://github.com/NativeScript/mlkit/commit/1e851e6))
+- **core:** instance check ([a58ac63](https://github.com/NativeScript/mlkit/commit/a58ac63))
+- **core:** should check if undefined ([92cffcf](https://github.com/NativeScript/mlkit/commit/92cffcf))
+- **facedetection:** only set instance if supported ([6b5e775](https://github.com/NativeScript/mlkit/commit/6b5e775))
+- **core:** latestImage guard ([859f7d8](https://github.com/NativeScript/mlkit/commit/859f7d8))
+- unify camera permission handling, detection background handling, detection sig, support processEveryNthFrame, onTorch handling ([98c2ebc](https://github.com/NativeScript/mlkit/commit/98c2ebc))
+- detection, torch & pause ([31d601d](https://github.com/NativeScript/mlkit/commit/31d601d))
+- android barcode detection, formats, ios detection & torch ([353ede1](https://github.com/NativeScript/mlkit/commit/353ede1))
+- detection event ([16642aa](https://github.com/NativeScript/mlkit/commit/16642aa))
+- ios ([9a7d9bc](https://github.com/NativeScript/mlkit/commit/9a7d9bc))
+- typings ([af53c19](https://github.com/NativeScript/mlkit/commit/af53c19))
+
+### ❤️ Thank You
+
+- cjohn001 @cjohn001
+- Nathan Walker
+- Osei Fortune @triniwiz
+- Sean Kelly @SeanKelly369
\ No newline at end of file
diff --git a/packages/mlkit-core/README.md b/packages/mlkit-core/README.md
index cd6b75c..38f5b94 100644
--- a/packages/mlkit-core/README.md
+++ b/packages/mlkit-core/README.md
@@ -1,15 +1,74 @@
# @nativescript/mlkit-core
-```javascript
-ns plugin add @nativescript/mlkit-core
+A plugin that provides a UI component to access the different functionalities of [Google's ML Kit](https://developers.google.com/ml-kit) SDK.
+
+## Contents
+
+* [Installation](#installation)
+* [Use @nativescript/mlkit-core](#use-nativescriptmlkit-core)
+ * [Core](#core)
+ * [Angular](#angular)
+ * [Vue](#vue)
+ * [Vision APIs optional modules](#vision-apis-optional-modules)
+ * [Barcode Scanning](#barcode-scanning)
+ * [Face Detection](#face-detection)
+ * [Image Labeling](#image-labeling)
+ * [Object Detection](#object-detection)
+ * [Pose Detection](#pose-detection)
+ * [Text Recognition](#text-recognition)
+
+* [API](#api)
+ * [detectWithStillImage()](#detectwithstillimage)
+ * [StillImageDetectionOptions interface](#stillimagedetectionoptions-interface)
+ * [MLKitView class](#mlkitview-class)
+ * [Properties](#properties)
+ * [Methods](#methods)
+ * [Enums](#enums)
+ * [DetectionType](#detectiontype)
+ * [CameraPosition](#cameraposition)
+ * [BarcodeFormats](#barcodeformats)
+ * [FaceDetectionPerformanceMode](#facedetectionperformancemode)
+* [License](#license)
+
+## Installation
+
+```cli
+npm install @nativescript/mlkit-core
```
-## Usage
+## Use @nativescript/mlkit-core
+The usage of `@nativescript/mlkit-core` has the following flow:
+1. Registering and adding [MLKitView](#mlkitview-class) to your markup.
-## Core
+2. Setting the `detectionType` and listening to the `detection` event.
-> **Important:** Ensure you've included xmlns:ui="@nativescript/mlkit-core" on the Page element
+To access all the vision APIs at once, set the `detectionType` property to `'all'` and identify them in the `detection` event's handler.
+
+To access a specific API, Barcode scanning for example, set the `detectionType` property to the API name (`'barcode'` for Barcode scanning), AND import that API's NativeScript plugin(`@nativescript/mlkit-barcode-scanning`).
+
+3. Check if ML Kit is supported
+To verify if ML Kit is supported on the device, call the static `isAvailable()` method on [MLKitView class](#mlkitview-class).
+
+```ts
+if(MLKitView.isAvailable()){
+
+}
+```
+4. Request for permission to access the device camera by calling `requestCameraPermission()`:
+
+```ts
+mlKitView.requestCameraPermission().then(()=>{
+
+})
+```
+The following are examples of registering and using `MLKitView` in the different JS flavors.
+
+### Core
+
+1. Register [MLKitView](#mlkitview-class) by adding `xmlns:ui="@nativescript/mlkit-core"` to the Page element.
+
+2. Use the `ui` prefix to access `MLKitView` from the plugin.
```xml
```
+### Angular
-#### Angular
+1. In Angular, register the `MLKitView` by adding `MLKitModule` to the `NgModule` of the component where you want to use `MLKitView`.
```ts
import { MLKitModule } from '@nativescript/mlkit-core/angular';
@@ -36,40 +96,48 @@ import { MLKitModule } from '@nativescript/mlkit-core/angular';
})
```
+2. Use `MLKitView` in markup.
```html
```
-#### Vue
+### Vue
+
+1. To use [MLKitView](#mlkitview-class), register it in the `app.ts` by passing it to the `use` method of the app instance.
```ts
-import Vue from 'nativescript-vue'
+import { createApp } from 'nativescript-vue'
+
import MLKit from '@nativescript/mlkit-core/vue'
+import Home from './components/Home.vue';
+
+const app = createApp(Home)
-Vue.use(MLKit)
+app.use(MLKit)
```
+2. Use `MLKitView` in markup.
-```xml
+```html
+/>
```
-### Optional modules
+### Vision APIs optional modules
> **Important:** Detection works only for optional modules installed
-# Barcode Scanning
+#### Barcode Scanning
-```javascript
-ns plugin add @nativescript/mlkit-barcode-scanning
+```cli
+npm i @nativescript/mlkit-barcode-scanning
```
```ts
@@ -77,32 +145,36 @@ 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 = data;
+ const barcode: BarcodeResult[] = event.data;
}
}
```
-# Face Detection
+For more details, see [@nativescript/mlkit-barcode-scanning](../mlkit-barcode-scanning/)
-```javascript
-ns plugin add @nativescript/mlkit-face-detection
+#### Face Detection
+
+```cli
+npm install @nativescript/mlkit-face-detection
```
```ts
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[] = data;
+ const faces: FaceResult[] = event.data;
}
}
```
+For more details, see [@nativescript/mlkit-face-detection](../mlkit-face-detection/)
-# Image Labeling
+#### Image Labeling
-```javascript
-ns plugin add @nativescript/mlkit-image-labeling
+```cli
+npm install @nativescript/mlkit-image-labeling
```
```ts
@@ -110,16 +182,17 @@ 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[] = data;
+ const labels: ImageLabelingResult[] = event.data;
}
}
```
+For more details, see [nativescript/mlkit-image-labeling](../mlkit-image-labeling/)
-# Object Detection
+#### Object Detection
-```javascript
-ns plugin add @nativescript/mlkit-object-detection
+```cli
+npm install @nativescript/mlkit-object-detection
```
```ts
@@ -127,15 +200,16 @@ 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[] = data;
+ const objects: ObjectResult[] = event.data;
}
}
```
+For more details, see [@nativescript/mlkit-object-detection](../mlkit-object-detection/)
-# Pose Detection
+#### Pose Detection
-```javascript
-ns plugin add @nativescript/mlkit-pose-detection
+```cli
+npm install @nativescript/mlkit-pose-detection
```
```ts
@@ -143,16 +217,17 @@ 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[] = data;
+ const poses: PoseResult = event.data;
}
}
```
+For more details, see [@nativescript/mlkit-pose-detection](../mlkit-pose-detection/)
-# Text Recognition
+#### Text Recognition
-```javascript
-ns plugin add @nativescript/mlkit-text-recognition
+```cli
+npm install @nativescript/mlkit-text-recognition
```
```ts
@@ -160,12 +235,157 @@ 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[] = data;
+ const text: TextResult = event.data;
+ }
+}
+```
+For more details, see [@nativescript/mlkit-text-recognition](../mlkit-text-recognition/)
+
+## API
+
+### detectWithStillImage()
+
+```ts
+import { DetectionType, detectWithStillImage } from "@nativescript/mlkit-core";
+
+async processStill(args) {
+ try {
+
+ result: { [key: string]: any } = await detectWithStillImage(image: ImageSource, options)
+ } catch (e) {
+ console.log(e);
+ }
}
+```
+Detects barcode, pose, etc from a still image instead of using the camera.
+- `image`: The image to detect the object from
+- `options`: An _optional_ [StillImageDetectionOptions](#stillimagedetectionoptions) object parameter specifying the detection characteristics.
+
+### MLKitView class
+
+The MLKitView class provides the camera view for detection.
+
+It has the following members.
+
+#### Properties
+
+| Property | Type
+|:---------|:-----
+| `detectionEvent`| `string`
+| `cameraPosition` | [CameraPosition](#cameraposition)
+| `detectionType` | [DetectionType](#detectiontype)
+| `barcodeFormats` | [BarcodeFormats](#barcodeformats)
+| `faceDetectionPerformanceMode` | [FaceDetectionPerformanceMode](#facedetectionperformancemode)
+| `faceDetectionTrackingEnabled` | `boolean`
+| `faceDetectionMinFaceSize` | `number`
+| `imageLabelerConfidenceThreshold` | `number`
+| `objectDetectionMultiple` | `boolean`
+| `objectDetectionClassify` | `boolean`
+| `torchOn` | `boolean`
+| `pause` | `boolean`
+| `processEveryNthFrame` | `number`
+| `readonly latestImage?` | [ImageSource](https://docs.nativescript.org/api-reference/classes/imagesource)
+| `retrieveLatestImage` | `boolean`
+
+#### Methods
+
+| Method | Returns | Description
+|:-------|:--------|:-----------
+| `isAvailable()` | `boolean`| A static method to check if the device supports ML Kit.
+| `stopPreview()` | `void`
+| `startPreview()` | `void`
+| `toggleCamera()` | `void`
+| `requestCameraPermission()` | `Promise`
+| `hasCameraPermission()` | `boolean` |
+| `on()` | `void` |
+
+
+#### StillImageDetectionOptions interface
+
+
+```ts
+interface StillImageDetectionOptions {
+ detectorType: DetectionType;
+
+ barcodeScanning?: {
+ barcodeFormat?: [BarcodeFormats];
+ };
+ faceDetection?: {
+ faceTracking?: boolean;
+ minimumFaceSize: ?number;
+ detectionMode?: 'fast' | 'accurate';
+ landmarkMode?: 'all' | 'none';
+ contourMode?: 'all' | 'none';
+ classificationMode?: 'all' | 'none';
+ };
+ imageLabeling?: {
+ confidenceThreshold?: number;
+ };
+ objectDetection?: {
+ multiple: boolean;
+ classification: boolean;
+ };
+ selfieSegmentation?: {
+ enableRawSizeMask?: boolean;
+ smoothingRatio?: number;
+ };
}
```
+### Enums
+#### DetectionType
+```ts
+export enum DetectionType {
+ Barcode = 'barcode',
+ DigitalInk = 'digitalInk',
+ Face = 'face',
+ Image = 'image',
+ Object = 'object',
+ Pose = 'pose',
+ Text = 'text',
+ All = 'all',
+ Selfie = 'selfie',
+ None = 'none',
+}
+```
+
+#### CameraPosition
+```ts
+export enum CameraPosition {
+ FRONT = 'front',
+ BACK = 'back',
+}
+```
+
+#### BarcodeFormats
+```ts
+export enum BarcodeFormats {
+ ALL = 'all',
+ CODE_128 = 'code_128',
+ CODE_39 = 'code_39',
+ CODE_93 = 'code_93',
+ CODABAR = 'codabar',
+ DATA_MATRIX = 'data_matrix',
+ EAN_13 = 'ean_13',
+ EAN_8 = 'ean_8',
+ ITF = 'itf',
+ QR_CODE = 'qr_code',
+ UPC_A = 'upc_a',
+ UPC_E = 'upc_e',
+ PDF417 = 'pdf417',
+ AZTEC = 'aztec',
+ UNKOWN = 'unknown',
+}
+```
+#### FaceDetectionPerformanceMode
+
+```ts
+export enum FaceDetectionPerformanceMode {
+ Fast = 'fast',
+ Accurate = 'accurate',
+}
+```
## License
Apache License Version 2.0
diff --git a/packages/mlkit-core/angular/.eslintrc.json b/packages/mlkit-core/angular/.eslintrc.json
new file mode 100644
index 0000000..e1b9056
--- /dev/null
+++ b/packages/mlkit-core/angular/.eslintrc.json
@@ -0,0 +1,24 @@
+{
+ "extends": ["../.eslintrc.json"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "rules": {
+ "@nx/enforce-module-boundaries": [
+ "error",
+ {
+ "allowCircularSelfDependency": true
+ }
+ ]
+ }
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "rules": {}
+ }
+ ]
+}
diff --git a/packages/mlkit-core/angular/index.ts b/packages/mlkit-core/angular/index.ts
index f6042be..8afa266 100644
--- a/packages/mlkit-core/angular/index.ts
+++ b/packages/mlkit-core/angular/index.ts
@@ -2,7 +2,8 @@ import { NgModule } from '@angular/core';
import { registerElement } from '@nativescript/angular';
import { MLKitViewDirective } from './mlkit-view-directive';
-
+import { MLKitView } from '@nativescript/mlkit-core';
+export * from './mlkit-view-directive';
@NgModule({
declarations: [MLKitViewDirective],
@@ -12,4 +13,4 @@ import { MLKitViewDirective } from './mlkit-view-directive';
// @ts-ignore
export class MLKitModule { }
-registerElement('MLKitView', () => require('@nativescript/mlkit-core').MLKitView);
\ No newline at end of file
+registerElement('MLKitView', () => MLKitView);
diff --git a/packages/mlkit-core/angular/mlkit-view-directive.ts b/packages/mlkit-core/angular/mlkit-view-directive.ts
index dd2b9aa..150e352 100644
--- a/packages/mlkit-core/angular/mlkit-view-directive.ts
+++ b/packages/mlkit-core/angular/mlkit-view-directive.ts
@@ -1,6 +1,7 @@
import { Directive } from '@angular/core';
@Directive({
- selector: 'MLKitView',
+ selector: 'MLKitView',
+ standalone: false,
})
-export class MLKitViewDirective { }
\ No newline at end of file
+export class MLKitViewDirective {}
diff --git a/packages/mlkit-core/angular/ng-package.json b/packages/mlkit-core/angular/ng-package.json
new file mode 100644
index 0000000..45ee28b
--- /dev/null
+++ b/packages/mlkit-core/angular/ng-package.json
@@ -0,0 +1,8 @@
+{
+ "$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
+ "lib": {
+ "entryFile": "index.ts"
+ },
+ "allowedNonPeerDependencies": ["."],
+ "dest": "../../../dist/packages/mlkit-core/angular"
+}
diff --git a/packages/mlkit-core/angular/package.json b/packages/mlkit-core/angular/package.json
index 3f21dcb..f030070 100644
--- a/packages/mlkit-core/angular/package.json
+++ b/packages/mlkit-core/angular/package.json
@@ -1,16 +1,3 @@
{
- "name": "@nativescript/mlkit-core-angular",
- "ngPackage": {
- "lib": {
- "entryFile": "index.ts",
- "umdModuleIds": {
- "@nativescript/core": "ns-core",
- "@nativescript/angular": "ns-angular",
- "@nativescript/mlkit-core": "ns-mlkit-core"
- }
- },
- "allowedNonPeerDependencies": [
- "."
- ]
- }
+ "name": "@nativescript/mlkit-core-angular"
}
diff --git a/packages/mlkit-core/angular/tsconfig.angular.json b/packages/mlkit-core/angular/tsconfig.angular.json
index 930b228..14cfe4d 100644
--- a/packages/mlkit-core/angular/tsconfig.angular.json
+++ b/packages/mlkit-core/angular/tsconfig.angular.json
@@ -1,10 +1,13 @@
{
- "extends": "../../../node_modules/ng-packagr/lib/ts/conf/tsconfig.ngc.json",
- "compilerOptions": {
- "types": ["node"],
- "baseUrl": ".",
- "paths": {
- "@nativescript/mlkit-core": ["../../../dist/packages/mlkit-core"]
- }
- }
+ "extends": "../../../node_modules/ng-packagr/lib/ts/conf/tsconfig.ngc.json",
+ "compilerOptions": {
+ "types": ["node"],
+ "baseUrl": ".",
+ "paths": {
+ "@nativescript/mlkit-core": ["../../../dist/packages/mlkit-core"]
+ },
+ "outDir": "../../../dist/out-tsc",
+ "declarationDir": "../../../dist/out-tsc"
+ },
+ "files": ["index.ts"]
}
diff --git a/packages/mlkit-core/angular/tsconfig.json b/packages/mlkit-core/angular/tsconfig.json
index 2d6ba44..0e3f1e6 100644
--- a/packages/mlkit-core/angular/tsconfig.json
+++ b/packages/mlkit-core/angular/tsconfig.json
@@ -1,7 +1,7 @@
{
- "extends": "../../../tsconfig.base.json",
- "compilerOptions": {
- "outDir": "../../../dist/out-tsc",
- "rootDir": "."
- }
-}
\ No newline at end of file
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "outDir": "../../../dist/out-tsc",
+ "rootDir": "."
+ }
+}
diff --git a/packages/mlkit-core/common.ts b/packages/mlkit-core/common.ts
index 37b7f88..10921b7 100644
--- a/packages/mlkit-core/common.ts
+++ b/packages/mlkit-core/common.ts
@@ -1,131 +1,282 @@
-import { booleanConverter, ContainerView, CSSType, Property } from '@nativescript/core';
+import { booleanConverter, ContainerView, CSSType, ImageSource, Property } from '@nativescript/core';
+
+export interface BoundingBoxSettings {
+ drawBBoxes?: boolean;
+ drawEdgeMarks?: boolean;
+ drawLabels?: boolean;
+ bBoxLineWidth?: number;
+ bBoxLineColor?: string;
+ bBoxCornerness?: number;
+ edgeMarkLengthFactor?: number;
+ edgeMarkLineWidth?: number;
+ showConfidence?: boolean;
+ labelTextColor?: string;
+ labelBackgroundColor?: string;
+ labelCornerness?: number;
+ labelAlignment?: 'natural' | 'left' | 'center' | 'right';
+ labelMappings?: { [key: string]: string };
+}
+export const DEFAULT_BOUNDING_BOX_SETTINGS: Required = {
+ drawBBoxes: false,
+ drawEdgeMarks: false,
+ drawLabels: false,
+ bBoxLineWidth: 2,
+ bBoxLineColor: '#FF0000FF',
+ bBoxCornerness: 5,
+ edgeMarkLengthFactor: 0.2,
+ edgeMarkLineWidth: 4,
+ showConfidence: false,
+ labelTextColor: '#FFFFFFFF',
+ labelBackgroundColor: '#00000090',
+ labelCornerness: 5,
+ labelAlignment: 'center',
+ labelMappings: {},
+};
+
+export interface TNSObjectDetectionResult {
+ bounds: {
+ x: number;
+ y: number;
+ width: number;
+ height: number;
+ };
+ trackingId?: number;
+ labels?: {
+ text: string;
+ confidence: number;
+ index?: number;
+ }[];
+}
export enum DetectionType {
- Barcode = "barcode",
- DigitalInk = "digitalInk",
- Face = "face",
- Image = "image",
- Object = "object",
- Pose = "pose",
- Text = "text",
- All = "all",
- None = "none"
+ Barcode = 'barcode',
+ DigitalInk = 'digitalInk',
+ Face = 'face',
+ Image = 'image',
+ Object = 'object',
+ CustomObject = 'customObject',
+ Pose = 'pose',
+ Text = 'text',
+ All = 'all',
+ Selfie = 'selfie',
+ None = 'none',
}
export enum CameraPosition {
- FRONT = 'front',
- BACK = 'back'
+ FRONT = 'front',
+ BACK = 'back',
}
-
export enum BarcodeFormats {
- ALL = 'all',
- CODE_128 = 'code_128',
- CODE_39 = 'code_39',
- CODE_93 = 'code_93',
- CODABAR = 'codabar',
- DATA_MATRIX = 'data_matrix',
- EAN_13 = 'ean_13',
- EAN_8 = 'ean_8',
- ITF = 'itf',
- QR_CODE = 'qr_code',
- UPC_A = 'upc_a',
- UPC_E = 'upc_e',
- PDF417 = 'pdf417',
- AZTEC = 'aztec',
- UNKOWN = 'unknown'
+ ALL = 'all',
+ CODE_128 = 'code_128',
+ CODE_39 = 'code_39',
+ CODE_93 = 'code_93',
+ CODABAR = 'codabar',
+ DATA_MATRIX = 'data_matrix',
+ EAN_13 = 'ean_13',
+ EAN_8 = 'ean_8',
+ ITF = 'itf',
+ QR_CODE = 'qr_code',
+ UPC_A = 'upc_a',
+ UPC_E = 'upc_e',
+ PDF417 = 'pdf417',
+ AZTEC = 'aztec',
+ UNKOWN = 'unknown',
}
-
export enum FaceDetectionPerformanceMode {
- Fast = 'fast',
- Accurate = 'accurate'
+ Fast = 'fast',
+ Accurate = 'accurate',
}
@CSSType('MLKitView')
export class MLKitViewBase extends ContainerView {
- public static detectionEvent = 'detection';
- cameraPosition: CameraPosition;
- detectionType: DetectionType;
- barcodeFormats: BarcodeFormats[];
- faceDetectionPerformanceMode: FaceDetectionPerformanceMode;
- faceDetectionTrackingEnabled: boolean;
- faceDetectionMinFaceSize: number;
- imageLabelerConfidenceThreshold: number;
- objectDetectionMultiple: boolean;
- objectDetectionClassify: boolean;
+ static detectionEvent = 'detection';
+ cameraPosition: CameraPosition;
+ detectionType: DetectionType;
+ barcodeFormats: BarcodeFormats[];
+ faceDetectionPerformanceMode: FaceDetectionPerformanceMode;
+ faceDetectionTrackingEnabled: boolean;
+ faceDetectionMinFaceSize: number;
+ imageLabelerConfidenceThreshold: number;
+ objectDetectionMultiple: boolean;
+ objectDetectionClassify: boolean;
+ customObjectDetectionMultiple: boolean;
+ customObjectDetectionClassify: boolean;
+ customObjectDetectionModelName: string;
+ customObjectDetectionLoadedModel: string;
+ customObjectDetectionConfidenceThreshold: number | null;
+ customObjectDetectionMaximumNumLabels: number;
+ boundingBoxSettings: BoundingBoxSettings;
+ torchOn: boolean;
+ pause: boolean;
+ processEveryNthFrame: number;
+ readonly latestImage?: ImageSource;
+ retrieveLatestImage: boolean;
+ aspectRatio: 'aspect' | 'aspectFill' | 'fill';
}
export const cameraPositionProperty = new Property({
- name: 'cameraPosition',
- defaultValue: CameraPosition.BACK
+ name: 'cameraPosition',
+ defaultValue: CameraPosition.BACK,
});
cameraPositionProperty.register(MLKitViewBase);
+export const aspectRatioProperty = new Property({
+ name: 'aspectRatio',
+ defaultValue: 'aspect',
+});
+
+aspectRatioProperty.register(MLKitViewBase);
+
export const detectionTypeProperty = new Property({
- name: 'detectionType',
- defaultValue: DetectionType.None
+ name: 'detectionType',
+ defaultValue: DetectionType.None,
});
detectionTypeProperty.register(MLKitViewBase);
export const barcodeFormatsProperty = new Property({
- name: 'barcodeFormats',
- defaultValue: [BarcodeFormats.ALL]
-})
+ name: 'barcodeFormats',
+ defaultValue: [BarcodeFormats.ALL],
+});
barcodeFormatsProperty.register(MLKitViewBase);
-
export const faceDetectionPerformanceModeProperty = new Property({
- name: 'faceDetectionPerformanceMode',
- defaultValue: FaceDetectionPerformanceMode.Fast
-})
+ name: 'faceDetectionPerformanceMode',
+ defaultValue: FaceDetectionPerformanceMode.Fast,
+});
faceDetectionPerformanceModeProperty.register(MLKitViewBase);
-
export const faceDetectionTrackingEnabledProperty = new Property({
- name: 'faceDetectionTrackingEnabled',
- defaultValue: false,
- valueConverter: booleanConverter
+ name: 'faceDetectionTrackingEnabled',
+ defaultValue: false,
+ valueConverter: booleanConverter,
});
faceDetectionTrackingEnabledProperty.register(MLKitViewBase);
-
export const faceDetectionMinFaceSizeProperty = new Property({
- name: 'faceDetectionMinFaceSize',
- defaultValue: 0.1
-})
+ name: 'faceDetectionMinFaceSize',
+ defaultValue: 0.1,
+});
faceDetectionMinFaceSizeProperty.register(MLKitViewBase);
-
export const imageLabelerConfidenceThresholdProperty = new Property({
- name: 'imageLabelerConfidenceThreshold',
- defaultValue: 0.5
+ name: 'imageLabelerConfidenceThreshold',
+ defaultValue: 0.5,
});
imageLabelerConfidenceThresholdProperty.register(MLKitViewBase);
export const objectDetectionMultipleProperty = new Property({
- name: 'objectDetectionMultiple',
- defaultValue: false,
- valueConverter: booleanConverter
+ name: 'objectDetectionMultiple',
+ defaultValue: false,
+ valueConverter: booleanConverter,
});
objectDetectionMultipleProperty.register(MLKitViewBase);
-
export const objectDetectionClassifyProperty = new Property({
- name: 'objectDetectionClassify',
- defaultValue: false,
- valueConverter: booleanConverter
+ name: 'objectDetectionClassify',
+ defaultValue: false,
+ valueConverter: booleanConverter,
});
objectDetectionClassifyProperty.register(MLKitViewBase);
+export const customObjectDetectionMultipleProperty = new Property({
+ name: 'customObjectDetectionMultiple',
+ defaultValue: false,
+ valueConverter: booleanConverter,
+});
+
+customObjectDetectionMultipleProperty.register(MLKitViewBase);
+
+export const customObjectDetectionClassifyProperty = new Property({
+ name: 'customObjectDetectionClassify',
+ defaultValue: false,
+ valueConverter: booleanConverter,
+});
+customObjectDetectionClassifyProperty.register(MLKitViewBase);
+
+export const customObjectDetectionModelNameProperty = new Property({
+ name: 'customObjectDetectionModelName',
+ defaultValue: 'customModel',
+});
+
+customObjectDetectionModelNameProperty.register(MLKitViewBase);
+
+export const customObjectDetectionConfidenceThresholdProperty = new Property({
+ name: 'customObjectDetectionConfidenceThreshold',
+ defaultValue: null,
+ valueConverter: (value: string) => {
+ return value === null ? null : +value;
+ },
+});
+
+customObjectDetectionConfidenceThresholdProperty.register(MLKitViewBase);
+
+export const customObjectDetectionMaximumNumLabelsProperty = new Property({
+ name: 'customObjectDetectionMaximumNumLabels',
+ defaultValue: 10,
+ valueConverter: (value: string) => {
+ return +value;
+ },
+});
+
+customObjectDetectionMaximumNumLabelsProperty.register(MLKitViewBase);
+
+export const boundingBoxSettingsProperty = new Property({
+ name: 'boundingBoxSettings',
+ defaultValue: DEFAULT_BOUNDING_BOX_SETTINGS,
+ valueConverter: (value: string): BoundingBoxSettings => {
+ if (typeof value === 'string') {
+ try {
+ const parsed = JSON.parse(value);
+ return { ...DEFAULT_BOUNDING_BOX_SETTINGS, ...parsed };
+ } catch (e) {
+ throw new Error(`Invalid boundingBoxSettings property value: ${value}`);
+ }
+ }
+ },
+});
+
+boundingBoxSettingsProperty.register(MLKitViewBase);
+
+export const torchOnProperty = new Property({
+ name: 'torchOn',
+ defaultValue: false,
+ valueConverter: booleanConverter,
+});
+
+torchOnProperty.register(MLKitViewBase);
+
+export const pauseProperty = new Property({
+ name: 'pause',
+ defaultValue: false,
+ valueConverter: booleanConverter,
+});
+
+pauseProperty.register(MLKitViewBase);
+
+export const processEveryNthFrameProperty = new Property({
+ name: 'processEveryNthFrame',
+ defaultValue: 0,
+});
+
+processEveryNthFrameProperty.register(MLKitViewBase);
+
+export const retrieveLatestImageProperty = new Property({
+ name: 'retrieveLatestImage',
+ defaultValue: false,
+ valueConverter: booleanConverter,
+});
+retrieveLatestImageProperty.register(MLKitViewBase);
diff --git a/packages/mlkit-core/index.android.ts b/packages/mlkit-core/index.android.ts
index d48e4a2..ebbe354 100644
--- a/packages/mlkit-core/index.android.ts
+++ b/packages/mlkit-core/index.android.ts
@@ -1,182 +1,275 @@
-import { BarcodeFormats, barcodeFormatsProperty, CameraPosition, cameraPositionProperty, DetectionType, detectionTypeProperty, faceDetectionMinFaceSizeProperty, faceDetectionPerformanceModeProperty, faceDetectionTrackingEnabledProperty, imageLabelerConfidenceThresholdProperty, MLKitViewBase, objectDetectionClassifyProperty, objectDetectionMultipleProperty } from "./common";
-import { Application, Device, Utils, AndroidActivityRequestPermissionsEventData } from '@nativescript/core';
+import { BarcodeFormats, barcodeFormatsProperty, CameraPosition, cameraPositionProperty, DetectionType, detectionTypeProperty, faceDetectionMinFaceSizeProperty, faceDetectionPerformanceModeProperty, faceDetectionTrackingEnabledProperty, imageLabelerConfidenceThresholdProperty, MLKitViewBase, objectDetectionClassifyProperty, objectDetectionMultipleProperty, pauseProperty, processEveryNthFrameProperty, retrieveLatestImageProperty, torchOnProperty } from './common';
+import { Application, Device, Utils, AndroidActivityRequestPermissionsEventData, ImageSource } from '@nativescript/core';
import lazy from '@nativescript/core/utils/lazy';
-
-const DetectorType_All = lazy(() => io.github.triniwiz.fancycamera.DetectorType.All);
-const DetectorType_Barcode = lazy(() => io.github.triniwiz.fancycamera.DetectorType.Barcode);
-const DetectorType_DigitalInk = lazy(() => io.github.triniwiz.fancycamera.DetectorType.DigitalInk);
-const DetectorType_Face = lazy(() => io.github.triniwiz.fancycamera.DetectorType.Face);
-const DetectorType_Image = lazy(() => io.github.triniwiz.fancycamera.DetectorType.Image);
-const DetectorType_None = lazy(() => io.github.triniwiz.fancycamera.DetectorType.None);
-const DetectorType_Object = lazy(() => io.github.triniwiz.fancycamera.DetectorType.Object);
-const DetectorType_Pose = lazy(() => io.github.triniwiz.fancycamera.DetectorType.Pose);
-const DetectorType_Text = lazy(() => io.github.triniwiz.fancycamera.DetectorType.Text);
-
-const BARCODE_SCANNER_SUPPORTED = lazy(() => typeof io.github.triniwiz.fancycamera?.barcodescanning?.BarcodeScanner);
-const TEXT_RECOGNITION_SUPPORTED = lazy(() => typeof io.github.triniwiz.fancycamera?.textrecognition?.TextRecognition);
-const FACE_DETECTION_SUPPORTED = lazy(() => typeof io.github.triniwiz.fancycamera?.facedetection?.FaceDetection);
-const IMAGE_LABELING_SUPPORTED = lazy(() => typeof io.github.triniwiz.fancycamera?.imagelabeling?.ImageLabeling);
-const OBJECT_DETECTION_SUPPORTED = lazy(() => typeof io.github.triniwiz.fancycamera?.objectdetection?.ObjectDetection);
-const POSE_DETECTION_SUPPORTED = lazy(() => typeof io.github.triniwiz.fancycamera?.posedetection?.PoseDetection);
+import { StillImageDetectionOptions } from '.';
+
+const IMAGE_PROCESSOR_All = lazy(() => {
+ const ret = [];
+
+ if (BARCODE_SCANNER_SUPPORTED()) {
+ ret.push(IMAGE_PROCESSOR_Barcode());
+ }
+
+ if (FACE_DETECTION_SUPPORTED()) {
+ ret.push(IMAGE_PROCESSOR_Face());
+ }
+
+ if (IMAGE_LABELING_SUPPORTED()) {
+ ret.push(IMAGE_PROCESSOR_Image());
+ }
+
+ if (OBJECT_DETECTION_SUPPORTED()) {
+ ret.push(IMAGE_PROCESSOR_Object());
+ }
+
+ if (POSE_DETECTION_SUPPORTED()) {
+ ret.push(IMAGE_PROCESSOR_Pose());
+ }
+
+ if (TEXT_RECOGNITION_SUPPORTED()) {
+ ret.push(IMAGE_PROCESSOR_Text());
+ }
+
+ if (SELFIE_SEGMENTATION_SUPPORTED()) {
+ ret.push(IMAGE_PROCESSOR_Selfie());
+ }
+
+ return ret;
+});
+const IMAGE_PROCESSOR_Barcode = lazy(() => new io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner());
+const IMAGE_PROCESSOR_DigitalInk = lazy(() => new (io as any).github.triniwiz.fancycamera.digitalink.DigitalInk());
+const IMAGE_PROCESSOR_Face = lazy(() => new io.github.triniwiz.fancycamera.facedetection.FaceDetection());
+const IMAGE_PROCESSOR_Image = lazy(() => new io.github.triniwiz.fancycamera.imagelabeling.ImageLabeling());
+const IMAGE_PROCESSOR_Object = lazy(() => new io.github.triniwiz.fancycamera.objectdetection.ObjectDetection());
+const IMAGE_PROCESSOR_Pose = lazy(() => new io.github.triniwiz.fancycamera.posedetection.PoseDetection());
+const IMAGE_PROCESSOR_Text = lazy(() => new io.github.triniwiz.fancycamera.textrecognition.TextRecognition());
+const IMAGE_PROCESSOR_Selfie = lazy(() => new io.github.triniwiz.fancycamera.selfiesegmentation.SelfieSegmentation());
+
+const BARCODE_SCANNER_SUPPORTED = lazy(() => typeof io.github.triniwiz.fancycamera?.barcodescanning?.BarcodeScanner !== 'undefined');
+const TEXT_RECOGNITION_SUPPORTED = lazy(() => typeof io.github.triniwiz.fancycamera?.textrecognition?.TextRecognition !== 'undefined');
+const FACE_DETECTION_SUPPORTED = lazy(() => typeof io.github.triniwiz.fancycamera?.facedetection?.FaceDetection !== 'undefined');
+const IMAGE_LABELING_SUPPORTED = lazy(() => typeof io.github.triniwiz.fancycamera?.imagelabeling?.ImageLabeling !== 'undefined');
+const OBJECT_DETECTION_SUPPORTED = lazy(() => typeof io.github.triniwiz.fancycamera?.objectdetection?.ObjectDetection !== 'undefined');
+const POSE_DETECTION_SUPPORTED = lazy(() => typeof io.github.triniwiz.fancycamera?.posedetection?.PoseDetection !== 'undefined');
+const SELFIE_SEGMENTATION_SUPPORTED = lazy(() => typeof io.github.triniwiz.fancycamera?.selfiesegmentation?.SelfieSegmentation !== 'undefined');
+
+const TORCH_MODE_ON = lazy(() => io.github.triniwiz.fancycamera.CameraFlashMode.TORCH);
+const TORCH_MODE_OFF = lazy(() => io.github.triniwiz.fancycamera.CameraFlashMode.OFF);
export { BarcodeFormats, barcodeFormatsProperty, CameraPosition, cameraPositionProperty, DetectionType, faceDetectionMinFaceSizeProperty, faceDetectionPerformanceModeProperty, faceDetectionTrackingEnabledProperty, imageLabelerConfidenceThresholdProperty, objectDetectionClassifyProperty, objectDetectionMultipleProperty } from './common';
export class MLKitView extends MLKitViewBase {
- #camera: io.github.triniwiz.fancycamera.FancyCamera;
- static #hasCamera: boolean;
- #onTextListener: io.github.triniwiz.fancycamera.ImageAnalysisCallback;
- #onBarcodeListener: io.github.triniwiz.fancycamera.ImageAnalysisCallback;
- #onDigitalInkListener: io.github.triniwiz.fancycamera.ImageAnalysisCallback;
- #onFaceListener: io.github.triniwiz.fancycamera.ImageAnalysisCallback;
- #onImageListener: io.github.triniwiz.fancycamera.ImageAnalysisCallback;
- #onObjectListener: io.github.triniwiz.fancycamera.ImageAnalysisCallback;
- #onPoseListener: io.github.triniwiz.fancycamera.ImageAnalysisCallback;
- #permissionHandler = (args: AndroidActivityRequestPermissionsEventData) => {
- this.#camera.onPermissionHandler(
- args.requestCode, args.permissions, args.grantResults
- )
- }
- #barcodeScannerOptions: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.Options;
- #faceDetectionOptions: io.github.triniwiz.fancycamera.facedetection.FaceDetection.Options;
- #imageLabelerOptions: io.github.triniwiz.fancycamera.imagelabeling.ImageLabeling.Options;
- #objectDetectionOptions: io.github.triniwiz.fancycamera.objectdetection.ObjectDetection.Options;
-
-
- #getFancyCamera() {
- return (this.#camera as any)?.getChildAt?.(0) as io.github.triniwiz.fancycamera.CameraBase;
- }
-
- createNativeView() {
- this.#camera = new io.github.triniwiz.fancycamera.FancyCamera(this._context);
- Application.android.on('activityRequestPermissions', this.#permissionHandler);
- return this.#camera;
- }
-
-
- [cameraPositionProperty.setNative](value: CameraPosition) {
- if (this.#camera) {
- switch (value) {
- case CameraPosition.FRONT:
- this.#camera.setPosition(
- io.github.triniwiz.fancycamera.CameraPosition.FRONT
- )
- break;
- default:
- this.#camera.setPosition(
- io.github.triniwiz.fancycamera.CameraPosition.BACK
- )
- break;
- }
- }
+ _camera: io.github.triniwiz.fancycamera.FancyCamera;
+ static _hasCamera: boolean;
+ _onTextListener: io.github.triniwiz.fancycamera.ImageAnalysisCallback;
+ _onBarcodeListener: io.github.triniwiz.fancycamera.ImageAnalysisCallback;
+ _onDigitalInkListener: io.github.triniwiz.fancycamera.ImageAnalysisCallback;
+ _onFaceListener: io.github.triniwiz.fancycamera.ImageAnalysisCallback;
+ _onImageListener: io.github.triniwiz.fancycamera.ImageAnalysisCallback;
+ _onObjectListener: io.github.triniwiz.fancycamera.ImageAnalysisCallback;
+ _onPoseListener: io.github.triniwiz.fancycamera.ImageAnalysisCallback;
+ _permissionHandler = (args: AndroidActivityRequestPermissionsEventData) => {
+ if (this.pause) {
+ return;
}
+ this._camera.onPermissionHandler(args.requestCode, args.permissions, args.grantResults);
+ };
+ _barcodeScannerOptions: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.Options;
+ _faceDetectionOptions: io.github.triniwiz.fancycamera.facedetection.FaceDetection.Options;
+ _imageLabelerOptions: io.github.triniwiz.fancycamera.imagelabeling.ImageLabeling.Options;
+ _objectDetectionOptions: io.github.triniwiz.fancycamera.objectdetection.ObjectDetection.Options;
+
+ _getFancyCamera() {
+ return (this._camera as any)?.getChildAt?.(0) as io.github.triniwiz.fancycamera.CameraBase;
+ }
+
+ createNativeView() {
+ this._camera = new io.github.triniwiz.fancycamera.FancyCamera(this._context);
+ Application.android.on('activityRequestPermissions', this._permissionHandler);
+ return this._camera;
+ }
+
+ [retrieveLatestImageProperty.setNative](value: boolean) {
+ if (!this._camera) {
+ return;
+ }
+ this._camera.setRetrieveLatestImage(value);
+ }
- public static isAvailable() {
- if (this.#hasCamera === undefined) {
- if (parseInt(Device.sdkVersion) >= 21) {
- try {
- const manager: android.hardware.camera2.CameraManager = Utils.android.getApplicationContext().getSystemService(android.content.Context.CAMERA_SERVICE);
- this.#hasCamera = manager.getCameraIdList().length > 0;
- } catch (e) {
- this.#hasCamera = false;
- }
- } else {
- this.#hasCamera = android.hardware.Camera.getNumberOfCameras() > 0;
- }
- }
- return this.#hasCamera;
- }
-
- [detectionTypeProperty.setNative](value) {
- let type = DetectorType_None();
- switch (value) {
- case DetectionType.All:
- type = DetectorType_All();
- break;
- case DetectionType.Barcode:
- type = DetectorType_Barcode();
- break;
- case DetectionType.DigitalInk:
- type = DetectorType_DigitalInk();
- break;
- case DetectionType.Face:
- type = DetectorType_Face();
- break;
- case DetectionType.Image:
- type = DetectorType_Image();
- break;
- case DetectionType.Object:
- type = DetectorType_Object();
- break;
- case DetectionType.Pose:
- type = DetectorType_Pose();
- break;
- case DetectionType.Text:
- type = DetectorType_Text();
- break;
- default:
- type = DetectorType_None();
- break;
- }
- this.#camera.setDetectorType(type);
- this.#setListeners();
+ _latestImage: ImageSource = null;
+
+ // @ts-ignore
+ get latestImage(): ImageSource {
+ if (!this._camera) {
+ return null;
}
- initNativeView() {
- super.initNativeView();
- this.#setListeners();
+ const image = this._camera.getLatestImage();
+ if (!image) {
+ return null;
}
- #setListeners() {
- const ref = new WeakRef(this);
- if (!this.#onTextListener && (this.detectionType === DetectionType.Text || this.detectionType === DetectionType.All)) {
- this.#onTextListener = new io.github.triniwiz.fancycamera.ImageAnalysisCallback({
- onSuccess(param0: string) {
- const hasListener = ref?.get?.().hasListeners?.(MLKitView.detectionEvent);
- if (!hasListener) {
- return;
- }
- try {
- ref?.get?.().notify?.({
- eventName: MLKitView.detectionEvent,
- object: ref?.get?.(),
- data: JSON.parse(param0),
- type: DetectionType.Text
- });
- } catch (e) { }
- },
- onError(param0: string, param1: java.lang.Exception) {
+ if (image !== this._latestImage?.android) {
+ this._latestImage = new ImageSource(image);
+ }
- }
- });
- this.#camera.setOnTextRecognitionListener(this.#onTextListener);
+ return this._latestImage;
+ }
+
+ [cameraPositionProperty.setNative](value: CameraPosition) {
+ if (this._camera) {
+ switch (value) {
+ case CameraPosition.FRONT:
+ this._camera.setPosition(io.github.triniwiz.fancycamera.CameraPosition.FRONT);
+ break;
+ default:
+ this._camera.setPosition(io.github.triniwiz.fancycamera.CameraPosition.BACK);
+ break;
+ }
+ }
+ }
+
+ public static isAvailable() {
+ if (this._hasCamera === undefined) {
+ if (parseInt(Device.sdkVersion) >= 21) {
+ try {
+ const manager: android.hardware.camera2.CameraManager = Utils.android.getApplicationContext().getSystemService(android.content.Context.CAMERA_SERVICE);
+ this._hasCamera = manager.getCameraIdList().length > 0;
+ } catch (e) {
+ this._hasCamera = false;
}
+ } else {
+ this._hasCamera = android.hardware.Camera.getNumberOfCameras() > 0;
+ }
+ }
+ return this._hasCamera;
+ }
+
+ [torchOnProperty.setNative](value: boolean) {
+ if (this._camera) {
+ if (value) {
+ this._camera.setFlashMode(TORCH_MODE_ON());
+ } else {
+ this._camera.setFlashMode(TORCH_MODE_OFF());
+ }
+ }
+ }
- if (!this.#onBarcodeListener && (this.detectionType.includes(DetectionType.Barcode) || this.detectionType.includes(DetectionType.All))) {
- this.#onBarcodeListener = new io.github.triniwiz.fancycamera.ImageAnalysisCallback({
- onSuccess(param0: string) {
- const hasListener = ref?.get?.().hasListeners?.(MLKitView.detectionEvent);
- if (!hasListener) {
- return;
- }
- try {
- ref?.get?.().notify?.({
- eventName: MLKitView.detectionEvent,
- object: ref?.get?.(),
- data: JSON.parse(param0),
- type: DetectionType.Barcode
- });
- } catch (e) { }
- },
- onError(param0: string, param1: java.lang.Exception) {
+ [pauseProperty.setNative](value: boolean) {
+ if (this._camera) {
+ this._camera.setPause(value);
+ }
+ }
+
+ [detectionTypeProperty.setNative](value) {
+ switch (value) {
+ case DetectionType.All:
+ {
+ const all = IMAGE_PROCESSOR_All();
+ if (all.length) {
+ this._camera.addImageProcessors(all);
+ } else {
+ this._camera.clearImageProcessor();
+ }
+ }
+ break;
+ case DetectionType.Barcode:
+ this._camera.clearImageProcessor();
+ this._camera.addImageProcessor(IMAGE_PROCESSOR_Barcode());
+ break;
+ case DetectionType.DigitalInk:
+ this._camera.clearImageProcessor();
+ break;
+ case DetectionType.Face:
+ this._camera.clearImageProcessor();
+ this._camera.addImageProcessor(IMAGE_PROCESSOR_Face());
+ break;
+ case DetectionType.Image:
+ this._camera.clearImageProcessor();
+ this._camera.addImageProcessor(IMAGE_PROCESSOR_Image());
+ break;
+ case DetectionType.Object:
+ this._camera.clearImageProcessor();
+ this._camera.addImageProcessor(IMAGE_PROCESSOR_Object());
+ break;
+ case DetectionType.Pose:
+ this._camera.clearImageProcessor();
+ this._camera.addImageProcessor(IMAGE_PROCESSOR_Pose());
+ break;
+ case DetectionType.Text:
+ this._camera.clearImageProcessor();
+ this._camera.addImageProcessor(IMAGE_PROCESSOR_Text());
+ break;
+ case DetectionType.Selfie:
+ this._camera.clearImageProcessor();
+ this._camera.addImageProcessor(IMAGE_PROCESSOR_Selfie());
+ break;
+ default:
+ this._camera.clearImageProcessor();
+ break;
+ }
+
+ this._setListeners();
+ }
- }
+ [processEveryNthFrameProperty.setNative](value) {
+ if (this._camera) {
+ this._camera.setProcessEveryNthFrame(value);
+ }
+ }
+
+ initNativeView() {
+ super.initNativeView();
+ this._setListeners();
+ }
+
+ _setListeners() {
+ const ref = new WeakRef(this);
+ if (!this._onTextListener && (this.detectionType === DetectionType.Text || this.detectionType === DetectionType.All)) {
+ this._onTextListener = new io.github.triniwiz.fancycamera.ImageAnalysisCallback({
+ onSuccess(param0: string) {
+ const hasListener = ref?.get?.().hasListeners?.(MLKitView.detectionEvent);
+ if (!hasListener) {
+ return;
+ }
+ try {
+ ref?.get?.().notify?.({
+ eventName: MLKitView.detectionEvent,
+ object: ref?.get?.(),
+ data: JSON.parse(param0),
+ type: DetectionType.Text,
});
- this.#camera.setOnBarcodeScanningListener(this.#onBarcodeListener);
- }
+ } catch (e) {}
+ },
+ onError(param0: string, param1: java.lang.Exception) {},
+ });
+ this._camera.setOnTextRecognitionListener(this._onTextListener);
+ }
+
+ if (!this._onBarcodeListener && (this.detectionType.includes(DetectionType.Barcode) || this.detectionType.includes(DetectionType.All))) {
+ this._onBarcodeListener = new io.github.triniwiz.fancycamera.ImageAnalysisCallback({
+ onSuccess(param0: string) {
+ const hasListener = ref?.get?.().hasListeners?.(MLKitView.detectionEvent);
+ if (!hasListener) {
+ return;
+ }
+ try {
+ ref?.get?.().notify?.({
+ eventName: MLKitView.detectionEvent,
+ object: ref?.get?.(),
+ data: JSON.parse(param0),
+ type: DetectionType.Barcode,
+ });
+ } catch (e) {}
+ },
+ onError(param0: string, param1: java.lang.Exception) {},
+ });
+ this._camera.setOnBarcodeScanningListener(this._onBarcodeListener);
+ }
- // todo
- if (!this.#onDigitalInkListener && (this.detectionType === DetectionType.DigitalInk || this.detectionType === DetectionType.All)) {
- /* this.#onDigitalInkListener = new io.github.triniwiz.fancycamera.ImageAnalysisCallback({
+ // todo
+ if (!this._onDigitalInkListener && (this.detectionType === DetectionType.DigitalInk || this.detectionType === DetectionType.All)) {
+ /* this._onDigitalInkListener = new io.github.triniwiz.fancycamera.ImageAnalysisCallback({
onSuccess(param0: string) {
const hasListener = ref?.get?.().hasListeners?.(MLKitView.detectionEvent);
if(!hasListener){
@@ -192,279 +285,372 @@ export class MLKitView extends MLKitViewBase {
} catch (e) { }
},
onError(param0: string, param1: java.lang.Exception) {
-
+
}
}); */
- }
-
- if (!this.#onFaceListener && (this.detectionType === DetectionType.Face || this.detectionType === DetectionType.All)) {
- this.#faceDetectionOptions = new io.github.triniwiz.fancycamera.facedetection.FaceDetection.Options();
- this.#onFaceListener = new io.github.triniwiz.fancycamera.ImageAnalysisCallback({
- onSuccess(param0: string) {
- const hasListener = ref?.get?.().hasListeners?.(MLKitView.detectionEvent);
- if (!hasListener) {
- return;
- }
- try {
- ref?.get?.().notify?.({
- eventName: MLKitView.detectionEvent,
- object: ref?.get?.(),
- data: JSON.parse(param0),
- type: DetectionType.Face
- });
- } catch (e) { }
- },
- onError(param0: string, param1: java.lang.Exception) {
+ }
- }
+ if (!this._onFaceListener && (this.detectionType === DetectionType.Face || this.detectionType === DetectionType.All)) {
+ if (FACE_DETECTION_SUPPORTED()) {
+ this._faceDetectionOptions = new io.github.triniwiz.fancycamera.facedetection.FaceDetection.Options();
+ }
+ this._onFaceListener = new io.github.triniwiz.fancycamera.ImageAnalysisCallback({
+ onSuccess(param0: string) {
+ const hasListener = ref?.get?.().hasListeners?.(MLKitView.detectionEvent);
+ if (!hasListener) {
+ return;
+ }
+ try {
+ ref?.get?.().notify?.({
+ eventName: MLKitView.detectionEvent,
+ object: ref?.get?.(),
+ data: JSON.parse(param0),
+ type: DetectionType.Face,
});
- this.#camera.setOnFacesDetectedListener(this.#onFaceListener);
- }
-
- if (!this.#onImageListener && (this.detectionType === DetectionType.Image || this.detectionType === DetectionType.All)) {
- this.#onImageListener = new io.github.triniwiz.fancycamera.ImageAnalysisCallback({
- onSuccess(param0: string) {
- const hasListener = ref?.get?.().hasListeners?.(MLKitView.detectionEvent);
- if (!hasListener) {
- return;
- }
- try {
- ref?.get?.().notify?.({
- eventName: MLKitView.detectionEvent,
- object: ref?.get?.(),
- data: JSON.parse(param0),
- type: DetectionType.Image
- });
- } catch (e) { }
- },
- onError(param0: string, param1: java.lang.Exception) {
+ } catch (e) {}
+ },
+ onError(param0: string, param1: java.lang.Exception) {},
+ });
+ this._camera.setOnFacesDetectedListener(this._onFaceListener);
+ }
- }
+ if (!this._onImageListener && (this.detectionType === DetectionType.Image || this.detectionType === DetectionType.All)) {
+ this._onImageListener = new io.github.triniwiz.fancycamera.ImageAnalysisCallback({
+ onSuccess(param0: string) {
+ const hasListener = ref?.get?.().hasListeners?.(MLKitView.detectionEvent);
+ if (!hasListener) {
+ return;
+ }
+ try {
+ ref?.get?.().notify?.({
+ eventName: MLKitView.detectionEvent,
+ object: ref?.get?.(),
+ data: JSON.parse(param0),
+ type: DetectionType.Image,
});
- this.#camera.setOnImageLabelingListener(this.#onImageListener);
- }
-
- if (!this.#onObjectListener && (this.detectionType === DetectionType.Object || this.detectionType === DetectionType.All)) {
- this.#onObjectListener = new io.github.triniwiz.fancycamera.ImageAnalysisCallback({
- onSuccess(param0: string) {
- const hasListener = ref?.get?.().hasListeners?.(MLKitView.detectionEvent);
- if (!hasListener) {
- return;
- }
- try {
- ref?.get?.().notify?.({
- eventName: MLKitView.detectionEvent,
- object: ref?.get?.(),
- data: JSON.parse(param0),
- type: DetectionType.Object
- });
- } catch (e) { }
- },
- onError(param0: string, param1: java.lang.Exception) {
+ } catch (e) {}
+ },
+ onError(param0: string, param1: java.lang.Exception) {},
+ });
+ this._camera.setOnImageLabelingListener(this._onImageListener);
+ }
- }
+ if (!this._onObjectListener && (this.detectionType === DetectionType.Object || this.detectionType === DetectionType.All)) {
+ this._onObjectListener = new io.github.triniwiz.fancycamera.ImageAnalysisCallback({
+ onSuccess(param0: string) {
+ const hasListener = ref?.get?.().hasListeners?.(MLKitView.detectionEvent);
+ if (!hasListener) {
+ return;
+ }
+ try {
+ ref?.get?.().notify?.({
+ eventName: MLKitView.detectionEvent,
+ object: ref?.get?.(),
+ data: JSON.parse(param0),
+ type: DetectionType.Object,
});
- this.#camera.setOnObjectDetectedListener(this.#onObjectListener);
- }
-
- if (!this.#onPoseListener && (this.detectionType === DetectionType.Pose || this.detectionType === DetectionType.All)) {
- this.#onPoseListener = new io.github.triniwiz.fancycamera.ImageAnalysisCallback({
- onSuccess(param0: string) {
- const hasListener = ref?.get?.().hasListeners?.(MLKitView.detectionEvent);
- if (!hasListener) {
- return;
- }
- try {
- ref?.get?.().notify?.({
- eventName: MLKitView.detectionEvent,
- object: ref?.get?.(),
- data: JSON.parse(param0),
- type: DetectionType.Pose
- });
- } catch (e) { }
- },
- onError(param0: string, param1: java.lang.Exception) {
+ } catch (e) {
+ /* empty */
+ }
+ },
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
+ onError(param0: string, param1: java.lang.Exception) {},
+ });
+ this._camera.setOnObjectDetectedListener(this._onObjectListener);
+ }
- }
+ if (!this._onPoseListener && (this.detectionType === DetectionType.Pose || this.detectionType === DetectionType.All)) {
+ this._onPoseListener = new io.github.triniwiz.fancycamera.ImageAnalysisCallback({
+ onSuccess(param0: string) {
+ const hasListener = ref?.get?.().hasListeners?.(MLKitView.detectionEvent);
+ if (!hasListener) {
+ return;
+ }
+ try {
+ ref?.get?.().notify?.({
+ eventName: MLKitView.detectionEvent,
+ object: ref?.get?.(),
+ data: JSON.parse(param0),
+ type: DetectionType.Pose,
});
- this.#camera.setOnPoseDetectedListener(this.#onPoseListener);
- }
+ } catch (e) {}
+ },
+ onError(param0: string, param1: java.lang.Exception) {},
+ });
+ this._camera.setOnPoseDetectedListener(this._onPoseListener);
}
+ }
- [barcodeFormatsProperty.setNative](value: BarcodeFormats[]) {
- if (!BARCODE_SCANNER_SUPPORTED()) {
- return;
- }
- if (!this.#barcodeScannerOptions) {
- this.#barcodeScannerOptions = new io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.Options();
- }
- let formats;
- if (Array.isArray(value)) {
- if (value.indexOf(BarcodeFormats.ALL)) {
- formats = Array.create('io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner$BarcodeFormat', 1);
- formats[0] = io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.ALL;
- } else {
- formats = value.map(format => {
- switch (format) {
- case BarcodeFormats.AZTEC:
- return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.AZTEC;
- case BarcodeFormats.CODABAR:
- return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.CODABAR;
- case BarcodeFormats.CODE_128:
- return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.CODE_128;
- case BarcodeFormats.CODE_39:
- return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.CODE_39;
- case BarcodeFormats.CODE_93:
- return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.CODE_93;
- case BarcodeFormats.DATA_MATRIX:
- return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.DATA_MATRIX;
- case BarcodeFormats.EAN_13:
- return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.EAN_13;
- case BarcodeFormats.EAN_8:
- return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.EAN_8;
- case BarcodeFormats.ITF:
- return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.ITF;
- case BarcodeFormats.PDF417:
- return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.PDF417;
- case BarcodeFormats.QR_CODE:
- return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.QR_CODE;
- case BarcodeFormats.UPC_A:
- return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.UPC_A;
- case BarcodeFormats.UPC_E:
- return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.UPC_E;
- default:
- return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.ALL;
- }
- })
- }
+ [barcodeFormatsProperty.setNative](value: BarcodeFormats[]) {
+ if (!BARCODE_SCANNER_SUPPORTED()) {
+ return;
+ }
+ if (!this._barcodeScannerOptions) {
+ this._barcodeScannerOptions = new io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.Options();
+ }
+ let formats;
+ if (Array.isArray(value)) {
+ if (value.indexOf(BarcodeFormats.ALL) !== -1) {
+ formats = Array.create('io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner$BarcodeFormat', 1);
+ formats[0] = io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.ALL;
+ } else {
+ formats = value.map((format) => {
+ switch (format) {
+ case BarcodeFormats.AZTEC:
+ return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.AZTEC;
+ case BarcodeFormats.CODABAR:
+ return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.CODABAR;
+ case BarcodeFormats.CODE_128:
+ return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.CODE_128;
+ case BarcodeFormats.CODE_39:
+ return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.CODE_39;
+ case BarcodeFormats.CODE_93:
+ return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.CODE_93;
+ case BarcodeFormats.DATA_MATRIX:
+ return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.DATA_MATRIX;
+ case BarcodeFormats.EAN_13:
+ return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.EAN_13;
+ case BarcodeFormats.EAN_8:
+ return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.EAN_8;
+ case BarcodeFormats.ITF:
+ return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.ITF;
+ case BarcodeFormats.PDF417:
+ return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.PDF417;
+ case BarcodeFormats.QR_CODE:
+ return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.QR_CODE;
+ case BarcodeFormats.UPC_A:
+ return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.UPC_A;
+ case BarcodeFormats.UPC_E:
+ return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.UPC_E;
+ default:
+ return io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.ALL;
+ }
+ });
+ }
- this.#barcodeScannerOptions.setBarcodeFormat(formats);
- }
+ const scanner = IMAGE_PROCESSOR_Barcode();
+ this._barcodeScannerOptions.setBarcodeFormat(formats);
+ scanner.setOptions(this._barcodeScannerOptions);
+ }
+ }
- this.#getFancyCamera().setBarcodeScannerOptions(this.#barcodeScannerOptions);
+ [faceDetectionTrackingEnabledProperty.setNative](value) {
+ if (!FACE_DETECTION_SUPPORTED()) {
+ return;
+ }
+ if (!this._faceDetectionOptions) {
+ this._faceDetectionOptions = new io.github.triniwiz.fancycamera.facedetection.FaceDetection.Options();
}
- [faceDetectionTrackingEnabledProperty.setNative](value) {
- if (!FACE_DETECTION_SUPPORTED) {
- return;
- }
- if (!this.#faceDetectionOptions) {
- this.#faceDetectionOptions = new io.github.triniwiz.fancycamera.facedetection.FaceDetection.Options();
- }
+ this._faceDetectionOptions.setFaceTracking(value);
- this.#faceDetectionOptions.setFaceTracking(value);
+ const detector = IMAGE_PROCESSOR_Face();
+ detector.setOptions(this._faceDetectionOptions);
+ }
- this.#getFancyCamera().setFaceDetectionOptions(this.#faceDetectionOptions);
+ [faceDetectionMinFaceSizeProperty.setNative](value) {
+ if (!FACE_DETECTION_SUPPORTED()) {
+ return;
}
- [faceDetectionMinFaceSizeProperty.setNative](value) {
- if (!FACE_DETECTION_SUPPORTED) {
- return;
- }
-
- if (!this.#faceDetectionOptions) {
- this.#faceDetectionOptions = new io.github.triniwiz.fancycamera.facedetection.FaceDetection.Options();
- }
-
- this.#faceDetectionOptions.setMinimumFaceSize(value);
- this.#getFancyCamera().setFaceDetectionOptions(this.#faceDetectionOptions);
+ if (!this._faceDetectionOptions) {
+ this._faceDetectionOptions = new io.github.triniwiz.fancycamera.facedetection.FaceDetection.Options();
}
- [faceDetectionPerformanceModeProperty.setNative](value) {
- if (!FACE_DETECTION_SUPPORTED) {
- return;
- }
+ this._faceDetectionOptions.setMinimumFaceSize(value);
- if (!this.#faceDetectionOptions) {
- this.#faceDetectionOptions = new io.github.triniwiz.fancycamera.facedetection.FaceDetection.Options();
- }
+ const detector = IMAGE_PROCESSOR_Face();
+ detector.setOptions(this._faceDetectionOptions);
+ }
- this.#faceDetectionOptions.setMinimumFaceSize(value);
- this.#getFancyCamera().setFaceDetectionOptions(this.#faceDetectionOptions);
+ [faceDetectionPerformanceModeProperty.setNative](value) {
+ if (!FACE_DETECTION_SUPPORTED()) {
+ return;
}
- [imageLabelerConfidenceThresholdProperty.setNative](value) {
- if (!IMAGE_LABELING_SUPPORTED()) {
- return;
- }
- if (!this.#imageLabelerOptions) {
- this.#imageLabelerOptions = new io.github.triniwiz.fancycamera.imagelabeling.ImageLabeling.Options();
- }
-
- this.#imageLabelerOptions.setConfidenceThreshold(value);
- this.#getFancyCamera().setImageLabelingOptions(this.#imageLabelerOptions);
+ if (!this._faceDetectionOptions) {
+ this._faceDetectionOptions = new io.github.triniwiz.fancycamera.facedetection.FaceDetection.Options();
}
- [objectDetectionClassifyProperty.setNative](value) {
- if (!OBJECT_DETECTION_SUPPORTED()) {
- return;
- }
+ this._faceDetectionOptions.setMinimumFaceSize(value);
- if (!this.#objectDetectionOptions) {
- this.#objectDetectionOptions = new io.github.triniwiz.fancycamera.objectdetection.ObjectDetection.Options();
- }
+ const detector = IMAGE_PROCESSOR_Face();
+ detector.setOptions(this._faceDetectionOptions);
+ }
- this.#objectDetectionOptions.setClassification(value);
- this.#getFancyCamera().setObjectDetectionOptions(this.#objectDetectionOptions);
+ [imageLabelerConfidenceThresholdProperty.setNative](value) {
+ if (!IMAGE_LABELING_SUPPORTED()) {
+ return;
+ }
+ if (!this._imageLabelerOptions) {
+ this._imageLabelerOptions = new io.github.triniwiz.fancycamera.imagelabeling.ImageLabeling.Options();
}
- [objectDetectionMultipleProperty.setNative](value) {
- if (!OBJECT_DETECTION_SUPPORTED) {
- return;
- }
+ this._imageLabelerOptions.setConfidenceThreshold(value);
- if (!this.#objectDetectionOptions) {
- this.#objectDetectionOptions = new io.github.triniwiz.fancycamera.objectdetection.ObjectDetection.Options();
- }
+ const detector = IMAGE_PROCESSOR_Image();
+ detector.setOptions(this._imageLabelerOptions);
+ }
- this.#objectDetectionOptions.setMultiple(value);
- this.#getFancyCamera().setObjectDetectionOptions(this.#objectDetectionOptions);
+ [objectDetectionClassifyProperty.setNative](value) {
+ if (!OBJECT_DETECTION_SUPPORTED()) {
+ return;
}
-
- onLoaded() {
- super.onLoaded();
- this.startPreview();
+ if (!this._objectDetectionOptions) {
+ this._objectDetectionOptions = new io.github.triniwiz.fancycamera.objectdetection.ObjectDetection.Options();
}
- onUnloaded() {
- this.stopPreview();
- super.onUnloaded();
- }
+ this._objectDetectionOptions.setClassification(value);
- disposeNativeView() {
- Application.android.off('activityRequestPermissions', this.#permissionHandler);
- super.disposeNativeView();
- }
+ const detector = IMAGE_PROCESSOR_Object();
+ detector.setOptions(this._objectDetectionOptions);
+ }
- public stopPreview(): void {
- this.#camera.stopPreview();
+ [objectDetectionMultipleProperty.setNative](value) {
+ if (!OBJECT_DETECTION_SUPPORTED()) {
+ return;
}
- public toggleCamera(): void {
- this.#camera.toggleCamera();
+ if (!this._objectDetectionOptions) {
+ this._objectDetectionOptions = new io.github.triniwiz.fancycamera.objectdetection.ObjectDetection.Options();
}
- public startPreview(): void {
- this.#camera.startPreview();
- }
+ this._objectDetectionOptions.setMultiple(value);
+ const detector = IMAGE_PROCESSOR_Object();
+ detector.setOptions(this._objectDetectionOptions);
+ }
- requestCameraPermission() {
- return new Promise((resolve, reject) => {
- Application.android.once('activityRequestPermissions', (args: AndroidActivityRequestPermissionsEventData) => {
- if (this.#camera.hasCameraPermission()) {
- resolve();
- } else {
- reject();
- }
- });
- this.#camera.requestCameraPermission();
- });
- }
+ onLoaded() {
+ super.onLoaded();
+ this.startPreview();
+ }
+
+ onUnloaded() {
+ this.stopPreview();
+ super.onUnloaded();
+ }
+ disposeNativeView() {
+ Application.android.off('activityRequestPermissions', this._permissionHandler);
+ this.releaseCamera();
+ super.disposeNativeView();
+ }
- hasCameraPermission(): boolean {
- return this.#camera.hasCameraPermission();
+ private releaseCamera() {
+ if (this._camera) {
+ this._camera.release();
+ }
+ }
+
+ public stopPreview(): void {
+ this._camera.stopPreview();
+ }
+
+ public toggleCamera(): void {
+ this._camera.toggleCamera();
+ }
+
+ public startPreview(): void {
+ this._camera.startPreview();
+ }
+
+ requestCameraPermission() {
+ return new Promise((resolve, reject) => {
+ Application.android.once('activityRequestPermissions', (args: AndroidActivityRequestPermissionsEventData) => {
+ if (this._camera.hasCameraPermission()) {
+ resolve();
+ } else {
+ reject();
+ }
+ });
+ this._camera.requestCameraPermission();
+ });
+ }
+
+ hasCameraPermission(): boolean {
+ return this._camera.hasCameraPermission();
+ }
+}
+
+export function detectWithStillImage(image: any, options?: StillImageDetectionOptions) {
+ return new Promise((resolve, reject) => {
+ let nativeImage;
+ let rotation = 0;
+ if (image instanceof ImageSource) {
+ nativeImage = image.android;
+ rotation = image.rotationAngle;
+ } else if (image instanceof android.graphics.Bitmap) {
+ nativeImage = image;
+ } else {
+ reject('Please use a valid Image');
}
-}
\ No newline at end of file
+
+ let processors = []; /* None */
+ switch (options?.detectorType) {
+ case DetectionType.All:
+ processors = IMAGE_PROCESSOR_All();
+ break;
+ case DetectionType.Barcode:
+ processors = [IMAGE_PROCESSOR_Barcode()];
+ break;
+ case DetectionType.DigitalInk:
+ processors = [];
+ break;
+ case DetectionType.Face:
+ processors = [IMAGE_PROCESSOR_Face()];
+ break;
+ case DetectionType.Image:
+ processors = [IMAGE_PROCESSOR_Image()];
+ break;
+ case DetectionType.Object:
+ processors = [IMAGE_PROCESSOR_Object()];
+ break;
+ case DetectionType.Pose:
+ processors = [IMAGE_PROCESSOR_Pose()];
+ break;
+ case DetectionType.Text:
+ processors = [IMAGE_PROCESSOR_Text()];
+ break;
+ case DetectionType.Selfie:
+ processors = [IMAGE_PROCESSOR_Selfie()];
+ break;
+ default:
+ processors = [];
+ break;
+ }
+
+ io.github.triniwiz.fancycamera.ML.processImage(
+ nativeImage,
+ rotation || 0,
+ java.util.Arrays.asList(processors),
+ new io.github.triniwiz.fancycamera.ImageAnalysisCallback({
+ onSuccess(param0: any) {
+ const results = {};
+ const size = param0.size();
+ for (let i = 0; i < size; i++) {
+ const item = param0.get(i);
+ const type = item[0];
+ const result = item[1];
+ try {
+ if (type.toString() === DetectionType.Selfie) {
+ results[type] = {
+ width: result.geWidth(),
+ height: result.getHeight(),
+ buffer: (ArrayBuffer as any).from(result.getBuffer()),
+ };
+ } else {
+ results[type] = JSON.parse(result.toString());
+ }
+ } catch (e) {}
+ }
+ resolve(results);
+ },
+ onError(param0: string, param1: java.lang.Exception) {
+ reject(param0);
+ },
+ })
+ );
+ });
+}
diff --git a/packages/mlkit-core/index.d.ts b/packages/mlkit-core/index.d.ts
index 9d44c5b..d320328 100644
--- a/packages/mlkit-core/index.d.ts
+++ b/packages/mlkit-core/index.d.ts
@@ -1,17 +1,53 @@
-import { MLKitViewBase, DetectionType } from "./common";
+import { MLKitViewBase, DetectionType, BarcodeFormats } from './common';
import { EventData } from '@nativescript/core';
+
+export interface StillImageDetectionOptions {
+ detectorType: DetectionType;
+ barcodeScanning?: {
+ barcodeFormat?: [BarcodeFormats];
+ };
+ faceDetection?: {
+ faceTracking?: boolean;
+ minimumFaceSize: ?number;
+ detectionMode?: 'fast' | 'accurate';
+ landmarkMode?: 'all' | 'none';
+ contourMode?: 'all' | 'none';
+ classificationMode?: 'all' | 'none';
+ };
+ imageLabeling?: {
+ confidenceThreshold?: number;
+ };
+ objectDetection?: {
+ multiple: boolean;
+ classification: boolean;
+ };
+ selfieSegmentation?: {
+ enableRawSizeMask?: boolean;
+ smoothingRatio?: number;
+ };
+}
+
export interface DetectionEvent extends EventData {
- data: { [key: string]: any };
- type: DetectionType
+ data: { [key: string]: any } | Array<{ [key: string]: any }>;
+ type: DetectionType;
}
+
+
export { BarcodeFormats, barcodeFormatsProperty, CameraPosition, cameraPositionProperty, DetectionType, faceDetectionMinFaceSizeProperty, faceDetectionPerformanceModeProperty, faceDetectionTrackingEnabledProperty, imageLabelerConfidenceThresholdProperty as imageLablerConfidenceThresholdProperty, objectDetectionClassifyProperty, objectDetectionMultipleProperty } from './common';
export declare class MLKitView extends MLKitViewBase {
- static isAvailable(): boolean;
- static detectionEvent: string;
- stopPreview(): void;
- toggleCamera(): void;
- startPreview(): void;
- requestCameraPermission(): Promise;
- hasCameraPermission(): boolean;
- on(event: 'detection', callback: (args: DetectionEvent) => void, thisArg?: any);
+ static isAvailable(): boolean;
+ static detectionEvent: string;
+ stopPreview(): void;
+ toggleCamera(): void;
+ startPreview(): void;
+ requestCameraPermission(): Promise;
+ hasCameraPermission(): boolean;
+ on(event: 'detection', callback: (args: DetectionEvent) => void, thisArg?: any);
+ // Needed when 'on' method is overriden.
+ /**
+ * @hidden
+ */
+ on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void;
}
+
+export function detectWithStillImage(image: any, options?: StillImageDetectionOptions): Promise<{ [key: string]: any }>;
diff --git a/packages/mlkit-core/index.ios.ts b/packages/mlkit-core/index.ios.ts
index 00ad23d..974619c 100644
--- a/packages/mlkit-core/index.ios.ts
+++ b/packages/mlkit-core/index.ios.ts
@@ -1,407 +1,847 @@
-import { Utils } from "@nativescript/core";
-import { BarcodeFormats, barcodeFormatsProperty, CameraPosition, cameraPositionProperty, DetectionType, detectionTypeProperty, faceDetectionMinFaceSizeProperty, faceDetectionPerformanceModeProperty, faceDetectionTrackingEnabledProperty, imageLabelerConfidenceThresholdProperty, MLKitViewBase, objectDetectionClassifyProperty, objectDetectionMultipleProperty } from "./common";
-import '@nativescript/core';
-import lazy from "@nativescript/core/utils/lazy";
-import { DetectionEvent } from ".";
+import {
+ BarcodeFormats,
+ barcodeFormatsProperty,
+ CameraPosition,
+ cameraPositionProperty,
+ DetectionType,
+ detectionTypeProperty,
+ faceDetectionMinFaceSizeProperty,
+ faceDetectionPerformanceModeProperty,
+ faceDetectionTrackingEnabledProperty,
+ imageLabelerConfidenceThresholdProperty,
+ MLKitViewBase,
+ objectDetectionClassifyProperty,
+ objectDetectionMultipleProperty,
+ pauseProperty,
+ processEveryNthFrameProperty,
+ torchOnProperty,
+ aspectRatioProperty,
+ retrieveLatestImageProperty,
+ customObjectDetectionMaximumNumLabelsProperty,
+ customObjectDetectionConfidenceThresholdProperty,
+ customObjectDetectionModelNameProperty,
+ customObjectDetectionClassifyProperty,
+ customObjectDetectionMultipleProperty,
+ TNSObjectDetectionResult,
+ BoundingBoxSettings,
+ boundingBoxSettingsProperty,
+ DEFAULT_BOUNDING_BOX_SETTINGS,
+} from './common';
+import { Color, File, ImageSource, Utils } from '@nativescript/core';
+import lazy from '@nativescript/core/utils/lazy';
+import { DetectionEvent, StillImageDetectionOptions } from '.';
+
+const BARCODE_SCANNER_SUPPORTED = lazy(() => typeof MLKBarcodeScanner !== 'undefined');
+const TEXT_RECOGNITION_SUPPORTED = lazy(() => typeof MLKTextRecognizer !== 'undefined');
+const FACE_DETECTION_SUPPORTED = lazy(() => typeof MLKFaceDetector !== 'undefined');
+const IMAGE_LABELING_SUPPORTED = lazy(() => typeof MLKImageLabeler !== 'undefined');
+const OBJECT_DETECTION_SUPPORTED = lazy(() => typeof MLKObjectDetector !== 'undefined');
+const POSE_DETECTION_SUPPORTED = lazy(() => typeof MLKPoseDetector !== 'undefined');
+const DIGITALINK_RECOGNITION_SUPPORTED = lazy(() => typeof MLKDigitalInkRecognizer !== 'undefined');
+const SELFIE_SEGMENTATION_SUPPORTED = lazy(() => typeof MLKSegmenter !== 'undefined');
+
+export { BarcodeFormats, barcodeFormatsProperty, CameraPosition, cameraPositionProperty, DetectionType, faceDetectionMinFaceSizeProperty, faceDetectionPerformanceModeProperty, faceDetectionTrackingEnabledProperty, imageLabelerConfidenceThresholdProperty as imageLablerConfidenceThresholdProperty, objectDetectionClassifyProperty, objectDetectionMultipleProperty, customObjectDetectionMaximumNumLabelsProperty, customObjectDetectionConfidenceThresholdProperty, customObjectDetectionModelNameProperty, customObjectDetectionClassifyProperty, customObjectDetectionMultipleProperty } from './common';
+declare const TNSMLKitHelper, TNSMLKitHelperCameraPosition;
-const BARCODE_SCANNER_SUPPORTED = lazy(() => typeof MLKBarcodeScanner);
-const TEXT_RECOGNITION_SUPPORTED = lazy(() => typeof MLKTextRecognizer);
-const FACE_DETECTION_SUPPORTED = lazy(() => typeof MLKFaceDetector);
-const IMAGE_LABELING_SUPPORTED = lazy(() => typeof MLKImageLabeler);
-const OBJECT_DETECTION_SUPPORTED = lazy(() => typeof MLKObjectDetector);
-const POSE_DETECTION_SUPPORTED = lazy(() => typeof MLKPoseDetector);
-const DIGITALINK_RECOGNITION_SUPPORTED = lazy(() => typeof MLKDigitalInkRecognizer);
-
-export { BarcodeFormats, barcodeFormatsProperty, CameraPosition, cameraPositionProperty, DetectionType, faceDetectionMinFaceSizeProperty, faceDetectionPerformanceModeProperty, faceDetectionTrackingEnabledProperty, imageLabelerConfidenceThresholdProperty as imageLablerConfidenceThresholdProperty, objectDetectionClassifyProperty, objectDetectionMultipleProperty } from './common';
-
+function getGravity(value) {
+ switch (value) {
+ case 'fill':
+ return AVLayerVideoGravityResize;
+ case 'aspectFill':
+ return AVLayerVideoGravityResizeAspectFill;
+ case 'aspect':
+ return AVLayerVideoGravityResizeAspect;
+ }
+ return null;
+}
-declare const TNSMLKitHelper, TNSMLKitHelperCameraPosition;
+function detectionTypeToNative(detectionType: DetectionType) {
+ switch (detectionType) {
+ case DetectionType.All:
+ return TNSMLKitDetectionType.All;
+ case DetectionType.Barcode:
+ return TNSMLKitDetectionType.Barcode;
+ case DetectionType.DigitalInk:
+ return TNSMLKitDetectionType.DigitalInk;
+ case DetectionType.Face:
+ return TNSMLKitDetectionType.Face;
+ case DetectionType.Image:
+ return TNSMLKitDetectionType.Image;
+ case DetectionType.Object:
+ return TNSMLKitDetectionType.Object;
+ case DetectionType.CustomObject:
+ return TNSMLKitDetectionType.CustomObject;
+ case DetectionType.Pose:
+ return TNSMLKitDetectionType.Pose;
+ case DetectionType.Text:
+ return TNSMLKitDetectionType.Text;
+ case DetectionType.Selfie:
+ return TNSMLKitDetectionType.Selfie;
+ default:
+ return TNSMLKitDetectionType.None;
+ }
+}
export class MLKitView extends MLKitViewBase {
- #device: AVCaptureDevice;
- #preview: AVCaptureVideoPreviewLayer;
- #textRecognizer: MLKTextRecognizer;
- #barcodeScanner: MLKBarcodeScanner;
- #digitalInkRecognizer: MLKDigitalInkRecognizer;
- #faceDetector: MLKFaceDetector;
- #imageLabeler: MLKImageLabeler;
- #objectDetector: MLKObjectDetector;
- #poseDetector: MLKPoseDetector;
- #barcodeScannerOptions: MLKBarcodeScannerOptions;
- #faceDetectorOptions: MLKFaceDetectorOptions;
- #imageLabelerOptions: MLKImageLabelerOptions;
- #objectDetectionOptions: MLKObjectDetectorOptions;
- #poseDetectionOptions: MLKPoseDetectorOptions;
- #mlkitHelper;
-
- constructor() {
- super();
- this.#mlkitHelper = TNSMLKitHelper.alloc().init();
- this.#mlkitHelper.onScanCallback = this._onScanCallback;
+ _device: AVCaptureDevice;
+ _preview: AVCaptureVideoPreviewLayer;
+ _textRecognizer: MLKTextRecognizer;
+ _barcodeScanner: MLKBarcodeScanner;
+ _digitalInkRecognizer: MLKDigitalInkRecognizer;
+ _faceDetector: MLKFaceDetector;
+ _imageLabeler: MLKImageLabeler;
+ _objectDetector: MLKObjectDetector;
+ _customObjectDetector: MLKObjectDetector;
+ _localModel: MLKLocalModel;
+ _poseDetector: MLKPoseDetector;
+ _selfieSegmentor: MLKSegmenter;
+ _barcodeScannerOptions: MLKBarcodeScannerOptions;
+ _faceDetectorOptions: MLKFaceDetectorOptions;
+ _imageLabelerOptions: MLKImageLabelerOptions;
+ _objectDetectionOptions: MLKObjectDetectorOptions;
+ _customObjectDetectionOptions: MLKCustomObjectDetectorOptions;
+ _poseDetectionOptions: MLKPoseDetectorOptions;
+ _selfieSegmentationOptions: MLKSelfieSegmenterOptions;
+ _overlayLayer: CALayer;
+ _boundingBoxSettings: BoundingBoxSettings;
+
+ _mlkitHelper: TNSMLKitHelper;
+ _onScanCallback: (result: any, type) => void;
+
+ constructor() {
+ super();
+ this._mlkitHelper = TNSMLKitHelper.alloc().init();
+
+ const ref = new WeakRef(this);
+ const _onScanCallback = (result: any, type) => {
+ const owner = ref.deref();
+ if (owner) {
+ if (owner.detectionType === DetectionType.None || !owner.hasListeners?.(MLKitView.detectionEvent)) {
+ return;
+ }
+ try {
+ let data = JSON.parse(result);
+ if (owner.detectionType === DetectionType.Object || owner.detectionType === DetectionType.CustomObject) {
+ if (owner._boundingBoxSettings?.drawBBoxes || owner._boundingBoxSettings?.drawEdgeMarks) {
+ owner.drawBoundingBoxes(data);
+ }
+ }
+ owner.notify({
+ eventName: MLKitView.detectionEvent,
+ object: owner,
+ data,
+ type,
+ });
+ } catch (e) {}
+ }
+ };
+
+ this._onScanCallback = _onScanCallback;
+ this._mlkitHelper.onScanCallback = _onScanCallback;
+ }
+
+ createNativeView() {
+ const nativeView = UIView.new();
+ this._preview = AVCaptureVideoPreviewLayer.layerWithSession(this._mlkitHelper.session);
+ this._preview.videoGravity = getGravity(this.aspectRatio) ?? AVLayerVideoGravityResizeAspect;
+ nativeView.layer.insertSublayerAtIndex(this._preview, 0);
+
+ this._overlayLayer = CALayer.layer();
+ this._overlayLayer.frame = nativeView.bounds;
+ nativeView.layer.addSublayer(this._overlayLayer);
+
+ return nativeView;
+ }
+
+ [retrieveLatestImageProperty.setNative](value: boolean) {
+ if (!this._mlkitHelper) {
+ return;
}
+ this._mlkitHelper.retrieveLatestImage = value;
+ }
- createNativeView() {
- const nativeView = UIView.new();
- this.#preview = AVCaptureVideoPreviewLayer.layerWithSession(this.#mlkitHelper.session);
- this.#preview.videoGravity = AVLayerVideoGravityResizeAspect;
- nativeView.layer.insertSublayerAtIndex(this.#preview, 0);
- return nativeView;
- }
+ _latestImage: ImageSource = null;
- get _device() {
- return this.#device;
+ //@ts-ignore
+ get latestImage(): ImageSource {
+ if (!this._mlkitHelper) {
+ return null;
}
- get _textRecognizer(): MLKTextRecognizer {
- return this.#textRecognizer;
+ const image = this._mlkitHelper.latestImage;
+ if (!image) {
+ return null;
}
- get _barcodeScanner(): MLKBarcodeScanner {
- return this.#barcodeScanner;
+ if (image !== this._latestImage?.ios) {
+ this._latestImage = new ImageSource(image);
}
- get _digitalInkRecognizer(): MLKDigitalInkRecognizer {
- return this.#digitalInkRecognizer;
- }
+ return this._latestImage;
+ }
- get _faceDetector(): MLKFaceDetector {
- return this.#faceDetector;
- }
+ initNativeView() {
+ super.initNativeView();
+ this._setupDetectors();
+ }
- get _imageLabeler(): MLKImageLabeler {
- return this.#imageLabeler;
+ [aspectRatioProperty.setNative](ratio) {
+ if (this._preview) {
+ switch (ratio) {
+ case 'fill':
+ case 'aspectFill':
+ case 'aspect':
+ this._preview.videoGravity = getGravity(ratio);
+ break;
+ }
}
+ }
- get _objectDetector(): MLKObjectDetector {
- return this.#objectDetector;
+ // @ts-ignore
+ [cameraPositionProperty.setNative](value: CameraPosition) {
+ switch (value) {
+ case CameraPosition.FRONT:
+ this._mlkitHelper.cameraPosition = TNSMLKitHelperCameraPosition.FRONT;
+ break;
+ case CameraPosition.BACK:
+ this._mlkitHelper.cameraPosition = TNSMLKitHelperCameraPosition.BACK;
+ break;
+ default:
+ break;
}
- get _poseDetector(): MLKPoseDetector {
- return this.#poseDetector;
+ }
+
+ public static isAvailable() {
+ return UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera);
+ }
+
+ [torchOnProperty.setNative](value: boolean) {
+ if (value) {
+ this._mlkitHelper.torchMode = TNSMLKitTorchMode.On;
+ } else {
+ this._mlkitHelper.torchMode = TNSMLKitTorchMode.Off;
}
+ }
+ [pauseProperty.setNative](value: boolean) {
+ this._mlkitHelper.pause = value;
+ }
- [cameraPositionProperty.setNative](value: CameraPosition) {
- switch (value) {
- case CameraPosition.FRONT:
- this.#mlkitHelper.cameraPosition = TNSMLKitHelperCameraPosition.FRONT;
- break;
- case CameraPosition.BACK:
- this.#mlkitHelper.cameraPosition = TNSMLKitHelperCameraPosition.BACK;
- break;
- default:
- break;
- }
+ [detectionTypeProperty.setNative](value) {
+ const type = detectionTypeToNative(value);
+ this._setupDetectors();
+ this._mlkitHelper.detectorType = type;
+ }
+
+ [processEveryNthFrameProperty.setNative](value) {
+ if (this._mlkitHelper) {
+ this._mlkitHelper.processEveryNthFrame = value;
}
+ }
- public static isAvailable() {
- return UIImagePickerController.isSourceTypeAvailable(
- UIImagePickerControllerSourceType.Camera
- );
- }
-
-
- [detectionTypeProperty.setNative](value) {
- let type = 8 /* None */
- switch (value) {
- case DetectionType.All:
- type = 7;
- break;
- case DetectionType.Barcode:
- type = 0;
- break;
- case DetectionType.DigitalInk:
- type = 1
- break;
- case DetectionType.Face:
- type = 2
- break;
- case DetectionType.Image:
- type = 3
- break;
- case DetectionType.Object:
- type = 4
- break;
- case DetectionType.Pose:
- type = 5
- break;
- case DetectionType.Text:
- type = 6
- break;
+ _setupDetectors() {
+ if (!this._textRecognizer && (this.detectionType === DetectionType.Text || this.detectionType === DetectionType.All)) {
+ if (TEXT_RECOGNITION_SUPPORTED()) {
+ this._textRecognizer = MLKTextRecognizer.textRecognizer();
+ this._mlkitHelper.textRecognizer = this._textRecognizer;
+ }
+ }
+
+ if (!this._barcodeScanner && (this.detectionType === DetectionType.Barcode || this.detectionType === DetectionType.All)) {
+ this._setupBarcodeScanner(this.barcodeFormats);
+ }
+
+ // TODO
+ if (!this._digitalInkRecognizer && (this.detectionType === DetectionType.DigitalInk || this.detectionType === DetectionType.All)) {
+ // MLKDigitalInkRecognizer.digitalInkRecognizerWithOptions()
+ }
+
+ if (!this._faceDetector && (this.detectionType === DetectionType.Face || this.detectionType === DetectionType.All)) {
+ this._setupFaceDetector();
+ }
+
+ if (!this._imageLabeler && (this.detectionType === DetectionType.Image || this.detectionType === DetectionType.All)) {
+ this._setImageLabeler();
+ }
+
+ if (!this._objectDetector && (this.detectionType === DetectionType.Object || this.detectionType === DetectionType.All)) {
+ this._setupObjectDetection();
+ }
+
+ if (!this._customObjectDetector && (this.detectionType === DetectionType.CustomObject || this.detectionType === DetectionType.All)) {
+ this._setupCustomObjectDetection();
+ }
+
+ if (!this._poseDetector && (this.detectionType === DetectionType.Pose || this.detectionType === DetectionType.All)) {
+ this._setPoseDetection();
+ }
+
+ if (!this._selfieSegmentor && (this.detectionType === DetectionType.Selfie || this.detectionType === DetectionType.All)) {
+ this._setSelfieSegmentation();
+ }
+ }
+
+ _setSelfieSegmentation() {
+ if (!SELFIE_SEGMENTATION_SUPPORTED()) {
+ return;
+ }
+
+ if (!this._selfieSegmentationOptions) {
+ this._selfieSegmentationOptions = MLKSelfieSegmenterOptions.new();
+ }
+
+ this._selfieSegmentationOptions.shouldEnableRawSizeMask = true;
+ this._selfieSegmentor = MLKSegmenter.segmenterWithOptions(this._selfieSegmentationOptions);
+ this._mlkitHelper.selfieSegmentor = this._selfieSegmentor;
+ }
+
+ // @ts-ignore
+ [barcodeFormatsProperty.setNative](value: BarcodeFormats[]) {
+ this._setupBarcodeScanner(value);
+ }
+
+ _setupBarcodeScanner(value) {
+ if (!BARCODE_SCANNER_SUPPORTED()) {
+ return;
+ }
+ let formats: MLKBarcodeFormat = 0;
+ if (Array.isArray(value)) {
+ if (value.indexOf(BarcodeFormats.ALL) !== -1) {
+ formats = MLKBarcodeFormat.All;
+ } else {
+ value.forEach((format) => {
+ switch (format) {
+ case BarcodeFormats.AZTEC:
+ formats |= MLKBarcodeFormat.Aztec;
+ break;
+ case BarcodeFormats.CODABAR:
+ formats |= MLKBarcodeFormat.CodaBar;
+ break;
+ case BarcodeFormats.CODE_128:
+ formats |= MLKBarcodeFormat.Code128;
+ break;
+ case BarcodeFormats.CODE_39:
+ formats |= MLKBarcodeFormat.Code39;
+ break;
+ case BarcodeFormats.CODE_93:
+ formats |= MLKBarcodeFormat.Code93;
+ break;
+ case BarcodeFormats.DATA_MATRIX:
+ formats |= MLKBarcodeFormat.DataMatrix;
+ break;
+ case BarcodeFormats.EAN_13:
+ formats |= MLKBarcodeFormat.EAN13;
+ break;
+ case BarcodeFormats.EAN_8:
+ formats |= MLKBarcodeFormat.EAN8;
+ break;
+ case BarcodeFormats.ITF:
+ formats |= MLKBarcodeFormat.ITF;
+ break;
+ case BarcodeFormats.PDF417:
+ formats |= MLKBarcodeFormat.PDF417;
+ break;
+ case BarcodeFormats.QR_CODE:
+ formats |= MLKBarcodeFormat.QRCode;
+ break;
+ case BarcodeFormats.UPC_A:
+ formats |= MLKBarcodeFormat.UPCA;
+ break;
+ case BarcodeFormats.UPC_E:
+ formats |= MLKBarcodeFormat.UPCE;
+ break;
default:
- type = 8;
- break;
- }
-
- this.#setupDetectors();
- this.#mlkitHelper.detectorType = type;
+ formats |= MLKBarcodeFormat.All;
+ break;
+ }
+ });
+ }
+ }
+ if (!formats) {
+ formats = MLKBarcodeFormat.All;
}
+ this._barcodeScannerOptions = MLKBarcodeScannerOptions.alloc().initWithFormats(formats);
+ this._barcodeScanner = MLKBarcodeScanner.barcodeScannerWithOptions(this._barcodeScannerOptions);
+ this._mlkitHelper.barcodeScanner = this._barcodeScanner;
+ }
- #setupDetectors() {
- if (TEXT_RECOGNITION_SUPPORTED() && !this.#textRecognizer && (this.detectionType === DetectionType.Text || this.detectionType === DetectionType.All)) {
- this.#textRecognizer = MLKTextRecognizer.textRecognizer();
- this.#mlkitHelper.textRecognizer = this.#textRecognizer;
- }
+ [faceDetectionTrackingEnabledProperty.setNative](value) {
+ this._setupFaceDetector();
+ }
- if (BARCODE_SCANNER_SUPPORTED() && !this.#barcodeScanner && (this.detectionType === DetectionType.Barcode || this.detectionType === DetectionType.All)) {
- this.#setupBarcodeScanner(this.barcodeFormats);
- }
+ [faceDetectionMinFaceSizeProperty.setNative](value) {
+ this._setupFaceDetector();
+ }
- // TODO
- if (DIGITALINK_RECOGNITION_SUPPORTED() && !this.#digitalInkRecognizer && (this.detectionType === DetectionType.DigitalInk || this.detectionType === DetectionType.All)) {
- // MLKDigitalInkRecognizer.digitalInkRecognizerWithOptions()
- }
+ [faceDetectionPerformanceModeProperty.setNative](value) {
+ this._setupFaceDetector();
+ }
+ _setupFaceDetector() {
+ if (!FACE_DETECTION_SUPPORTED()) {
+ return;
+ }
- if (FACE_DETECTION_SUPPORTED() && !this.#faceDetector && (this.detectionType === DetectionType.Face || this.detectionType === DetectionType.All)) {
- this.#setupFaceDetector();
- }
+ if (!this._faceDetectorOptions) {
+ this._faceDetectorOptions = MLKFaceDetectorOptions.new();
+ }
- if (IMAGE_LABELING_SUPPORTED() && !this.#imageLabeler && (this.detectionType === DetectionType.Image || this.detectionType === DetectionType.All)) {
- this.#setImageLabeler()
- }
+ this._faceDetectorOptions.landmarkMode = MLKFaceDetectorLandmarkModeAll;
+ this._faceDetectorOptions.classificationMode = MLKFaceDetectorClassificationModeAll;
+ this._faceDetectorOptions.performanceMode = this.faceDetectionPerformanceMode === 'accurate' ? (this._faceDetectorOptions.performanceMode = MLKFaceDetectorPerformanceModeAccurate) : (this._faceDetectorOptions.performanceMode = MLKFaceDetectorPerformanceModeFast);
+ this._faceDetectorOptions.trackingEnabled = this.faceDetectionTrackingEnabled;
+ this._faceDetectorOptions.minFaceSize = this.faceDetectionMinFaceSize;
+ this._faceDetector = MLKFaceDetector.faceDetectorWithOptions(this._faceDetectorOptions);
+ this._mlkitHelper.faceDetector = this._faceDetector;
+ }
- if (OBJECT_DETECTION_SUPPORTED() && !this.#objectDetector && (this.detectionType === DetectionType.Object || this.detectionType === DetectionType.All)) {
- this.#setupObjectDetection();
- }
+ [imageLabelerConfidenceThresholdProperty.setNative](value) {
+ this._setImageLabeler();
+ }
- if (POSE_DETECTION_SUPPORTED() && !this.#poseDetector && (this.detectionType === DetectionType.Pose || this.detectionType === DetectionType.All)) {
- this.#setPoseDetection();
- }
+ _setImageLabeler() {
+ if (!IMAGE_LABELING_SUPPORTED()) {
+ return;
}
-
-
- initNativeView() {
- super.initNativeView();
- this.#setupDetectors();
+ if (!this._imageLabelerOptions) {
+ this._imageLabelerOptions = MLKImageLabelerOptions.new();
}
+ this._imageLabelerOptions.confidenceThreshold = this.imageLabelerConfidenceThreshold;
+ this._imageLabeler = MLKImageLabeler.imageLabelerWithOptions(this._imageLabelerOptions);
+ this._mlkitHelper.imageLabeler = this._imageLabeler;
+ }
- _onScanCallback(result: string, type) {
- if (this.detectionType === DetectionType.None || !this.hasListeners(MLKitView.detectionEvent)) {
- return;
- }
- try {
- const data = JSON.parse(result);
- this.notify({
- eventName: MLKitView.detectionEvent,
- object: this,
- data,
- type
- })
- } catch (e) { }
- }
+ [objectDetectionClassifyProperty.setNative](value) {
+ this._setupObjectDetection();
+ }
+ [objectDetectionMultipleProperty.setNative](value) {
+ this._setupObjectDetection();
+ }
- [barcodeFormatsProperty.setNative](value: BarcodeFormats[]) {
- this.#setupBarcodeScanner(value);
+ _setupObjectDetection() {
+ if (!OBJECT_DETECTION_SUPPORTED()) {
+ return;
}
-
- #setupBarcodeScanner(value) {
- if (!BARCODE_SCANNER_SUPPORTED()) {
- return;
- }
- let formats: MLKBarcodeFormat = 0;
- if (Array.isArray(value)) {
- if (value.indexOf(BarcodeFormats.ALL)) {
- formats = MLKBarcodeFormat.All;
- } else {
- value.forEach(format => {
- switch (format) {
- case BarcodeFormats.AZTEC:
- formats |= MLKBarcodeFormat.Aztec;
- break;
- case BarcodeFormats.CODABAR:
- formats |= MLKBarcodeFormat.CodaBar;
- break;
- case BarcodeFormats.CODE_128:
- formats |= MLKBarcodeFormat.Code128;
- break;
- case BarcodeFormats.CODE_39:
- formats |= MLKBarcodeFormat.Code39;
- break;
- case BarcodeFormats.CODE_93:
- formats |= MLKBarcodeFormat.Code93;
- break;
- case BarcodeFormats.DATA_MATRIX:
- formats |= MLKBarcodeFormat.DataMatrix;
- break;
- case BarcodeFormats.EAN_13:
- formats |= MLKBarcodeFormat.EAN13;
- break;
- case BarcodeFormats.EAN_8:
- formats |= MLKBarcodeFormat.EAN8;
- break;
- case BarcodeFormats.ITF:
- formats |= MLKBarcodeFormat.ITF;
- break;
- case BarcodeFormats.PDF417:
- formats |= MLKBarcodeFormat.PDF417;
- break;
- case BarcodeFormats.QR_CODE:
- formats |= MLKBarcodeFormat.QRCode;
- break;
- case BarcodeFormats.UPC_A:
- formats |= MLKBarcodeFormat.UPCA;
- break;
- case BarcodeFormats.UPC_E:
- formats |= MLKBarcodeFormat.UPCE;
- break;
- default:
- formats |= MLKBarcodeFormat.All;
- break;
- }
- });
- }
- }
- if (!formats) {
- formats = MLKBarcodeFormat.All;
- }
-
- this.#barcodeScannerOptions = MLKBarcodeScannerOptions.alloc().initWithFormats(formats);
- this.#barcodeScanner = MLKBarcodeScanner.barcodeScannerWithOptions(this.#barcodeScannerOptions);
- this.#mlkitHelper.barcodeScanner = this.#barcodeScanner;
+ if (!this._objectDetectionOptions) {
+ this._objectDetectionOptions = MLKObjectDetectorOptions.new();
}
- [faceDetectionTrackingEnabledProperty.setNative](value) {
- this.#setupFaceDetector();
- }
+ this._objectDetectionOptions.detectorMode = MLKObjectDetectorModeStream;
- [faceDetectionMinFaceSizeProperty.setNative](value) {
- this.#setupFaceDetector();
- }
+ this._objectDetectionOptions.shouldEnableMultipleObjects = this.objectDetectionMultiple;
+ this._objectDetectionOptions.shouldEnableClassification = this.objectDetectionClassify;
- [faceDetectionPerformanceModeProperty.setNative](value) {
- this.#setupFaceDetector();
- }
+ this._objectDetector = MLKObjectDetector.objectDetectorWithOptions(this._objectDetectionOptions);
+ this._mlkitHelper.objectDetector = this._objectDetector;
+ }
- #setupFaceDetector() {
- if (!FACE_DETECTION_SUPPORTED) {
- return;
- }
+ [customObjectDetectionModelNameProperty.setNative](value) {
+ this._setupCustomObjectDetection();
+ }
- if (!this.#faceDetectorOptions) {
- this.#faceDetectorOptions = MLKFaceDetectorOptions.new();
- }
+ [customObjectDetectionClassifyProperty.setNative](value) {
+ this._setupCustomObjectDetection();
+ }
- this.#faceDetectorOptions.landmarkMode = MLKFaceDetectorLandmarkModeAll;
- this.#faceDetectorOptions.classificationMode = MLKFaceDetectorClassificationModeAll;
- this.#faceDetectorOptions.performanceMode = this.faceDetectionPerformanceMode === 'accurate' ? this.#faceDetectorOptions.performanceMode = MLKFaceDetectorPerformanceModeAccurate : this.#faceDetectorOptions.performanceMode = MLKFaceDetectorPerformanceModeFast;
- this.#faceDetectorOptions.trackingEnabled = this.faceDetectionTrackingEnabled;
- this.#faceDetectorOptions.minFaceSize = this.faceDetectionMinFaceSize;
- this.#faceDetector = MLKFaceDetector.faceDetectorWithOptions(this.#faceDetectorOptions);
- this.#mlkitHelper.faceDetector = this.#faceDetector;
- }
+ [customObjectDetectionMultipleProperty.setNative](value) {
+ this._setupCustomObjectDetection();
+ }
- [imageLabelerConfidenceThresholdProperty.setNative](value) {
- this.#setImageLabeler();
- }
+ [customObjectDetectionMaximumNumLabelsProperty.setNative](value) {
+ this._setupCustomObjectDetection();
+ }
- #setImageLabeler() {
- if (!IMAGE_LABELING_SUPPORTED) {
- return;
- }
- if (!this.#imageLabelerOptions) {
- this.#imageLabelerOptions = MLKImageLabelerOptions.new();
- }
- this.#imageLabelerOptions.confidenceThreshold = this.imageLabelerConfidenceThreshold;
- this.#imageLabeler = MLKImageLabeler.imageLabelerWithOptions(this.#imageLabelerOptions);
- this.#mlkitHelper.imageLabeler = this.#imageLabeler;
- }
+ [customObjectDetectionConfidenceThresholdProperty.setNative](value) {
+ this._setupCustomObjectDetection();
+ }
+ [boundingBoxSettingsProperty.setNative](value) {
+ this._boundingBoxSettings = { ...DEFAULT_BOUNDING_BOX_SETTINGS, ...(value as BoundingBoxSettings) };
+ }
- [objectDetectionClassifyProperty.setNative](value) {
- this.#setupObjectDetection();
+ _setupCustomObjectDetection() {
+ if (!OBJECT_DETECTION_SUPPORTED()) {
+ return;
}
- [objectDetectionMultipleProperty.setNative](value) {
- this.#setupObjectDetection();
+ if (this.customObjectDetectionModelName !== this.customObjectDetectionLoadedModel) {
+ // Construct the model file path
+ const modelFilePath = NSBundle.mainBundle.pathForResourceOfType(this.customObjectDetectionModelName, 'tflite');
+ if (File.exists(modelFilePath)) {
+ this._localModel = MLKLocalModel.alloc().initWithPath(modelFilePath);
+ this.customObjectDetectionLoadedModel = this.customObjectDetectionModelName;
+ this._customObjectDetectionOptions = MLKCustomObjectDetectorOptions.alloc().initWithLocalModel(this._localModel);
+ } else {
+ console.error('TFLite model file not found.');
+ }
}
-
- #setupObjectDetection() {
- if (!OBJECT_DETECTION_SUPPORTED) {
- return;
- }
- if (!this.#objectDetectionOptions) {
- this.#objectDetectionOptions = MLKObjectDetectorOptions.new();
- }
-
- this.#objectDetectionOptions.detectorMode = MLKObjectDetectorModeStream;
-
- this.#objectDetectionOptions.shouldEnableMultipleObjects = this.objectDetectionMultiple;
- this.#objectDetectionOptions.shouldEnableClassification = this.objectDetectionClassify;
-
- this.#objectDetector = MLKObjectDetector.objectDetectorWithOptions(this.#objectDetectionOptions);
- this.#mlkitHelper.objectDetector = this.#objectDetector;
+ if (this._customObjectDetectionOptions) {
+ this._customObjectDetectionOptions.detectorMode = MLKObjectDetectorModeStream;
+ this._customObjectDetectionOptions.shouldEnableMultipleObjects = this.customObjectDetectionMultiple;
+ this._customObjectDetectionOptions.shouldEnableClassification = this.customObjectDetectionClassify;
+ if (this.customObjectDetectionConfidenceThreshold != null) {
+ this._customObjectDetectionOptions.classificationConfidenceThreshold = this.customObjectDetectionConfidenceThreshold;
+ }
+ this._customObjectDetectionOptions.maxPerObjectLabelCount = this.customObjectDetectionMaximumNumLabels;
+ this._customObjectDetector = MLKObjectDetector.objectDetectorWithOptions(this._customObjectDetectionOptions);
+ this._mlkitHelper.customObjectDetector = this._customObjectDetector;
+ }
+ }
+
+ _setPoseDetection() {
+ if (!POSE_DETECTION_SUPPORTED()) {
+ return;
+ }
+ if (!this._poseDetectionOptions) {
+ this._poseDetectionOptions = MLKPoseDetectorOptions.new();
}
+ this._poseDetectionOptions.detectorMode = 1; // MLKPoseDetectorModeStream;
- #setPoseDetection() {
- if (!POSE_DETECTION_SUPPORTED) {
- return;
- }
- if (!this.#poseDetectionOptions) {
- this.#poseDetectionOptions = MLKPoseDetectorOptions.new();
- }
+ this._poseDetector = MLKPoseDetector.poseDetectorWithOptions(this._poseDetectionOptions);
- this.#poseDetectionOptions.detectorMode = 1; // MLKPoseDetectorModeStream;
+ this._mlkitHelper.poseDetector = this._poseDetector;
+ }
- this.#poseDetector = MLKPoseDetector.poseDetectorWithOptions(this.#poseDetectionOptions);
+ onLoaded() {
+ super.onLoaded();
+ this.startPreview();
+ }
- this.#mlkitHelper.poseDetector = this.#poseDetector;
- }
+ onUnloaded() {
+ this.stopPreview();
+ super.onUnloaded();
+ }
- onLoaded() {
- super.onLoaded();
- this.startPreview();
- }
+ public stopPreview(): void {
+ this._mlkitHelper.stopPreview();
+ }
- onUnloaded() {
- this.stopPreview();
- super.onUnloaded();
- }
-
- public stopPreview(): void {
- this.#mlkitHelper.stopPreview();
- }
+ public toggleCamera(): void {
+ this._mlkitHelper.toggleCamera();
+ }
- public toggleCamera(): void {
- this.#mlkitHelper.toggleCamera();
+ public startPreview(): void {
+ this._mlkitHelper.openCamera();
+ if (!this.pause) {
+ this._mlkitHelper.startPreview();
}
+ }
+
+ public onLayout(left: number, top: number, right: number, bottom: number) {
+ if (this._preview && this.nativeView) {
+ this._preview.frame = this.nativeView.bounds;
+ }
+ if (this._overlayLayer && this.nativeView) {
+ this._overlayLayer.frame = this.nativeView.bounds;
+ }
+ }
+
+ public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number) {
+ const width = Utils.layout.getMeasureSpecSize(widthMeasureSpec);
+ const height = Utils.layout.getMeasureSpecSize(heightMeasureSpec);
+ this.setMeasuredDimension(width, height);
+ }
+
+ requestCameraPermission() {
+ return new Promise((resolve, reject) => {
+ AVCaptureDevice.requestAccessForMediaTypeCompletionHandler(AVMediaTypeVideo, (cameraPermissionStatus) => {
+ if (cameraPermissionStatus) {
+ this.startPreview();
+ resolve();
+ } else {
+ reject();
+ }
+ });
+ });
+ }
+
+ hasCameraPermission(): boolean {
+ return AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo) === AVAuthorizationStatus.Authorized;
+ }
+
+ private adjustBoundingBoxForVideoGravity(x: number, y: number, width: number, height: number, imageWidth: number, imageHeight: number, imageOrientation: number, displayedWidth: number, displayedHeight: number, videoGravity: string): { x: number; y: number; width: number; height: number } {
+ let scaleX = 1;
+ let scaleY = 1;
+ let offsetX = 0;
+ let offsetY = 0;
+
+ // Handle orientation-specific adjustments
+ let adjustedImageWidth = imageWidth;
+ let adjustedImageHeight = imageHeight;
+
+ if ([2, 3, 6, 7].includes(imageOrientation)) {
+ adjustedImageWidth = imageHeight;
+ adjustedImageHeight = imageWidth;
+ }
+
+ // Determine scaling and offsets based on video gravity
+ const imageAspectRatio = adjustedImageWidth / adjustedImageHeight;
+ const viewAspectRatio = displayedWidth / displayedHeight;
+
+ switch (videoGravity) {
+ case 'AVLayerVideoGravityResizeAspect': {
+ // 'aspect'
+ if (imageAspectRatio > viewAspectRatio) {
+ // Letterboxing on the top and bottom
+ scaleX = displayedWidth / adjustedImageWidth;
+ scaleY = scaleX;
+ offsetY = (displayedHeight - adjustedImageHeight * scaleY) / 2;
+ } else {
+ // Letterboxing on the left and right
+ scaleY = displayedHeight / adjustedImageHeight;
+ scaleX = scaleY;
+ offsetX = (displayedWidth - adjustedImageWidth * scaleX) / 2;
+ }
+ break;
+ }
+ case 'AVLayerVideoGravityResizeAspectFill': {
+ // 'aspectFill'
+ if (imageAspectRatio > viewAspectRatio) {
+ // Cropping on the left and right
+ scaleY = displayedHeight / adjustedImageHeight;
+ scaleX = scaleY;
+ offsetX = (displayedWidth - adjustedImageWidth * scaleX) / 2;
+ } else {
+ // Cropping on the top and bottom
+ scaleX = displayedWidth / adjustedImageWidth;
+ scaleY = scaleX;
+ offsetY = (displayedHeight - adjustedImageHeight * scaleY) / 2;
+ }
+ break;
+ }
+ case 'AVLayerVideoGravityResize': {
+ // 'fill'
+ scaleX = displayedWidth / adjustedImageWidth;
+ scaleY = displayedHeight / adjustedImageHeight;
+ break;
+ }
+ }
+
+ // Adjust coordinates and dimensions for orientation
+ const adjusted = this.adjustBoundingBox(x, y, width, height, imageWidth, imageHeight, imageOrientation);
+
+ // Scale and shift the bounding box for display
+ return {
+ x: adjusted.x * scaleX + offsetX,
+ y: adjusted.y * scaleY + offsetY,
+ width: adjusted.width * scaleX,
+ height: adjusted.height * scaleY,
+ };
+ }
+
+ private adjustBoundingBox(x: number, y: number, width: number, height: number, imageWidth: number, imageHeight: number, imageOrientation: number): { x: number; y: number; width: number; height: number } {
+ let adjustedX = x;
+ let adjustedY = y;
+ let adjustedWidth = width;
+ let adjustedHeight = height;
+
+ switch (imageOrientation) {
+ case 1: // Down
+ adjustedX = imageWidth - x - width;
+ adjustedY = imageHeight - y - height;
+ break;
+ case 2: // Left
+ adjustedX = y;
+ adjustedY = imageWidth - x - width;
+ adjustedWidth = height;
+ adjustedHeight = width;
+ break;
+ case 3: // Right
+ adjustedX = imageHeight - y - height;
+ adjustedY = x;
+ adjustedWidth = height;
+ adjustedHeight = width;
+ break;
+ case 4: // Up Mirrored
+ adjustedX = imageWidth - x - width;
+ break;
+ case 5: // Down Mirrored
+ adjustedY = imageHeight - y - height;
+ break;
+ case 6: // Left Mirrored
+ adjustedX = imageHeight - y - height;
+ adjustedY = imageWidth - x - width;
+ adjustedWidth = height;
+ adjustedHeight = width;
+ break;
+ case 7: // Right Mirrored
+ adjustedX = y;
+ adjustedY = x;
+ adjustedWidth = height;
+ adjustedHeight = width;
+ break;
+ default: // Up
+ break;
+ }
+ return { x: adjustedX, y: adjustedY, width: adjustedWidth, height: adjustedHeight };
+ }
+
+ public drawBoundingBoxes(objects: TNSObjectDetectionResult[]) {
+ if (!this._overlayLayer) return;
+ const img_info_string = (this._mlkitHelper as any).getCaptureInfo() as string;
+ const img_info = JSON.parse(img_info_string) as { width: number; height: number; orientation: number };
+
+ // Clear previous bounding boxes
+ if (this._overlayLayer.sublayers) {
+ this._overlayLayer.sublayers = null;
+ }
+
+ if (objects) {
+ // Draw bounding boxes for each detected object
+ objects.forEach((object) => {
+ const bbox = object.bounds;
+ if (!bbox) {
+ console.warn('No bounds found for object:', object);
+ return;
+ }
- public startPreview(): void {
- this.#mlkitHelper.openCamera();
- this.#mlkitHelper.startPreview();
- }
-
-
- public onLayout(left: number, top: number, right: number, bottom: number) {
- if (this.#preview) {
- this.#preview.frame = this.nativeView.bounds;
+ let bestLabel = null;
+ if (object.labels && object.labels.length > 0) {
+ // Take the most confident label, MLKit seems to ignore threshold value
+ bestLabel = object.labels.reduce((maxLabel, label) => (label.confidence > maxLabel.confidence ? label : maxLabel));
+ if (bestLabel.confidence < this.customObjectDetectionConfidenceThreshold) {
+ return;
+ }
}
- }
+ const tbbox = this.adjustBoundingBoxForVideoGravity(bbox.x, bbox.y, bbox.width, bbox.height, img_info.width, img_info.height, img_info.orientation, this._preview.bounds.size.width, this._preview.bounds.size.height, this._preview.videoGravity);
- public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number) {
- const width = Utils.layout.getMeasureSpecSize(widthMeasureSpec);
- const height = Utils.layout.getMeasureSpecSize(heightMeasureSpec);
- this.setMeasuredDimension(width, height);
- }
+ if (this._boundingBoxSettings.drawBBoxes) {
+ const boxLayer = CALayer.layer();
+ boxLayer.frame = CGRectMake(tbbox.x, tbbox.y, tbbox.width, tbbox.height);
+ boxLayer.borderWidth = this._boundingBoxSettings.bBoxLineWidth;
+ boxLayer.borderColor = new Color(this._boundingBoxSettings.bBoxLineColor).ios.CGColor;
+ boxLayer.backgroundColor = UIColor.clearColor.CGColor;
+ boxLayer.cornerRadius = this._boundingBoxSettings.bBoxCornerness;
+ this._overlayLayer.addSublayer(boxLayer);
+ }
- requestCameraPermission() {
- return new Promise((resolve, reject) => {
- AVCaptureDevice.requestAccessForMediaTypeCompletionHandler(AVMediaTypeVideo, cameraPermissionStatus => {
- if (cameraPermissionStatus) {
- resolve()
- } else {
- reject();
- }
- });
- });
- }
+ // Draw edge marks with rounded corners
+ const edgeMarkLength = Math.min(tbbox.width, tbbox.height) * this._boundingBoxSettings.edgeMarkLengthFactor;
+ const lineWidth = this._boundingBoxSettings.edgeMarkLineWidth; // Thickness of edge marks
+
+ // Create layers for each edge mark
+ if (this._boundingBoxSettings.drawEdgeMarks) {
+ const createEdgeLayer = (x: number, y: number, width: number, height: number) => {
+ const layer = CALayer.layer();
+ layer.frame = CGRectMake(x, y, width, height);
+ layer.cornerRadius = this._boundingBoxSettings.bBoxCornerness;
+ layer.backgroundColor = UIColor.redColor.CGColor;
+ return layer;
+ };
+ // Top-left corner
+ this._overlayLayer.addSublayer(createEdgeLayer(tbbox.x, tbbox.y, edgeMarkLength, lineWidth));
+ this._overlayLayer.addSublayer(createEdgeLayer(tbbox.x, tbbox.y, lineWidth, edgeMarkLength));
+
+ // Top-right corner
+ this._overlayLayer.addSublayer(createEdgeLayer(tbbox.x + tbbox.width - edgeMarkLength, tbbox.y, edgeMarkLength, lineWidth));
+ this._overlayLayer.addSublayer(createEdgeLayer(tbbox.x + tbbox.width - lineWidth, tbbox.y, lineWidth, edgeMarkLength));
+
+ // Bottom-left corner
+ this._overlayLayer.addSublayer(createEdgeLayer(tbbox.x, tbbox.y + tbbox.height - edgeMarkLength, lineWidth, edgeMarkLength));
+ this._overlayLayer.addSublayer(createEdgeLayer(tbbox.x, tbbox.y + tbbox.height - lineWidth, edgeMarkLength, lineWidth));
+
+ // Bottom-right corner
+ this._overlayLayer.addSublayer(createEdgeLayer(tbbox.x + tbbox.width - edgeMarkLength, tbbox.y + tbbox.height - lineWidth, edgeMarkLength, lineWidth));
+ this._overlayLayer.addSublayer(createEdgeLayer(tbbox.x + tbbox.width - lineWidth, tbbox.y + tbbox.height - edgeMarkLength, lineWidth, edgeMarkLength));
+ }
+ // draw label
+ if (this._boundingBoxSettings.drawLabels) {
+ const textLayer = this.drawText(tbbox, bestLabel);
+ this._overlayLayer.addSublayer(textLayer); // Add the text layer
+ }
+ });
+ }
+ }
+ private drawText(bbox: { x: number; y: number; width: number; height: number }, label: { text: string; confidence: number; index?: number }): CATextLayer {
+ const textLayer = CATextLayer.layer();
+ const mappedLabelText = this._boundingBoxSettings.labelMappings[label.text] ?? label.text;
+ const labelText = this._boundingBoxSettings.showConfidence ? `${mappedLabelText} ${label.confidence.toFixed(2)}` : `${mappedLabelText}`;
+ textLayer.string = labelText;
+
+ const fontSize = 14;
+ textLayer.fontSize = fontSize;
+ textLayer.foregroundColor = new Color(this._boundingBoxSettings.labelTextColor).ios.CGColor;
+ textLayer.backgroundColor = new Color(this._boundingBoxSettings.labelBackgroundColor).ios.CGColor;
+
+ let mode = kCAAlignmentNatural;
+ switch (this._boundingBoxSettings.labelAlignment) {
+ case 'left':
+ mode = kCAAlignmentLeft;
+ break;
+ case 'center':
+ mode = kCAAlignmentCenter;
+ break;
+ case 'right':
+ mode = kCAAlignmentRight;
+ break;
+ }
+ textLayer.alignmentMode = mode;
+ textLayer.cornerRadius = this._boundingBoxSettings.labelCornerness;
+ textLayer.masksToBounds = true;
+
+ // Calculate text width to ensure it fits the content
+ const textAttributes = NSDictionary.dictionaryWithObjectForKey(UIFont.systemFontOfSize(fontSize), NSFontAttributeName);
+ const textSize = NSString.stringWithString(labelText).sizeWithAttributes(textAttributes);
+
+ // Ensure the label width is at least as wide as the bounding box
+ const labelWidth = Math.max(textSize.width + 10, bbox.width); // Add padding to text size
+ const labelHeight = textSize.height + 8; // Add padding to text height
+
+ // Position the label above the bounding box, centered horizontally
+ const padding = 4; // Space between the text and the bounding box
+ const labelX = bbox.x + (bbox.width - labelWidth) / 2; // Center horizontally above the bounding box
+ const labelY = bbox.y - labelHeight - padding; // Position above the bounding box
+
+ textLayer.frame = CGRectMake(labelX, labelY, labelWidth, labelHeight);
+ textLayer.bounds = CGRectMake(0, -textLayer.fontSize / 4, labelWidth, labelHeight);
+ return textLayer;
+ }
+}
- hasCameraPermission(): boolean {
- return AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo) === AVAuthorizationStatus.Authorized
- }
+export function detectWithStillImage(image: any, options?: StillImageDetectionOptions) {
+ return new Promise((resolve, reject) => {
+ let nativeImage;
+ if (image instanceof ImageSource) {
+ nativeImage = image.ios;
+ } else if (image instanceof UIImage) {
+ nativeImage = image;
+ } else {
+ reject('Please use a valid Image');
+ }
+
+ const type = detectionTypeToNative(options?.detectorType);
+
+ TNSML.processImage(
+ nativeImage,
+ {
+ ...(options || {}),
+ detectorType: type,
+ } as any,
+ (ret: NSArray) => {
+ const result = {};
+ const count = ret.count;
+ for (let i = 0; i < count; i++) {
+ const item = ret.objectAtIndex(i);
+ try {
+ if (item.type === DetectionType.Selfie) {
+ result[item.type] = {
+ data: interop.bufferFromData(item.result),
+ width: item.result.width,
+ height: item.result.height,
+ };
+ } else {
+ result[item.type] = JSON.parse(item.result);
+ }
+ } catch (e) {}
+ }
+ resolve(result);
+ },
+ );
+ });
}
diff --git a/packages/mlkit-core/package.json b/packages/mlkit-core/package.json
index 5ddf6ed..7b2097d 100644
--- a/packages/mlkit-core/package.json
+++ b/packages/mlkit-core/package.json
@@ -1,35 +1,39 @@
{
- "name": "@nativescript/mlkit-core",
- "version": "1.0.0-alpha.1",
- "description": "NativeScript MLKit Core",
- "main": "index",
- "typings": "index.d.ts",
- "nativescript": {
- "platforms": {
- "ios": "6.0.0",
- "android": "6.0.0"
- }
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/NativeScript/mlkit.git"
- },
- "keywords": [
- "NativeScript",
- "JavaScript",
- "TypeScript",
- "iOS",
- "Android"
- ],
- "author": {
- "name": "NativeScript",
- "email": "oss@nativescript.org"
- },
- "bugs": {
- "url": "https://github.com/NativeScript/mlkit/issues"
- },
- "license": "Apache-2.0",
- "homepage": "https://github.com/NativeScript/mlkit",
- "readmeFilename": "README.md",
- "bootstrapper": "@nativescript/plugin-seed"
+ "name": "@nativescript/mlkit-core",
+ "version": "3.0.4",
+ "description": "NativeScript MLKit Core",
+ "main": "index",
+ "typings": "index.d.ts",
+ "files": [
+ "*",
+ "angular/package.json"
+ ],
+ "nativescript": {
+ "platforms": {
+ "ios": "6.0.0",
+ "android": "6.0.0"
+ }
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/NativeScript/mlkit.git"
+ },
+ "keywords": [
+ "NativeScript",
+ "JavaScript",
+ "TypeScript",
+ "iOS",
+ "Android"
+ ],
+ "author": {
+ "name": "NativeScript",
+ "email": "oss@nativescript.org"
+ },
+ "bugs": {
+ "url": "https://github.com/NativeScript/mlkit/issues"
+ },
+ "license": "Apache-2.0",
+ "homepage": "https://github.com/NativeScript/mlkit",
+ "readmeFilename": "README.md",
+ "bootstrapper": "@nativescript/plugin-seed"
}
diff --git a/packages/mlkit-core/platforms/android/include.gradle b/packages/mlkit-core/platforms/android/include.gradle
index 4cf653e..65181eb 100644
--- a/packages/mlkit-core/platforms/android/include.gradle
+++ b/packages/mlkit-core/platforms/android/include.gradle
@@ -1,3 +1,25 @@
+allprojects {
+ repositories {
+ maven { url "https://repo1.maven.org/maven2/" }
+ maven { url "https://s01.oss.sonatype.org/content/repositories/releases/" }
+ }
+}
+
dependencies {
- implementation 'io.github.triniwiz:fancycamera:3.0.0-alpha23'
-}
\ No newline at end of file
+ implementation 'io.github.triniwiz:fancycamera:4.0.0-alpha.13'
+}
+
+
+android {
+ packagingOptions {
+ exclude 'META-INF/DEPENDENCIES'
+ exclude 'META-INF/LICENSE'
+ exclude 'META-INF/LICENSE.txt'
+ exclude 'META-INF/license.txt'
+ exclude 'META-INF/NOTICE'
+ exclude 'META-INF/NOTICE.txt'
+ exclude 'META-INF/notice.txt'
+ exclude 'META-INF/ASL2.0'
+ exclude("META-INF/*.kotlin_module")
+ }
+}
diff --git a/packages/mlkit-core/platforms/ios/Podfile b/packages/mlkit-core/platforms/ios/Podfile
index 6310e39..9cd8010 100644
--- a/packages/mlkit-core/platforms/ios/Podfile
+++ b/packages/mlkit-core/platforms/ios/Podfile
@@ -1 +1 @@
-pod 'SwiftyJSON', '~> 4.0'
\ No newline at end of file
+pod 'SwiftyJSON', '~> 5.0'
\ No newline at end of file
diff --git a/packages/mlkit-core/platforms/ios/src/TNSBarcodeScanner.swift b/packages/mlkit-core/platforms/ios/src/TNSBarcodeScanner.swift
index 277f749..430f621 100644
--- a/packages/mlkit-core/platforms/ios/src/TNSBarcodeScanner.swift
+++ b/packages/mlkit-core/platforms/ios/src/TNSBarcodeScanner.swift
@@ -87,6 +87,41 @@ enum BarcodeFormats: String, Codable {
}
}
+ var format: BarcodeFormat {
+ switch(self){
+ case .ALL:
+ return .all
+ case .CODE_128:
+ return .code128
+ case .CODE_39:
+ return .code39
+ case .CODE_93:
+ return .code93
+ case .CODABAR:
+ return .codaBar
+ case .DATA_MATRIX:
+ return .dataMatrix
+ case .EAN_13:
+ return .EAN13
+ case .EAN_8:
+ return .EAN8
+ case .ITF:
+ return .ITF
+ case .QR_CODE:
+ return .qrCode
+ case .UPC_A:
+ return .UPCA
+ case .UPC_E:
+ return .UPCE
+ case .PDF417:
+ return .PDF417
+ case .AZTEC:
+ return .aztec
+ case .UNKOWN:
+ return BarcodeFormat(rawValue: 0)
+ }
+ }
+
typealias RawValue = String
case ALL
@@ -137,9 +172,11 @@ struct TNSBarcodeScannerResult: Codable {
var displayValue: String?
var driverLicense: TNSDriverLicense?
var email: TNSEmail?
- var format: [BarcodeFormats]
+ var format: BarcodeFormats
var phone: TNSPhone?
- var rawBytes: Data?
+ var rawBytes: [UInt8]?
+
+
var rawValue: String?
var geoPoint: TNSGeo?
var sms: TNSSms?
@@ -154,7 +191,16 @@ class TNSBarcodeScanner: NSObject {
static func createBarcodeScannerResult(_ barcode: Barcode) -> TNSBarcodeScannerResult {
- return TNSBarcodeScannerResult(calenderEvent: TNSBarcodeScanner.createCalenderEvent(barcode.calendarEvent), contactInfo: TNSBarcodeScanner.createContactInfo(barcode.contactInfo), bounds: createBounds(barcode.frame), points: createPoints(barcode.cornerPoints), displayValue: barcode.displayValue, driverLicense: createDriverLicense(barcode.driverLicense), email: createEmail(barcode.email), format: parseFormat(barcode.format), phone: createPhone(barcode.phone), rawBytes: barcode.rawData, rawValue: barcode.rawValue, geoPoint: createGeo(barcode.geoPoint), sms: createSMS(barcode.sms), url: createURL(barcode.url), valueType: createValueType(barcode.valueType), wifi: createWIFI(barcode.wifi))
+
+
+ var rawBytes: [UInt8]?
+
+ if(barcode.rawData != nil){
+ let rawData = barcode.rawData! as NSData
+ rawBytes = [UInt8](rawData)
+ }
+
+ return TNSBarcodeScannerResult(calenderEvent: TNSBarcodeScanner.createCalenderEvent(barcode.calendarEvent), contactInfo: TNSBarcodeScanner.createContactInfo(barcode.contactInfo), bounds: createBounds(barcode.frame), points: createPoints(barcode.cornerPoints), displayValue: barcode.displayValue, driverLicense: createDriverLicense(barcode.driverLicense), email: createEmail(barcode.email), format: parseFormat(barcode.format), phone: createPhone(barcode.phone), rawBytes: rawBytes, rawValue: barcode.rawValue, geoPoint: createGeo(barcode.geoPoint), sms: createSMS(barcode.sms), url: createURL(barcode.url), valueType: createValueType(barcode.valueType), wifi: createWIFI(barcode.wifi))
}
static func createValueType(_ value: BarcodeValueType) -> String {
@@ -449,45 +495,41 @@ struct TNSDriverLicense: Codable {
}
-func parseFormat(_ format: BarcodeFormat) -> [BarcodeFormats]{
- var result: [BarcodeFormats] = []
-
+func parseFormat(_ format: BarcodeFormat) -> BarcodeFormats {
+
if (format == .all) {
- result.append(.ALL)
- return result
+ return BarcodeFormats.ALL
}
if ((format.rawValue & BarcodeFormat.aztec.rawValue) == BarcodeFormat.aztec.rawValue) {
- result.append(.AZTEC)
+ return .AZTEC
} else if ((format.rawValue & BarcodeFormat.codaBar.rawValue) == BarcodeFormat.codaBar.rawValue) {
- result.append(.CODABAR)
+ return .CODABAR
} else if ((format.rawValue & BarcodeFormat.code128.rawValue) == BarcodeFormat.code128.rawValue) {
- result.append(.CODE_128)
+ return .CODE_128
} else if ((format.rawValue & BarcodeFormat.code39.rawValue) == BarcodeFormat.code39.rawValue) {
- result.append(.CODE_39)
+ return .CODE_39
} else if ((format.rawValue & BarcodeFormat.code93.rawValue) == BarcodeFormat.code93.rawValue) {
- result.append(.CODE_93)
+ return .CODE_93
} else if ((format.rawValue & BarcodeFormat.dataMatrix.rawValue) == BarcodeFormat.dataMatrix.rawValue) {
- result.append(.DATA_MATRIX)
+ return .DATA_MATRIX
} else if ((format.rawValue & BarcodeFormat.EAN13.rawValue) == BarcodeFormat.EAN13.rawValue) {
- result.append(.EAN_13)
+ return .EAN_13
} else if ((format.rawValue & BarcodeFormat.EAN8.rawValue) == BarcodeFormat.EAN8.rawValue) {
- result.append(BarcodeFormats.EAN_8)
+ return BarcodeFormats.EAN_8
} else if ((format.rawValue & BarcodeFormat.ITF.rawValue) == BarcodeFormat.ITF.rawValue) {
- result.append(BarcodeFormats.ITF)
+ return BarcodeFormats.ITF
} else if ((format.rawValue & BarcodeFormat.PDF417.rawValue) == BarcodeFormat.PDF417.rawValue) {
- result.append(BarcodeFormats.PDF417)
+ return BarcodeFormats.PDF417
} else if ((format.rawValue & BarcodeFormat.qrCode.rawValue) == BarcodeFormat.qrCode.rawValue) {
- result.append(BarcodeFormats.QR_CODE)
+ return BarcodeFormats.QR_CODE
} else if ((format.rawValue & BarcodeFormat.UPCA.rawValue) == BarcodeFormat.UPCA.rawValue) {
- result.append(BarcodeFormats.UPC_A)
+ return BarcodeFormats.UPC_A
} else if ((format.rawValue & BarcodeFormat.UPCE.rawValue) == BarcodeFormat.UPCE.rawValue) {
- result.append(BarcodeFormats.UPC_E)
- }
- if (format.rawValue == 0) {
- result.append(.UNKOWN)
+ return BarcodeFormats.UPC_E
}
- return result
+
+ return .UNKOWN
}
diff --git a/packages/mlkit-core/platforms/ios/src/TNSML.swift b/packages/mlkit-core/platforms/ios/src/TNSML.swift
new file mode 100644
index 0000000..67dccac
--- /dev/null
+++ b/packages/mlkit-core/platforms/ios/src/TNSML.swift
@@ -0,0 +1,380 @@
+import Foundation
+import UIKit
+
+#if canImport(MLKitVision)
+ import MLKitVision
+#endif
+
+#if canImport(MLKitBarcodeScanning)
+ import MLKitBarcodeScanning
+#endif
+
+#if canImport(MLKitFaceDetection)
+ import MLKitFaceDetection
+#endif
+
+#if canImport(MLKitTextRecognition)
+ import MLKitTextRecognition
+#endif
+
+#if canImport(MLKitDigitalInkRecognition)
+ import MLKitDigitalInkRecognition
+#endif
+
+#if canImport(MLKitImageLabeling)
+ import MLKitImageLabeling
+#endif
+
+#if canImport(MLKitObjectDetection)
+ import MLKitObjectDetection
+#endif
+
+#if canImport(MLKitPoseDetection)
+ import MLKitPoseDetection
+#endif
+
+#if canImport(MLKitSegmentationSelfie)
+ import MLKitSegmentationSelfie
+#endif
+
+@objcMembers
+@objc(TNSMLResult)
+public class TNSMLResult: NSObject {
+ var result: Any
+ var type: String
+ public init(_ result: Any, _ type: String) {
+ self.result = result
+ self.type = type
+ }
+}
+
+#if canImport(MLKitVision)
+ @objcMembers
+ @objc(TNSML)
+ public class TNSML: NSObject {
+ private static let encoder = JSONEncoder()
+ private static let queue = DispatchQueue(label: "TNSML", attributes: .concurrent)
+
+ public static func processImage(
+ _ image: UIImage, _ json: NSDictionary, _ callback: @escaping ((Any) -> Void)
+ ) {
+ if isMLSupported() {
+ let inputImage = VisionImage(image: image)
+ process(inputImage, json, callback)
+ }
+ }
+
+ private static func process(
+ _ inputImage: VisionImage, _ json: NSDictionary, _ callback: @escaping ((Any) -> Void)
+ ) {
+ queue.async {
+
+ let detectorType = TNSMLKitDetectionType.init(
+ rawValue: json["detectorType"] as? UInt32 ?? TNSMLKitDetectionType.None.rawValue
+ )
+
+ var results: [TNSMLResult] = []
+
+ #if canImport(MLKitBarcodeScanning)
+ if detectorType == .Barcode || detectorType == .All {
+ var formatRaw = 0
+ let barcodeScanning = json["barcodeScanning"] as? NSDictionary
+ if barcodeScanning != nil {
+ let formatArray = barcodeScanning!["format"] as? [String]
+
+ if formatArray != nil {
+ for item in formatArray! {
+ let format = BarcodeFormats(rawValue: item)
+ if format != nil {
+ formatRaw |= format!.format.rawValue
+ }
+ }
+ }
+
+ if formatRaw == 0 {
+ formatRaw = BarcodeFormat.all.rawValue
+ }
+ } else {
+ formatRaw = BarcodeFormat.all.rawValue
+ }
+
+ let options = BarcodeScannerOptions(
+ formats: BarcodeFormat(rawValue: formatRaw))
+ do {
+ let scanner = BarcodeScanner.barcodeScanner(options: options)
+ let result = try scanner.results(in: inputImage)
+ let barCodes = handleBarcodeScanner(result)
+ if !barCodes.isEmpty {
+ let response = toJSON(barCodes)
+ if response != nil {
+ results.append(
+ TNSMLResult(
+ response!,
+ TNSMLKitDetectionType.Barcode.string()
+ ))
+ }
+ }
+ } catch {}
+
+ }
+ #endif
+
+ #if canImport(MLKitFaceDetection)
+ if detectorType == .Face || detectorType == .All {
+ let faceDetection = json["faceDetection"] as? NSDictionary
+ let options = FaceDetectorOptions()
+ if faceDetection != nil {
+ options.isTrackingEnabled =
+ faceDetection!["faceTracking"] as? Bool ?? false
+ options.minFaceSize = CGFloat(
+ faceDetection!["minimumFaceSize"] as? Float ?? 0.1)
+ options.performanceMode =
+ (faceDetection!["detectionMode"] as? String ?? "fast") == "accurate"
+ ? .accurate : .fast
+
+ options.landmarkMode =
+ (faceDetection!["landmarkMode"] as? String ?? "all") == "none"
+ ? .none : .all
+
+ options.contourMode =
+ (faceDetection!["contourMode"] as? String ?? "all") == "none"
+ ? .none : .all
+
+ options.classificationMode =
+ (faceDetection!["classificationMode"] as? String ?? "all") == "none"
+ ? .none : .all
+
+ } else {
+ options.isTrackingEnabled = false
+ options.minFaceSize = CGFloat(0.1)
+ options.performanceMode = .fast
+ options.classificationMode = .all
+ options.landmarkMode = .all
+ options.contourMode = .all
+ }
+
+ let faceDetector = FaceDetector.faceDetector(options: options)
+ do {
+ let result = try faceDetector.results(in: inputImage)
+ let faces = handleFaceDetection(result)
+
+ if !faces.isEmpty {
+ let response = toJSON(faces)
+ if response != nil {
+ results.append(
+ TNSMLResult(
+ response!,
+ TNSMLKitDetectionType.Face.string()
+ ))
+ }
+ }
+ } catch {}
+ }
+ #endif
+
+ #if canImport(MLKitPoseDetection)
+ if detectorType == .Pose || detectorType == .All {
+ let options = PoseDetectorOptions()
+ options.detectorMode = .singleImage
+ let poseDetector = PoseDetector.poseDetector(options: options)
+ do {
+ let result = try poseDetector.results(in: inputImage)
+ let poses = handlePoseDetection(result)
+
+ if !poses.isEmpty {
+ let response = toJSON(poses)
+ if response != nil {
+ results.append(
+ TNSMLResult(
+ response!,
+ TNSMLKitDetectionType.Pose.string()
+ ))
+ }
+ }
+ } catch {}
+ }
+ #endif
+
+ #if canImport(MLKitImageLabeling)
+ if detectorType == .Image || detectorType == .All {
+ let options = ImageLabelerOptions()
+
+ let imageLabeling = json["imageLabeling"] as? NSDictionary
+
+ if imageLabeling != nil {
+ options.confidenceThreshold =
+ (imageLabeling!["confidenceThreshold"] as? Float ?? 0.5) as NSNumber
+ } else {
+ options.confidenceThreshold = 0.5
+ }
+
+ let imageLabeler = ImageLabeler.imageLabeler(options: options)
+ do {
+ let result = try imageLabeler.results(in: inputImage)
+ let labels = handleImageLabeling(result)
+
+ if !labels.isEmpty {
+ let response = toJSON(labels)
+ if response != nil {
+ results.append(
+ TNSMLResult(
+ response!,
+ TNSMLKitDetectionType.Image.string()
+ ))
+ }
+ }
+ } catch {}
+ }
+ #endif
+
+ #if canImport(MLKitObjectDetection)
+ if detectorType == .Object || detectorType == .All {
+ let options = ObjectDetectorOptions()
+
+ let objectDetection = json["objectDetection"] as? NSDictionary
+
+ if objectDetection != nil {
+ options.shouldEnableMultipleObjects =
+ objectDetection!["multiple"] as? Bool ?? false
+ options.shouldEnableClassification =
+ objectDetection!["classification"] as? Bool ?? false
+
+ } else {
+ options.shouldEnableMultipleObjects = false
+ options.shouldEnableClassification = false
+ }
+
+ let objectDetector = ObjectDetector.objectDetector(options: options)
+ do {
+ let result = try objectDetector.results(in: inputImage)
+ let objects = handleObjectDetection(result)
+
+ if !objects.isEmpty {
+ let response = toJSON(objects)
+ results.append(
+ TNSMLResult(
+ response!,
+ TNSMLKitDetectionType.Object.string()
+ ))
+ }
+ } catch {}
+ }
+ #endif
+
+ #if canImport(MLKitTextRecognition)
+ if detectorType == .Text || detectorType == .All {
+ let textRecognizer = TextRecognizer.textRecognizer(
+ options: TextRecognizerOptions())
+ do {
+ let result = try textRecognizer.results(in: inputImage)
+ let texts = handleTextRecognition(result)
+
+ if !texts.isEmpty {
+ let response = toJSON(texts)
+ if response != nil {
+ results.append(
+ TNSMLResult(
+ response!,
+ TNSMLKitDetectionType.Text.string()
+ ))
+ }
+ }
+ } catch {}
+ }
+ #endif
+
+ #if canImport(MLKitSegmentationSelfie)
+ if detectorType == .Selfie || detectorType == .All {
+ let options = SelfieSegmenterOptions()
+ options.segmenterMode = .singleImage
+ let selfieSegmentation = json["selfieSegmentation"] as? NSDictionary
+
+ if selfieSegmentation != nil {
+ options.shouldEnableRawSizeMask =
+ selfieSegmentation!["enableRawSizeMask"] as? Bool ?? false
+
+ } else {
+ options.shouldEnableRawSizeMask = false
+ }
+
+ let selfieSegmentor = Segmenter.segmenter(options: options)
+ do {
+ let mask = try selfieSegmentor.results(in: inputImage)
+ let maskWidth = CVPixelBufferGetWidth(mask.buffer)
+ let maskHeight = CVPixelBufferGetHeight(mask.buffer)
+
+ CVPixelBufferLockBaseAddress(
+ mask.buffer, CVPixelBufferLockFlags.readOnly)
+ let maskBytesPerRow = CVPixelBufferGetBytesPerRow(mask.buffer)
+ let maskAddress =
+ CVPixelBufferGetBaseAddress(mask.buffer)!.bindMemory(
+ to: Float32.self, capacity: maskBytesPerRow * maskHeight)
+ let data = Data(bytes: maskAddress, count: maskBytesPerRow * maskHeight)
+ var ret: [String: Any] = [:]
+ ret["width"] = maskWidth
+ ret["height"] = maskHeight
+ ret["data"] = data
+ results.append(
+ TNSMLResult(
+ ret,
+ TNSMLKitDetectionType.Selfie.string()
+ ))
+
+ } catch {}
+ }
+ #endif
+
+ DispatchQueue.main.async {
+ callback(results)
+ }
+
+ }
+ }
+
+ private static func toJSON(_ value: T) -> String? {
+ do {
+ let json = try encoder.encode(value)
+ return String(data: json, encoding: .utf8) ?? nil
+ } catch {
+ return nil
+ }
+ }
+
+ private static func isMLSupported() -> Bool {
+ var supported = false
+ #if canImport(MLKitBarcodeScanning)
+ supported = true
+ #endif
+
+ #if canImport(MLKitFaceDetection)
+ supported = true
+ #endif
+
+ #if canImport(MLKitTextRecognition)
+ supported = true
+ #endif
+
+ #if canImport(MLKitDigitalInkRecognition)
+ supported = true
+ #endif
+
+ #if canImport(MLKitImageLabeling)
+ supported = true
+ #endif
+
+ #if canImport(MLKitObjectDetection)
+ supported = true
+ #endif
+
+ #if canImport(MLKitPoseDetection)
+ supported = true
+ #endif
+
+ #if canImport(MLKitSegmentationSelfie)
+ supported = true
+ #endif
+
+ return supported
+ }
+ }
+#endif
diff --git a/packages/mlkit-core/platforms/ios/src/TNSMLKitHelper.swift b/packages/mlkit-core/platforms/ios/src/TNSMLKitHelper.swift
index 018c245..8d7171f 100644
--- a/packages/mlkit-core/platforms/ios/src/TNSMLKitHelper.swift
+++ b/packages/mlkit-core/platforms/ios/src/TNSMLKitHelper.swift
@@ -1,43 +1,53 @@
-import Foundation
import AVFoundation
-import MLKit
+import Foundation
+import UIKit
+
+#if canImport(MLKitVision)
+ import MLKitVision
+#endif
#if canImport(MLKitBarcodeScanning)
-import MLKitBarcodeScanning
+ import MLKitBarcodeScanning
#endif
#if canImport(MLKitFaceDetection)
-import MLKitFaceDetection
+ import MLKitFaceDetection
#endif
#if canImport(MLKitTextRecognition)
-import MLKitTextRecognition
+ import MLKitTextRecognition
#endif
#if canImport(MLKitDigitalInkRecognition)
-import MLKitDigitalInkRecognition
+ import MLKitDigitalInkRecognition
#endif
#if canImport(MLKitImageLabeling)
-import MLKitImageLabeling
+ import MLKitImageLabeling
#endif
#if canImport(MLKitObjectDetection)
-import MLKitObjectDetection
+ import MLKitObjectDetection
#endif
-#if canImport(MLKitPoseDetection)
-import MLKitPoseDetection
+#if canImport(MLKitObjectDetectionCustom)
+ import MLKitObjectDetectionCustom
#endif
+#if canImport(MLKitPoseDetection)
+ import MLKitPoseDetection
+#endif
+#if canImport(MLKitSegmentationSelfie)
+ import MLKitSegmentationSelfie
+#endif
@objc(TNSMLKitHelperCameraPosition)
public enum TNSMLKitHelperCameraPosition: Int, RawRepresentable {
case Front
case Back
public typealias RawValue = UInt32
-
+
public var rawValue: RawValue {
switch self {
case .Back:
@@ -46,8 +56,7 @@ public enum TNSMLKitHelperCameraPosition: Int, RawRepresentable {
return 1
}
}
-
-
+
public init?(rawValue: RawValue) {
switch rawValue {
case 0:
@@ -58,8 +67,7 @@ public enum TNSMLKitHelperCameraPosition: Int, RawRepresentable {
return nil
}
}
-
-
+
public init?(string: String) {
switch string {
case "back":
@@ -70,9 +78,8 @@ public enum TNSMLKitHelperCameraPosition: Int, RawRepresentable {
return nil
}
}
-
-}
+}
struct TNSBounds: Codable {
var x: Double
@@ -81,25 +88,24 @@ struct TNSBounds: Codable {
var height: Double
}
-
func createBounds(_ frame: CGRect) -> TNSBounds {
- return TNSBounds(x: Double(frame.origin.x), y: Double(frame.origin.y), width: Double(frame.size.width), height: Double(frame.size.height))
+ return TNSBounds(
+ x: Double(frame.origin.x), y: Double(frame.origin.y), width: Double(frame.size.width),
+ height: Double(frame.size.height))
}
-
struct TNSPoint: Codable {
- var x:Double
+ var x: Double
var y: Double
}
func createPoint(_ point: NSValue?) -> TNSPoint? {
- guard point != nil else {return nil}
- return TNSPoint(x: Double(point!.cgPointValue.x), y: Double(point!.cgPointValue.y))
+ guard point != nil else { return nil }
+ return TNSPoint(x: Double(point!.cgPointValue.x), y: Double(point!.cgPointValue.y))
}
-
func createPoints(_ points: [NSValue]?) -> [TNSPoint]? {
- guard points != nil else {return nil}
+ guard points != nil else { return nil }
var results: [TNSPoint] = []
for point in points! {
results.append(createPoint(point)!)
@@ -107,9 +113,6 @@ func createPoints(_ points: [NSValue]?) -> [TNSPoint]? {
return results
}
-
-
-
@objc(TNSMLKitDetectionType)
enum TNSMLKitDetectionType: Int, RawRepresentable {
case Barcode
@@ -117,12 +120,14 @@ enum TNSMLKitDetectionType: Int, RawRepresentable {
case Face
case Image
case Object
+ case CustomObject
case Pose
case Text
case All
+ case Selfie
case None
public typealias RawValue = UInt32
-
+
public var rawValue: RawValue {
switch self {
case .Barcode:
@@ -135,18 +140,21 @@ enum TNSMLKitDetectionType: Int, RawRepresentable {
return 3
case .Object:
return 4
- case .Pose:
+ case .CustomObject:
return 5
- case .Text:
+ case .Pose:
return 6
- case .All:
+ case .Text:
return 7
- case .None:
+ case .All:
return 8
+ case .Selfie:
+ return 9
+ case .None:
+ return 10
}
}
-
-
+
public init?(rawValue: RawValue) {
switch rawValue {
case 0:
@@ -160,19 +168,22 @@ enum TNSMLKitDetectionType: Int, RawRepresentable {
case 4:
self = .Object
case 5:
- self = .Pose
+ self = .CustomObject
case 6:
- self = .Text
+ self = .Pose
case 7:
- self = .All
+ self = .Text
case 8:
+ self = .All
+ case 9:
+ self = .Selfie
+ case 10:
self = .None
default:
return nil
}
}
-
-
+
public init?(string: String) {
switch string {
case "barcode":
@@ -185,21 +196,26 @@ enum TNSMLKitDetectionType: Int, RawRepresentable {
self = .Image
case "object":
self = .Object
+ case "customObject":
+ self = .CustomObject
case "pose":
self = .Pose
- case "text":
+ case "text":
self = .Text
case "all":
self = .All
+ case "selfie":
+ self = .Selfie
case "none":
self = .None
default:
return nil
}
}
-
+
func string() -> String {
- switch(self){case .Barcode:
+ switch self {
+ case .Barcode:
return "barcode"
case .DigitalInk:
return "digitalInk"
@@ -209,84 +225,250 @@ enum TNSMLKitDetectionType: Int, RawRepresentable {
return "image"
case .Object:
return "object"
+ case .CustomObject:
+ return "customObject"
case .Pose:
return "pose"
case .Text:
return "text"
case .All:
return "all"
+ case .Selfie:
+ return "selfie"
case .None:
return "none"
}
}
}
+@objc(TNSMLKitTorchMode)
+public enum TNSMLKitTorchMode: Int, RawRepresentable {
+ case Off
+ case On
+ case Auto
+ public typealias RawValue = UInt32
+
+ public var rawValue: RawValue {
+ switch self {
+ case .Off:
+ return 0
+ case .On:
+ return 1
+ case .Auto:
+ return 2
+ }
+ }
+
+ public init?(rawValue: RawValue) {
+ switch rawValue {
+ case 0:
+ self = .Off
+ case 1:
+ self = .On
+ case 2:
+ self = .Auto
+ default:
+ return nil
+ }
+ }
+
+ public init?(string: String) {
+ switch string {
+ case "off":
+ self = .Off
+ case "on":
+ self = .On
+ case "auto":
+ self = .Auto
+ default:
+ return nil
+ }
+ }
+}
@objc(TNSMLKitHelper)
@objcMembers
public class TNSMLKitHelper: NSObject, AVCaptureVideoDataOutputSampleBufferDelegate {
- var onScanCallback: ((String, String) -> Void)?
+ var onScanCallback: ((Any, String) -> Void)?
var onError: ((NSError) -> Void)?
private var _output = AVCaptureVideoDataOutput()
let queue = DispatchQueue(label: "TNSMLKitHelper")
let sessionQueue = DispatchQueue(label: "TNSMLKitHelperSession")
private var isSessionSetup = false
private var videoInput: AVCaptureDeviceInput?
+ private var _latestImage: UIImage? = nil
+
+ public func getCaptureInfo() -> String? {
+ guard let videoInput = self.videoInput else { return nil }
+ let formatDescription = videoInput.device.activeFormat.formatDescription
+ let orientation = getOrientation(
+ deviceOrientation: UIDevice.current.orientation,
+ cameraPosition: videoInput.device.position)
+ let dimensions = CMVideoFormatDescriptionGetDimensions(formatDescription)
+ let imageInfo = [
+ "width": Int(dimensions.width),
+ "height": Int(dimensions.height),
+ "orientation": orientation.rawValue,
+ ]
+ let encoder = JSONEncoder()
+ if let jsonData = try? encoder.encode(imageInfo) {
+ return String(data: jsonData, encoding: .utf8)
+ }
+ return nil
+ }
+
+ var retrieveLatestImage = false {
+ didSet {
+ if _latestImage != nil {
+ _latestImage = nil
+ }
+ }
+ }
+
+ var latestImage: UIImage? {
+ return _latestImage
+ }
+
var cameraPosition = TNSMLKitHelperCameraPosition.Back {
didSet {
- if(!isSessionSetup){
+ if !isSessionSetup {
return
}
setCamera()
}
}
var output: AVCaptureVideoDataOutput {
- get {
- return _output
- }
+ return _output
}
+ var autoFocus = true
let session = AVCaptureSession()
let encoder = JSONEncoder()
var detectorType = TNSMLKitDetectionType.All
-
-
-#if canImport(MLKitBarcodeScanning)
- var barcodeScanner: BarcodeScanner?
-#endif
-
-
-#if canImport(MLKitFaceDetection)
- var faceDetector: FaceDetector?
-#endif
-
-
-#if canImport(MLKitTextRecognition)
- var textRecognizer: TextRecognizer?
-#endif
-
-
-#if canImport(MLKitDigitalInkRecognition)
- var digitalInkRecognizer: DigitalInkRecognizer?
-#endif
-
-
-#if canImport(MLKitImageLabeling)
- var imageLabeler: ImageLabeler?
-#endif
-
-
-#if canImport(MLKitObjectDetection)
- var objectDetector: ObjectDetector?
-#endif
-
-
-#if canImport(MLKitPoseDetection)
- var poseDetector: PoseDetector?
-#endif
-
-
-
-
+ var processEveryNthFrame = 0
+ private var currentFrame = 0
+
+ private func updateAutoFocus(_ videoInput: AVCaptureDeviceInput?) {
+ if !session.isRunning {
+ return
+ }
+ do {
+ guard let videoInput = videoInput else {
+ return
+ }
+
+ try videoInput.device.lockForConfiguration()
+
+ defer {
+ videoInput.device.unlockForConfiguration()
+ }
+
+ if videoInput.device.isFocusModeSupported(.continuousAutoFocus) {
+ videoInput.device.focusMode = .continuousAutoFocus
+ if videoInput.device.isSmoothAutoFocusSupported {
+ videoInput.device.isSmoothAutoFocusEnabled = true
+ }
+ }
+
+ } catch {}
+ }
+
+ private func updateTorchMode(_ videoInput: AVCaptureDeviceInput?) {
+ if !session.isRunning {
+ return
+ }
+ do {
+ guard videoInput?.device != nil else {
+ return
+ }
+
+ try videoInput!.device.lockForConfiguration()
+
+ defer {
+ videoInput!.device.unlockForConfiguration()
+ }
+
+ switch torchMode {
+ case .Off:
+ if videoInput!.device.isTorchModeSupported(.off) {
+ videoInput!.device.torchMode = .off
+ }
+ break
+ case .On:
+ if videoInput!.device.isTorchModeSupported(.on) {
+ videoInput!.device.torchMode = .on
+ }
+ break
+ case .Auto:
+ if videoInput!.device.isTorchModeSupported(.auto) {
+ videoInput!.device.torchMode = .auto
+ }
+ break
+ }
+
+ } catch {}
+ }
+
+ public var torchMode: TNSMLKitTorchMode = .Off {
+ didSet {
+ updateTorchMode(self.videoInput)
+ }
+ }
+
+ public var pause: Bool = false {
+ didSet {
+ sessionQueue.async {
+ if self.isSessionSetup {
+ if self.pause && self.session.isRunning {
+ self.session.stopRunning()
+ self.resetCurrentFrame()
+ }
+
+ if !self.pause && !self.session.isRunning {
+ self.session.startRunning()
+ self.updateAutoFocus(self.videoInput)
+ self.updateTorchMode(self.videoInput)
+ }
+ }
+ }
+ }
+ }
+
+ #if canImport(MLKitBarcodeScanning)
+ var barcodeScanner: BarcodeScanner?
+ #endif
+
+ #if canImport(MLKitFaceDetection)
+ var faceDetector: FaceDetector?
+ #endif
+
+ #if canImport(MLKitTextRecognition)
+ var textRecognizer: TextRecognizer?
+ #endif
+
+ #if canImport(MLKitDigitalInkRecognition)
+ var digitalInkRecognizer: DigitalInkRecognizer?
+ #endif
+
+ #if canImport(MLKitImageLabeling)
+ var imageLabeler: ImageLabeler?
+ #endif
+
+ #if canImport(MLKitObjectDetection)
+ var objectDetector: ObjectDetector?
+ #endif
+
+ #if canImport(MLKitObjectDetectionCustom)
+ var customObjectDetector: ObjectDetector?
+ #endif
+
+ #if canImport(MLKitPoseDetection)
+ var poseDetector: PoseDetector?
+ #endif
+
+ #if canImport(MLKitSegmentationSelfie)
+ var selfieSegmentor: Segmenter?
+ #endif
+
public override init() {
super.init()
_output.alwaysDiscardsLateVideoFrames = true
@@ -295,44 +477,47 @@ public class TNSMLKitHelper: NSObject, AVCaptureVideoDataOutputSampleBufferDeleg
]
_output.setSampleBufferDelegate(self, queue: queue)
}
-
- public func startPreview(){
+
+ public func startPreview() {
sessionQueue.async {
- if(self.isSessionSetup && !self.session.isRunning){
+ if self.isSessionSetup && !self.session.isRunning && !self.pause {
self.session.startRunning()
+ self.updateAutoFocus(self.videoInput)
+ self.updateTorchMode(self.videoInput)
}
}
-
+
}
-
- public func stopPreview(){
+
+ public func stopPreview() {
sessionQueue.async {
- if(self.isSessionSetup && self.session.isRunning){
+ if self.isSessionSetup && self.session.isRunning {
self.session.stopRunning()
+ self.resetCurrentFrame()
}
}
}
-
- public func toggleCamera(){
+
+ public func toggleCamera() {
if cameraPosition == .Front {
cameraPosition = .Back
- }else {
+ } else {
cameraPosition = .Front
}
setCamera()
}
- private func setCamera(){
- sessionQueue.async {
- if(self.isSessionSetup){
+ private func setCamera() {
+ sessionQueue.async { [self] in
+ if self.isSessionSetup {
let wasRunning = self.session.isRunning
-
+
let videoDevice = self.getVideoDevice()
guard videoDevice != nil else {
let error = NSError(domain: "Failed to toggleCamera", code: 1, userInfo: nil)
self.onError?(error)
return
}
-
+
let videoInput: AVCaptureDeviceInput?
do {
videoInput = try AVCaptureDeviceInput(device: videoDevice!)
@@ -340,39 +525,45 @@ public class TNSMLKitHelper: NSObject, AVCaptureVideoDataOutputSampleBufferDeleg
self.onError?(error as NSError)
return
}
-
-
- if(wasRunning){
+
+ if wasRunning {
self.session.stopRunning()
+ self.resetCurrentFrame()
}
-
-
- if(self.videoInput != nil){
+
+ if self.videoInput != nil {
self.session.removeInput(self.videoInput!)
}
-
+
self.videoInput = videoInput
-
- if(self.session.canAddInput(videoInput!)){
+
+ if self.session.canAddInput(videoInput!) {
self.session.addInput(videoInput!)
}
- if(wasRunning){
+ if wasRunning && !self.pause {
self.session.startRunning()
+ updateAutoFocus(videoInput)
+ updateTorchMode(videoInput)
}
}
}
}
-
+
private func getVideoDevice() -> AVCaptureDevice? {
var captureDevice: AVCaptureDevice?
var position = AVCaptureDevice.Position.back
if self.cameraPosition == .Front {
position = .front
}
- if #available(iOS 10.0, *){
- captureDevice = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: position)
-
- }else {
+ if #available(iOS 10.0, *) {
+ // close range autofocus requires a virtual camera as the minimum focus distance of WideAngleCamera
+ // is to far away to allow for good quality barcode scanning
+ captureDevice =
+ AVCaptureDevice.default(.builtInTripleCamera, for: .video, position: position)
+ ?? AVCaptureDevice.default(.builtInDualWideCamera, for: .video, position: position)
+ ?? AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: position)
+
+ } else {
let devices = AVCaptureDevice.devices(for: .video)
for device in devices {
if device.position == position {
@@ -383,65 +574,82 @@ public class TNSMLKitHelper: NSObject, AVCaptureVideoDataOutputSampleBufferDeleg
}
return captureDevice
}
-
- public func openCamera(){
+
+ public func hasCameraPermission() -> Bool {
+ return AVCaptureDevice.authorizationStatus(for: .video) == .authorized
+ }
+
+ public func requestCameraPermission(_ callback: @escaping ((Bool) -> Void)) {
+ AVCaptureDevice.requestAccess(for: .video) { result in
+ DispatchQueue.main.async {
+ callback(result)
+ }
+ }
+ }
+
+ public func openCamera() {
sessionQueue.async {
- if(self.isSessionSetup){
+ if self.isSessionSetup {
+ return
+ }
+
+ if !self.hasCameraPermission() {
return
}
+
let captureDevice = self.getVideoDevice()
- guard captureDevice != nil else {return}
+ guard captureDevice != nil else { return }
do {
self.videoInput = try AVCaptureDeviceInput(device: captureDevice!)
- }catch {
+ } catch {
self.onError?(error as NSError)
}
-
- guard self.videoInput != nil else {return}
-
+
+ guard self.videoInput != nil else { return }
+
+ self.updateAutoFocus(self.videoInput)
+ self.updateTorchMode(self.videoInput)
+
self.session.beginConfiguration()
self.session.addInput(self.videoInput!)
-
- if self.session.canAddOutput(self.output){
+
+ if self.session.canAddOutput(self.output) {
self.session.addOutput(self.output)
}
self.session.commitConfiguration()
self.isSessionSetup = true
-
+
}
}
-
+
private func handleNil(_ value: AnyObject?) -> AnyHashable {
- guard value != nil else {return NSNull()}
+ guard value != nil else { return NSNull() }
return value as! AnyHashable
}
-
-
+
private func handleNilArray(_ value: [Any]?) -> Any {
- guard value != nil else {return NSNull()}
+ guard value != nil else { return NSNull() }
return value!
}
-
-
- func toJSON(_ value: T)-> String?{
- do{
+
+ func toJSON(_ value: T) -> String? {
+ do {
let json = try encoder.encode(value)
return String(data: json, encoding: .utf8) ?? nil
- }catch{
+ } catch {
return nil
}
}
-
-
-
- func getOrientation(deviceOrientation: UIDeviceOrientation, cameraPosition: AVCaptureDevice.Position) -> UIImage.Orientation {
- switch (deviceOrientation) {
+
+ func getOrientation(
+ deviceOrientation: UIDeviceOrientation, cameraPosition: AVCaptureDevice.Position
+ ) -> UIImage.Orientation {
+ switch deviceOrientation {
case .portrait:
if cameraPosition == .front {
return .leftMirrored
}
return .right
-
case .landscapeLeft:
if cameraPosition == .front {
return .downMirrored
@@ -458,140 +666,245 @@ public class TNSMLKitHelper: NSObject, AVCaptureVideoDataOutputSampleBufferDeleg
}
return .down
case .unknown, .faceUp, .faceDown:
- return .up;
+ return .up
}
}
-
-
-
- public func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
- autoreleasepool {
- let buffer = CMSampleBufferGetImageBuffer(sampleBuffer)
- guard buffer != nil else {return}
- let image = VisionImage(buffer: sampleBuffer)
-
- image.orientation = getOrientation(deviceOrientation: UIDevice.current.orientation, cameraPosition: videoInput!.device.position)
-
-
-#if canImport(MLKitBarcodeScanning)
- if(detectorType == .Barcode || detectorType == .All){
- do {
- let result = try self.barcodeScanner?.results(in: image)
- if(result != nil){
- let barCodes = handleBarcodeScanner(result!)
- if(!barCodes.isEmpty) {
- let response = toJSON(barCodes)
- if(response != nil){
- onScanCallback?(response!, TNSMLKitDetectionType.Barcode.string())
+
+ private func resetCurrentFrame() {
+ if isProcessingEveryNthFrame() {
+ self.currentFrame = 0
+ }
+ }
+
+ private func isProcessingEveryNthFrame() -> Bool {
+ return self.processEveryNthFrame > 0
+ }
+
+ private func incrementCurrentFrame() {
+ if isProcessingEveryNthFrame() {
+ self.currentFrame += 1
+ }
+ }
+
+ let context = CIContext()
+
+ public func captureOutput(
+ _ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer,
+ from connection: AVCaptureConnection
+ ) {
+ #if canImport(MLKitVision)
+ if onScanCallback == nil { return }
+ autoreleasepool {
+ let buffer = CMSampleBufferGetImageBuffer(sampleBuffer)
+ guard buffer != nil else { return }
+
+ if self.currentFrame != self.processEveryNthFrame {
+ self.incrementCurrentFrame()
+ return
+ }
+
+ let image = VisionImage(buffer: sampleBuffer)
+
+ let orientation = getOrientation(
+ deviceOrientation: UIDevice.current.orientation,
+ cameraPosition: videoInput!.device.position)
+
+ image.orientation = orientation
+
+ #if canImport(MLKitBarcodeScanning)
+ if detectorType == .Barcode || detectorType == .All {
+ do {
+ let result = try self.barcodeScanner?.results(in: image)
+ if result != nil {
+ let barCodes = handleBarcodeScanner(result!)
+ if !barCodes.isEmpty {
+ let response = toJSON(barCodes)
+ if response != nil {
+ DispatchQueue.main.async {
+ self.onScanCallback!(
+ response!, TNSMLKitDetectionType.Barcode.string())
+ }
+ }
+ }
}
- }
+ } catch {}
}
- } catch {}
- }
-#endif
-
-
-#if canImport(MLKitFaceDetection)
- if(detectorType == .Face || detectorType == .All){
- do {
- let result = try self.faceDetector?.results(in: image)
- if(result != nil){
- let faces = handleFaceDetection(result!)
-
- if(!faces.isEmpty) {
- let response = toJSON(faces)
- if response != nil {
- onScanCallback?(response!, TNSMLKitDetectionType.Face.string())
+ #endif
+
+ #if canImport(MLKitFaceDetection)
+ if detectorType == .Face || detectorType == .All {
+ do {
+ let result = try self.faceDetector?.results(in: image)
+ if result != nil {
+ let faces = handleFaceDetection(result!)
+
+ if !faces.isEmpty {
+ let response = toJSON(faces)
+ if response != nil {
+ DispatchQueue.main.async {
+ self.onScanCallback!(
+ response!, TNSMLKitDetectionType.Face.string())
+ }
+ }
+ }
}
- }
+ } catch {}
}
- } catch {}
- }
-#endif
-
-
-
-#if canImport(MLKitPoseDetection)
- if(detectorType == .Pose || detectorType == .All){
- do {
- let result = try self.poseDetector?.results(in: image)
- if(result != nil){
- let poses = handlePoseDetection(result!)
-
- if(!poses.isEmpty) {
- let response = toJSON(poses)
- if response != nil {
- onScanCallback?(response!, TNSMLKitDetectionType.Pose.string())
+ #endif
+
+ #if canImport(MLKitPoseDetection)
+ if detectorType == .Pose || detectorType == .All {
+ do {
+ let result = try self.poseDetector?.results(in: image)
+ if result != nil {
+ let poses = handlePoseDetection(result!)
+
+ if !poses.isEmpty {
+ let response = toJSON(poses)
+ if response != nil {
+ DispatchQueue.main.async {
+ self.onScanCallback!(
+ response!, TNSMLKitDetectionType.Pose.string())
+ }
+ }
+ }
}
- }
+ } catch {}
}
- } catch {}
- }
-#endif
-
-
-
-#if canImport(MLKitImageLabeling)
- if(detectorType == .Image || detectorType == .All){
- do {
- let result = try self.imageLabeler?.results(in: image)
- if(result != nil){
- let labels = handleImageLabeling(result!)
-
- if(!labels.isEmpty) {
- let response = toJSON(labels)
- if response != nil {
- onScanCallback?(response!, TNSMLKitDetectionType.Image.string())
+ #endif
+
+ #if canImport(MLKitImageLabeling)
+ if detectorType == .Image || detectorType == .All {
+ do {
+ let result = try self.imageLabeler?.results(in: image)
+ if result != nil {
+ let labels = handleImageLabeling(result!)
+
+ if !labels.isEmpty {
+ let response = toJSON(labels)
+ if response != nil {
+ DispatchQueue.main.async {
+ self.onScanCallback!(
+ response!, TNSMLKitDetectionType.Image.string())
+ }
+ }
+ }
}
- }
+ } catch {}
}
- } catch {}
- }
-#endif
-
-
-
-#if canImport(MLKitObjectDetection)
- if(detectorType == .Object || detectorType == .All){
- do {
- let result = try self.objectDetector?.results(in: image)
- if(result != nil){
- let objects = handleObjectDetection(result!)
-
- if(!objects.isEmpty) {
- let response = toJSON(objects)
- if response != nil {
- onScanCallback?(response!, TNSMLKitDetectionType.Object.string())
+ #endif
+
+ #if canImport(MLKitObjectDetection)
+ if detectorType == .Object || detectorType == .All {
+ do {
+ let result = try self.objectDetector?.results(in: image)
+ if result != nil {
+ let objects = handleObjectDetection(result!)
+
+ if !objects.isEmpty {
+ let response = toJSON(objects)
+ if response != nil {
+ DispatchQueue.main.async {
+ self.onScanCallback!(
+ response!, TNSMLKitDetectionType.Object.string())
+ }
+ }
+ }
}
- }
+ } catch {}
}
- } catch {}
- }
-#endif
-
-
-
-
-#if canImport(MLKitTextRecognition)
- if(detectorType == .Text || detectorType == .All){
- do {
- let result = try self.textRecognizer?.results(in: image)
- if(result != nil){
- let texts = handleTextRecognition(result!)
-
- if(!texts.isEmpty) {
- let response = toJSON(texts)
- if response != nil {
- onScanCallback?(response!, TNSMLKitDetectionType.Text.string())
+ #endif
+
+ #if canImport(MLKitObjectDetectionCustom)
+ if detectorType == .CustomObject || detectorType == .All {
+ do {
+ let result = try self.customObjectDetector?.results(in: image)
+ if result != nil {
+ let objects = handleObjectDetection(result!)
+ if !objects.isEmpty {
+ let response = toJSON(objects)
+ if response != nil {
+ DispatchQueue.main.async {
+ self.onScanCallback!(
+ response!,
+ TNSMLKitDetectionType.CustomObject.string())
+ }
+ }
+ }
}
+ } catch let error {
+ print(
+ "Failed to detect object with error \(error.localizedDescription).")
+ return
}
}
- } catch {}
+ #endif
+
+ #if canImport(MLKitTextRecognition)
+ if detectorType == .Text || detectorType == .All {
+ do {
+ let result = try self.textRecognizer?.results(in: image)
+ if result != nil {
+ let texts = handleTextRecognition(result!)
+
+ if !texts.isEmpty {
+ let response = toJSON(texts)
+ if response != nil {
+ DispatchQueue.main.async {
+ self.onScanCallback!(
+ response!, TNSMLKitDetectionType.Text.string())
+ }
+ }
+ }
+ }
+ } catch {}
+ }
+ #endif
+
+ #if canImport(MLKitSegmentationSelfie)
+ if detectorType == .Selfie || detectorType == .All {
+ do {
+ let result = try self.selfieSegmentor?.results(in: image)
+ if result != nil {
+ let mask = result!
+ let maskWidth = CVPixelBufferGetWidth(mask.buffer)
+ let maskHeight = CVPixelBufferGetHeight(mask.buffer)
+
+ CVPixelBufferLockBaseAddress(
+ mask.buffer, CVPixelBufferLockFlags.readOnly)
+ let maskBytesPerRow = CVPixelBufferGetBytesPerRow(mask.buffer)
+ let maskAddress =
+ CVPixelBufferGetBaseAddress(mask.buffer)!.bindMemory(
+ to: Float32.self, capacity: maskBytesPerRow * maskHeight)
+ let data = Data(
+ bytes: maskAddress, count: maskBytesPerRow * maskHeight)
+ var ret: [String: Any] = [:]
+ ret["width"] = maskWidth
+ ret["height"] = maskHeight
+ ret["data"] = data
+
+ DispatchQueue.main.async {
+ self.onScanCallback!(ret, TNSMLKitDetectionType.Selfie.string())
+ }
+
+ }
+ } catch {}
+ }
+ #endif
+ // latest image should be updated only after last plugin finished processing, this ensures that
+ // image will be available till next scan result
+ if retrieveLatestImage {
+ let ciimage = CIImage(cvImageBuffer: buffer!)
+ self._latestImage = UIImage(
+ ciImage: ciimage, scale: 1.0, orientation: orientation)
+ } else {
+ self._latestImage = nil
+ }
+
+ self.resetCurrentFrame()
}
-#endif
-
- }
-
+ #endif
+
}
-
+
}
diff --git a/packages/mlkit-core/project.json b/packages/mlkit-core/project.json
new file mode 100644
index 0000000..1927907
--- /dev/null
+++ b/packages/mlkit-core/project.json
@@ -0,0 +1,62 @@
+{
+ "name": "mlkit-core",
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
+ "projectType": "library",
+ "sourceRoot": "packages/mlkit-core",
+ "targets": {
+ "build": {
+ "executor": "@nx/js:tsc",
+ "options": {
+ "outputPath": "dist/packages/mlkit-core",
+ "tsConfig": "packages/mlkit-core/tsconfig.json",
+ "packageJson": "packages/mlkit-core/package.json",
+ "main": "packages/mlkit-core/index.d.ts",
+ "assets": [
+ "packages/mlkit-core/*.md",
+ "packages/mlkit-core/index.d.ts",
+ "LICENSE",
+ {
+ "glob": "**/*",
+ "input": "packages/mlkit-core/platforms/",
+ "output": "./platforms/"
+ }
+ ]
+ },
+ "dependsOn": [
+ {
+ "target": "build.all",
+ "dependencies": true
+ }
+ ]
+ },
+ "build.all": {
+ "executor": "nx:run-commands",
+ "options": {
+ "commands": ["node tools/scripts/build-finish.ts mlkit-core"],
+ "parallel": false
+ },
+ "outputs": ["{workspaceRoot}/dist/packages/mlkit-core"],
+ "dependsOn": [
+ {
+ "target": "build.all",
+ "dependencies": true
+ },
+
+ {
+ "target": "build",
+ "projects": "self"
+ }
+ ]
+ },
+ "focus": {
+ "executor": "nx:run-commands",
+ "options": {
+ "commands": ["nx g @nativescript/plugin-tools:focus-packages mlkit-core"],
+ "parallel": false
+ }
+ },
+ "lint": {
+ "executor": "@nx/eslint:lint"
+ }
+ }
+}
diff --git a/packages/mlkit-core/typings/android.d.ts b/packages/mlkit-core/typings/android.d.ts
index 06d15eb..38f778f 100644
--- a/packages/mlkit-core/typings/android.d.ts
+++ b/packages/mlkit-core/typings/android.d.ts
@@ -1,1679 +1,1805 @@
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class BuildConfig {
- public static class: java.lang.Class;
- public static DEBUG: boolean;
- public static LIBRARY_PACKAGE_NAME: string;
- public static BUILD_TYPE: string;
- public constructor();
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class BitmapUtils {
+ public static class: java.lang.Class;
+ public static INSTANCE: io.github.triniwiz.fancycamera.BitmapUtils;
+ public getBitmap(nv21Buffer: androidx.camera.core.ImageProxy): globalAndroid.graphics.Bitmap;
+ public getBitmap(stream: java.nio.ByteBuffer, bmp: io.github.triniwiz.fancycamera.FrameMetadata): globalAndroid.graphics.Bitmap;
+ public getBitmap(stream: androidNative.Array, bmp: io.github.triniwiz.fancycamera.FrameMetadata): globalAndroid.graphics.Bitmap;
+ public getBitmapFromContentUri(orientation: globalAndroid.content.ContentResolver, rotationDegrees: globalAndroid.net.Uri): globalAndroid.graphics.Bitmap;
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class Camera extends io.github.triniwiz.fancycamera.CameraBase {
- public static class: java.lang.Class;
- public getDisplayRatio(): string;
- public cameraRecording(): boolean;
- public getAllowExifRotation(): boolean;
- public setMaxVideoFrameRate(param0: number): void;
- public getDisableHEVC(): boolean;
- public getAutoFocus(): boolean;
- public setAllowExifRotation(param0: boolean): void;
- public getQuality(): io.github.triniwiz.fancycamera.Quality;
- public isStarted(): boolean;
- public startPreview(): void;
- public getMaxAudioBitRate(): number;
- public getWhiteBalance(): io.github.triniwiz.fancycamera.WhiteBalance;
- public constructor(param0: globalAndroid.content.Context, param1: globalAndroid.util.AttributeSet);
- public setAutoSquareCrop(param0: boolean): void;
- public setForceStopping(param0: boolean): void;
- public isForceStopping(): boolean;
- public setRotation(param0: io.github.triniwiz.fancycamera.CameraOrientation): void;
- public getAutoSquareCrop(): boolean;
- public setWhiteBalance(param0: io.github.triniwiz.fancycamera.WhiteBalance): void;
- public getPictureSize(): string;
- public getSaveToGallery(): boolean;
- public isRecording(): boolean;
- public startRecording(): void;
- public setDisableHEVC(param0: boolean): void;
- public setCamera(param0: globalAndroid.hardware.Camera): void;
- public setQuality(param0: io.github.triniwiz.fancycamera.Quality): void;
- public getNumberOfCameras(): number;
- public getSupportedRatios(): androidNative.Array;
- public setZoom(param0: number): void;
- public release(): void;
- public getLock(): any;
- public setLock(param0: any): void;
- public setSaveToGallery(param0: boolean): void;
- public setAudioLevelsEnabled(param0: boolean): void;
- public orientationUpdated(): void;
- public getRotation(): io.github.triniwiz.fancycamera.CameraOrientation;
- public setPosition(param0: io.github.triniwiz.fancycamera.CameraPosition): void;
- public stop(): void;
- public isAudioLevelsEnabled(): boolean;
- public setMaxVideoBitrate(param0: number): void;
- public setRecording(param0: boolean): void;
- public getAmplitudeEMA(): number;
- public stopPreview(): void;
- public setStarted(param0: boolean): void;
- public setPictureSize(param0: string): void;
- public getPosition(): io.github.triniwiz.fancycamera.CameraPosition;
- public getFlashMode(): io.github.triniwiz.fancycamera.CameraFlashMode;
- public getMaxVideoBitrate(): number;
- public setFlashMode(param0: io.github.triniwiz.fancycamera.CameraFlashMode): void;
- public getCamera(): globalAndroid.hardware.Camera;
- public getDetectorType(): io.github.triniwiz.fancycamera.DetectorType;
- public takePhoto(): void;
- public getMaxVideoFrameRate(): number;
- public getPreviewSurface(): any;
- public getAmplitude(): number;
- public getZoom(): number;
- public getAvailablePictureSizes(param0: string): androidNative.Array;
- public setAutoFocus(param0: boolean): void;
- public setDisplayRatio(param0: string): void;
- public toggleCamera(): void;
- public stopRecording(): void;
- public constructor(param0: globalAndroid.content.Context, param1: globalAndroid.util.AttributeSet, param2: number);
- public hasFlash(): boolean;
- public constructor(param0: globalAndroid.content.Context);
- public setDetectorType(param0: io.github.triniwiz.fancycamera.DetectorType): void;
- public setMaxAudioBitRate(param0: number): void;
- public getDb(): number;
- }
- export module Camera {
- export class WhenMappings {
- public static class: java.lang.Class;
- }
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class Camera extends io.github.triniwiz.fancycamera.CameraBase {
+ public static class: java.lang.Class;
+ public getDisplayRatio(): string;
+ public cameraRecording(): boolean;
+ public getRetrieveLatestImage(): boolean;
+ public setZoomRatio(value: number): void;
+ public getAllowExifRotation(): boolean;
+ public getDisableHEVC(): boolean;
+ public getAutoFocus(): boolean;
+ public getQuality(): io.github.triniwiz.fancycamera.Quality;
+ public isStarted(): boolean;
+ public startPreview(): void;
+ public getMaxAudioBitRate(): number;
+ public setMaxAudioBitRate(value: number): void;
+ public setAutoSquareCrop(value: boolean): void;
+ public getWhiteBalance(): io.github.triniwiz.fancycamera.WhiteBalance;
+ public getImageProcessors(): androidx.databinding.ObservableList>;
+ public isWideAngleSupported(): boolean;
+ public isForceStopping(): boolean;
+ public setRotation(value: io.github.triniwiz.fancycamera.CameraOrientation): void;
+ public getAutoSquareCrop(): boolean;
+ public getPictureSize(): string;
+ public getSaveToGallery(): boolean;
+ public isRecording(): boolean;
+ public startRecording(): void;
+ public getNumberOfCameras(): number;
+ public getSupportedRatios(): androidNative.Array;
+ public release(): void;
+ public getLock(): any;
+ public setMaxVideoBitrate(value: number): void;
+ public setZoom(value: number): void;
+ public orientationUpdated(): void;
+ public setLock(value: any): void;
+ public getRotation(): io.github.triniwiz.fancycamera.CameraOrientation;
+ public setForceStopping(value: boolean): void;
+ public setQuality(value: io.github.triniwiz.fancycamera.Quality): void;
+ public setDisableHEVC(value: boolean): void;
+ public setWhiteBalance(value: io.github.triniwiz.fancycamera.WhiteBalance): void;
+ public stop(): void;
+ public isAudioLevelsEnabled(): boolean;
+ public constructor(context: globalAndroid.content.Context);
+ public setImageProcessors(value: androidx.databinding.ObservableList>): void;
+ public setRetrieveLatestImage(value: boolean): void;
+ public setDisplayRatio(value: string): void;
+ public getAmplitudeEMA(): number;
+ public stopPreview(): void;
+ public getAvailablePictureSizes(thisCollection$iv: string): androidNative.Array;
+ public setDefaultLens(value: io.github.triniwiz.fancycamera.CameraLens): void;
+ public getPosition(): io.github.triniwiz.fancycamera.CameraPosition;
+ public setEnableTapToFocus(value: boolean): void;
+ public constructor(context: globalAndroid.content.Context, attrs: globalAndroid.util.AttributeSet);
+ public setCamera(value: globalAndroid.hardware.Camera): void;
+ public getFlashMode(): io.github.triniwiz.fancycamera.CameraFlashMode;
+ public setEnablePinchZoom(value: boolean): void;
+ public setMaxVideoFrameRate(value: number): void;
+ public getMaxVideoBitrate(): number;
+ public getCamera(): globalAndroid.hardware.Camera;
+ public takePhoto(): void;
+ public getMaxVideoFrameRate(): number;
+ public getPreviewSurface(): any;
+ public setAllowExifRotation(value: boolean): void;
+ public getAmplitude(): number;
+ public getZoom(): number;
+ public setRecording(value: boolean): void;
+ public getEnableTapToFocus(): boolean;
+ public constructor(callback: globalAndroid.content.Context, attrs: globalAndroid.util.AttributeSet, defStyleAttr: number);
+ public setPause(value: boolean): void;
+ public getEnablePinchZoom(): boolean;
+ public setSaveToGallery(value: boolean): void;
+ public getDefaultLens(): io.github.triniwiz.fancycamera.CameraLens;
+ public setPosition(value: io.github.triniwiz.fancycamera.CameraPosition): void;
+ public toggleCamera(): void;
+ public setStarted(value: boolean): void;
+ public stopRecording(): void;
+ public getPause(): boolean;
+ public hasFlash(): boolean;
+ public setAudioLevelsEnabled(value: boolean): void;
+ public setAutoFocus(value: boolean): void;
+ public getDb(): number;
+ public getZoomRatio(): number;
+ }
+ export namespace Camera {
+ export class WhenMappings {
+ public static class: java.lang.Class;
+ }
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class Camera2 extends io.github.triniwiz.fancycamera.CameraBase {
- public static class: java.lang.Class;
- public getDisplayRatio(): string;
- public cameraRecording(): boolean;
- public getAllowExifRotation(): boolean;
- public setMaxVideoFrameRate(param0: number): void;
- public getDisableHEVC(): boolean;
- public getAutoFocus(): boolean;
- public setAllowExifRotation(param0: boolean): void;
- public getQuality(): io.github.triniwiz.fancycamera.Quality;
- public getMaxAudioBitRate(): number;
- public startPreview(): void;
- public getWhiteBalance(): io.github.triniwiz.fancycamera.WhiteBalance;
- public constructor(param0: globalAndroid.content.Context, param1: globalAndroid.util.AttributeSet);
- public setAutoSquareCrop(param0: boolean): void;
- public setRotation(param0: io.github.triniwiz.fancycamera.CameraOrientation): void;
- public getAutoSquareCrop(): boolean;
- public setWhiteBalance(param0: io.github.triniwiz.fancycamera.WhiteBalance): void;
- public getPictureSize(): string;
- public getSaveToGallery(): boolean;
- public startRecording(): void;
- public setDisableHEVC(param0: boolean): void;
- public getNumberOfCameras(): number;
- public setQuality(param0: io.github.triniwiz.fancycamera.Quality): void;
- public getSupportedRatios(): androidNative.Array;
- public setZoom(param0: number): void;
- public release(): void;
- public setSaveToGallery(param0: boolean): void;
- public setAudioLevelsEnabled(param0: boolean): void;
- public orientationUpdated(): void;
- public getRotation(): io.github.triniwiz.fancycamera.CameraOrientation;
- public setPosition(param0: io.github.triniwiz.fancycamera.CameraPosition): void;
- public setAmplitude(param0: number): void;
- public isAudioLevelsEnabled(): boolean;
- public stop(): void;
- public setMaxVideoBitrate(param0: number): void;
- public setAmplitudeEMA(param0: number): void;
- public getAmplitudeEMA(): number;
- public stopPreview(): void;
- public setPictureSize(param0: string): void;
- public getPosition(): io.github.triniwiz.fancycamera.CameraPosition;
- public setDb(param0: number): void;
- public getFlashMode(): io.github.triniwiz.fancycamera.CameraFlashMode;
- public getMaxVideoBitrate(): number;
- public setFlashMode(param0: io.github.triniwiz.fancycamera.CameraFlashMode): void;
- public getDetectorType(): io.github.triniwiz.fancycamera.DetectorType;
- public getMaxVideoFrameRate(): number;
- public takePhoto(): void;
- public getPreviewSurface(): any;
- public getAmplitude(): number;
- public getZoom(): number;
- public getAvailablePictureSizes(param0: string): androidNative.Array;
- public setAutoFocus(param0: boolean): void;
- public setDisplayRatio(param0: string): void;
- public toggleCamera(): void;
- public stopRecording(): void;
- public constructor(param0: globalAndroid.content.Context, param1: globalAndroid.util.AttributeSet, param2: number);
- public hasFlash(): boolean;
- public constructor(param0: globalAndroid.content.Context);
- public setDetectorType(param0: io.github.triniwiz.fancycamera.DetectorType): void;
- public setMaxAudioBitRate(param0: number): void;
- public getDb(): number;
- }
- export module Camera2 {
- export class WhenMappings {
- public static class: java.lang.Class;
- }
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class Camera2 extends io.github.triniwiz.fancycamera.CameraBase {
+ public static class: java.lang.Class;
+ public setEnablePinchZoom(value: boolean): void;
+ public constructor(callback: globalAndroid.content.Context, $this$imageProcessors_u24lambda_u240: globalAndroid.util.AttributeSet, $i$f$afterMeasured: number);
+ public getDisplayRatio(): string;
+ public cameraRecording(): boolean;
+ public getMinZoomRatio(): number;
+ public getRetrieveLatestImage(): boolean;
+ public getAllowExifRotation(): boolean;
+ public getDisableHEVC(): boolean;
+ public getAutoFocus(): boolean;
+ public getQuality(): io.github.triniwiz.fancycamera.Quality;
+ public getMaxAudioBitRate(): number;
+ public setMaxAudioBitRate(value: number): void;
+ public startPreview(): void;
+ public setFlashMode(test: io.github.triniwiz.fancycamera.CameraFlashMode): void;
+ public setAutoSquareCrop(value: boolean): void;
+ public setStoredZoom(value: number): void;
+ public getWhiteBalance(): io.github.triniwiz.fancycamera.WhiteBalance;
+ public getImageProcessors(): androidx.databinding.ObservableList>;
+ public isWideAngleSupported(): boolean;
+ public setAmplitudeEMA(value: number): void;
+ public setRotation(value: io.github.triniwiz.fancycamera.CameraOrientation): void;
+ public getAutoSquareCrop(): boolean;
+ public getDeviceCameraInfo(): java.util.List;
+ public getPictureSize(): string;
+ public getSaveToGallery(): boolean;
+ public setPosition(value: io.github.triniwiz.fancycamera.CameraPosition): void;
+ public startRecording(): void;
+ public setQuality(wasBound: io.github.triniwiz.fancycamera.Quality): void;
+ public getNumberOfCameras(): number;
+ public getBackCameraId(): string;
+ public getSupportedRatios(): androidNative.Array;
+ public release(): void;
+ public setMaxVideoBitrate(value: number): void;
+ public setZoom(value: number): void;
+ public orientationUpdated(): void;
+ public getRotation(): io.github.triniwiz.fancycamera.CameraOrientation;
+ public setCameraWithId(id: string): void;
+ public setDisableHEVC(value: boolean): void;
+ public setWhiteBalance(value: io.github.triniwiz.fancycamera.WhiteBalance): void;
+ public isAudioLevelsEnabled(): boolean;
+ public stop(): void;
+ public constructor(context: globalAndroid.content.Context);
+ public setImageProcessors(value: androidx.databinding.ObservableList>): void;
+ public setZoomRatio(value: number): void;
+ public setRetrieveLatestImage(value: boolean): void;
+ public setDisplayRatio(value: string): void;
+ public getAmplitudeEMA(): number;
+ public stopPreview(): void;
+ public getAvailablePictureSizes(thisCollection$iv: string): androidNative.Array;
+ public setDb(value: number): void;
+ public getPosition(): io.github.triniwiz.fancycamera.CameraPosition;
+ public setEnableTapToFocus(value: boolean): void;
+ public constructor(context: globalAndroid.content.Context, attrs: globalAndroid.util.AttributeSet);
+ public getMaxZoomRatio(): number;
+ public setExternalCameraId(value: string): void;
+ public getFlashMode(): io.github.triniwiz.fancycamera.CameraFlashMode;
+ public setMaxVideoFrameRate(value: number): void;
+ public getMaxVideoBitrate(): number;
+ public getCurrentCameraInfo(): io.github.triniwiz.fancycamera.Camera2.CameraInfo;
+ public getMaxVideoFrameRate(): number;
+ public takePhoto(): void;
+ public getPreviewSurface(): any;
+ public setAllowExifRotation(value: boolean): void;
+ public getAmplitude(): number;
+ public getZoom(): number;
+ public getExternalCameraId(): string;
+ public getEnableTapToFocus(): boolean;
+ public getStoredZoom(): number;
+ public getEnablePinchZoom(): boolean;
+ public setPause(value: boolean): void;
+ public setSaveToGallery(value: boolean): void;
+ public setAmplitude(value: number): void;
+ public getDefaultLens(): io.github.triniwiz.fancycamera.CameraLens;
+ public toggleCamera(): void;
+ public stopRecording(): void;
+ public getPause(): boolean;
+ public hasFlash(): boolean;
+ public setAutoFocus(value: boolean): void;
+ public setDefaultLens(value: io.github.triniwiz.fancycamera.CameraLens): void;
+ public getStoredZoomRatio(): number;
+ public setStoredZoomRatio(value: number): void;
+ public getDb(): number;
+ public setAudioLevelsEnabled(value: boolean): void;
+ public getFrontCameraId(): string;
+ public getZoomRatio(): number;
+ }
+ export namespace Camera2 {
+ export class Camera2CameraCharacteristicsImpl extends io.github.triniwiz.fancycamera.Camera2.CameraCharacteristicsImpl {
+ public static class: java.lang.Class;
+ public constructor(characteristics: globalAndroid.hardware.camera2.CameraCharacteristics);
+ public getCameraCharacteristic(param0: globalAndroid.hardware.camera2.CameraCharacteristics.Key): any;
+ public getCameraCharacteristic(key: globalAndroid.hardware.camera2.CameraCharacteristics.Key): any;
+ }
+ export class CameraCharacteristicsImpl {
+ public static class: java.lang.Class;
+ /**
+ * Constructs a new instance of the io.github.triniwiz.fancycamera.Camera2$CameraCharacteristicsImpl interface with the provided implementation. An empty constructor exists calling super() when extending the interface class.
+ */
+ public constructor(implementation: { getCameraCharacteristic(param0: globalAndroid.hardware.camera2.CameraCharacteristics.Key): any });
+ public constructor();
+ public getCameraCharacteristic(param0: globalAndroid.hardware.camera2.CameraCharacteristics.Key): any;
+ }
+ export class CameraInfo {
+ public static class: java.lang.Class;
+ public getMaxZoom(): number;
+ public getMinZoom(): number;
+ public getFocalLengths(): androidNative.Array;
+ public toString(): string;
+ public getActiveSize(): globalAndroid.graphics.Rect;
+ public getLensFacing(): number;
+ public constructor(id: string, implementationType: string, characteristics: io.github.triniwiz.fancycamera.Camera2.CameraCharacteristicsImpl);
+ public getZoomRange(): globalAndroid.util.Range;
+ public getId(): string;
+ public getMaxDigitalZoom(): number;
+ public getImplementationType(): string;
+ public getCapabilities(): androidNative.Array;
+ public getHardwareLevel(): number;
+ }
+ export class CameraxCameraCharacteristicsImpl extends io.github.triniwiz.fancycamera.Camera2.CameraCharacteristicsImpl {
+ public static class: java.lang.Class;
+ public constructor(characteristics: androidx.camera.camera2.interop.Camera2CameraInfo);
+ public getCameraCharacteristic(param0: globalAndroid.hardware.camera2.CameraCharacteristics.Key): any;
+ public getCameraCharacteristic(key: globalAndroid.hardware.camera2.CameraCharacteristics.Key): any;
+ }
+ export class WhenMappings {
+ public static class: java.lang.Class;
+ }
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export abstract class CameraBase {
- public static class: java.lang.Class;
- public static Companion: io.github.triniwiz.fancycamera.CameraBase.Companion;
- public setFaceDetectionOptions(param0: any): void;
- public setMTimerTask$fancycamera_release(param0: java.util.TimerTask): void;
- public getAllowExifRotation(): boolean;
- public setOnBarcodeScanningListener$fancycamera_release(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- public setCurrentOrientation(param0: number): void;
- public finalize(): void;
- public setMaxVideoFrameRate(param0: number): void;
- public isObjectDetectionSupported$fancycamera_release(): boolean;
- public getAutoFocus(): boolean;
- public setAllowExifRotation(param0: boolean): void;
- public startPreview(): void;
- public isMLSupported$fancycamera_release(): boolean;
- public getDATETIME_FORMAT$fancycamera_release(): java.lang.ThreadLocal;
- public setOverridePhotoWidth(param0: number): void;
- public constructor(param0: globalAndroid.content.Context, param1: globalAndroid.util.AttributeSet);
- public isFaceDetectionSupported$fancycamera_release(): boolean;
- public setAutoSquareCrop(param0: boolean): void;
- public setRotation(param0: io.github.triniwiz.fancycamera.CameraOrientation): void;
- public setOverridePhotoHeight(param0: number): void;
- public setOnTextRecognitionListener(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- public getOnPoseDetectedListener$fancycamera_release(): io.github.triniwiz.fancycamera.ImageAnalysisCallback;
- public getSaveToGallery(): boolean;
- public setGettingAudioLevels$fancycamera_release(param0: boolean): void;
- public getImageLabelingOptions$fancycamera_release(): any;
- public setQuality(param0: io.github.triniwiz.fancycamera.Quality): void;
- public setListener$fancycamera_release(param0: io.github.triniwiz.fancycamera.CameraEventListener): void;
- public getSupportedRatios(): androidNative.Array;
- public hasCameraPermission(): boolean;
- public setSaveToGallery(param0: boolean): void;
- public setAudioLevelsEnabled(param0: boolean): void;
- public orientationUpdated(): void;
- public setOnTextRecognitionListener$fancycamera_release(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- public getDATE_FORMAT$fancycamera_release(): java.lang.ThreadLocal;
- public getAnalysisExecutor$fancycamera_release(): java.util.concurrent.ExecutorService;
- public getObjectDetectionOptions$fancycamera_release(): any;
- public setOnImageLabelingListener(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- public setImageLabelingSupported$fancycamera_release(param0: boolean): void;
- public getOnSurfaceUpdateListener$fancycamera_release(): io.github.triniwiz.fancycamera.SurfaceUpdateListener;
- public getMDuration$fancycamera_release(): number;
- public getPosition(): io.github.triniwiz.fancycamera.CameraPosition;
- public setFaceDetectionSupported$fancycamera_release(param0: boolean): void;
- public setBarcodeScannerOptions$fancycamera_release(param0: any): void;
- public getMainHandler$fancycamera_release(): globalAndroid.os.Handler;
- public setAnalysisExecutor$fancycamera_release(param0: java.util.concurrent.ExecutorService): void;
- public startDurationTimer$fancycamera_release(): void;
- public stopDurationTimer$fancycamera_release(): void;
- public getDuration(): number;
- public requestAudioPermission(): void;
- public hasAudioPermission(): boolean;
- public getOnBarcodeScanningListener$fancycamera_release(): io.github.triniwiz.fancycamera.ImageAnalysisCallback;
- public getMaxVideoBitrate(): number;
- public setonSurfaceUpdateListener(param0: io.github.triniwiz.fancycamera.SurfaceUpdateListener): void;
- public isBarcodeScanningSupported$fancycamera_release(): boolean;
- public getFaceDetectionOptions$fancycamera_release(): any;
- public setFlashMode(param0: io.github.triniwiz.fancycamera.CameraFlashMode): void;
- public getMTimerTask$fancycamera_release(): java.util.TimerTask;
- public setRecorder$fancycamera_release(param0: globalAndroid.media.MediaRecorder): void;
- public getDetectorType(): io.github.triniwiz.fancycamera.DetectorType;
- public setTextRecognitionSupported$fancycamera_release(param0: boolean): void;
- public getMaxVideoFrameRate(): number;
- public takePhoto(): void;
- public stringSizeToSize$fancycamera_release(param0: string): io.github.triniwiz.fancycamera.Size;
- public getAvailablePictureSizes(param0: string): androidNative.Array;
- public getRecorder$fancycamera_release(): globalAndroid.media.MediaRecorder;
- public setAutoFocus(param0: boolean): void;
- public convertToExifDateTime$fancycamera_release(param0: number): string;
- public setOnFacesDetectedListener$fancycamera_release(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- public setImageLabelingOptions(param0: any): void;
- public setOnPoseDetectedListener$fancycamera_release(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- public initListener$fancycamera_release(param0: globalAndroid.media.MediaRecorder): void;
- public getVIDEO_RECORDER_PERMISSIONS_REQUEST$fancycamera_release(): number;
- public stopRecording(): void;
- public hasFlash(): boolean;
- public constructor(param0: globalAndroid.content.Context);
- public setDetectorType(param0: io.github.triniwiz.fancycamera.DetectorType): void;
- public setMaxAudioBitRate(param0: number): void;
- public getDb(): number;
- public setBarcodeScannerOptions(param0: any): void;
- public getBarcodeScannerOptions$fancycamera_release(): any;
- public cameraRecording(): boolean;
- public getDisplayRatio(): string;
- public isImageLabelingSupported$fancycamera_release(): boolean;
- public deInitListener$fancycamera_release(): void;
- public toggleFlash(): void;
- public getDisableHEVC(): boolean;
- public getQuality(): io.github.triniwiz.fancycamera.Quality;
- public requestCameraPermission(): void;
- public getMaxAudioBitRate(): number;
- public setOnObjectDetectedListener$fancycamera_release(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- public getWhiteBalance(): io.github.triniwiz.fancycamera.WhiteBalance;
- public setObjectDetectionOptions$fancycamera_release(param0: any): void;
- public getTIME_FORMAT$fancycamera_release(): java.lang.ThreadLocal;
- public hasStoragePermission(): boolean;
- public setMTimer$fancycamera_release(param0: java.util.Timer): void;
- public getListener$fancycamera_release(): io.github.triniwiz.fancycamera.CameraEventListener;
- public getAutoSquareCrop(): boolean;
- public getOverridePhotoWidth(): number;
- public setWhiteBalance(param0: io.github.triniwiz.fancycamera.WhiteBalance): void;
- public getPictureSize(): string;
- public startRecording(): void;
- public setDisableHEVC(param0: boolean): void;
- public setOnSurfaceUpdateListener$fancycamera_release(param0: io.github.triniwiz.fancycamera.SurfaceUpdateListener): void;
- public detectSupport$fancycamera_release(): void;
- public setObjectDetectionSupported$fancycamera_release(param0: boolean): void;
- public getNumberOfCameras(): number;
- public setZoom(param0: number): void;
- public requestPermission(): void;
- public release(): void;
- public getOnTextRecognitionListener$fancycamera_release(): io.github.triniwiz.fancycamera.ImageAnalysisCallback;
- public getRotation(): io.github.triniwiz.fancycamera.CameraOrientation;
- public isGettingAudioLevels$fancycamera_release(): boolean;
- public setPosition(param0: io.github.triniwiz.fancycamera.CameraPosition): void;
- public getOnFacesDetectedListener$fancycamera_release(): io.github.triniwiz.fancycamera.ImageAnalysisCallback;
- public getCamcorderProfile$fancycamera_release(param0: io.github.triniwiz.fancycamera.Quality): globalAndroid.media.CamcorderProfile;
- public setOnObjectDetectedListener(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- public isAudioLevelsEnabled(): boolean;
- public stop(): void;
- public setPoseDetectionSupported$fancycamera_release(param0: boolean): void;
- public setMaxVideoBitrate(param0: number): void;
- public getOnImageLabelingListener$fancycamera_release(): io.github.triniwiz.fancycamera.ImageAnalysisCallback;
- public getAmplitudeEMA(): number;
- public setOnBarcodeScanningListener(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- public stopPreview(): void;
- public getMTimer$fancycamera_release(): java.util.Timer;
- public getOnObjectDetectedListener$fancycamera_release(): io.github.triniwiz.fancycamera.ImageAnalysisCallback;
- public getOverridePhotoHeight(): number;
- public setObjectDetectionOptions(param0: any): void;
- public setPictureSize(param0: string): void;
- public setImageLabelingOptions$fancycamera_release(param0: any): void;
- public getFlashMode(): io.github.triniwiz.fancycamera.CameraFlashMode;
- public convertFromExifDateTime$fancycamera_release(param0: string): java.util.Date;
- public hasPermission(): boolean;
- public isPoseDetectionSupported$fancycamera_release(): boolean;
- public getPreviewSurface(): any;
- public getAmplitude(): number;
- public getZoom(): number;
- public getVIDEO_RECORDER_PERMISSIONS$fancycamera_release(): androidNative.Array;
- public setDisplayRatio(param0: string): void;
- public requestStoragePermission(): void;
- public toggleCamera(): void;
- public constructor(param0: globalAndroid.content.Context, param1: globalAndroid.util.AttributeSet, param2: number);
- public setOnPoseDetectedListener(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- public setMDuration$fancycamera_release(param0: number): void;
- public setOnImageLabelingListener$fancycamera_release(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- public setBarcodeScanningSupported$fancycamera_release(param0: boolean): void;
- public setFaceDetectionOptions$fancycamera_release(param0: any): void;
- public getCurrentOrientation(): number;
- public isTextRecognitionSupported$fancycamera_release(): boolean;
- public setOnFacesDetectedListener(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- }
- export module CameraBase {
- export class Companion {
- public static class: java.lang.Class;
- public getEMA_FILTER$fancycamera_release(): number;
- }
- export class WhenMappings {
- public static class: java.lang.Class;
- }
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export abstract class CameraBase {
+ public static class: java.lang.Class;
+ public setOnImageLabelingListener$fancycamera_release(value: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public setPause(param0: boolean): void;
+ public getAllowExifRotation(): boolean;
+ public setLatestImage$fancycamera_release(value: globalAndroid.graphics.Bitmap): void;
+ public finalize(): void;
+ public setMaxVideoFrameRate(param0: number): void;
+ public getAutoFocus(): boolean;
+ public setOnImageLabelingListener(callback: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public setEnableAudio(value: boolean): void;
+ public setAllowExifRotation(param0: boolean): void;
+ public startPreview(): void;
+ public getDATETIME_FORMAT$fancycamera_release(): java.lang.ThreadLocal;
+ public setAutoSquareCrop(param0: boolean): void;
+ public setOnSelfieSegmentationListener(callback: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public isWideAngleSupported(): boolean;
+ public setRotation(param0: io.github.triniwiz.fancycamera.CameraOrientation): void;
+ public getCamcorderProfile$fancycamera_release(profile: io.github.triniwiz.fancycamera.Quality): globalAndroid.media.CamcorderProfile;
+ public setOnFacesDetectedListener$fancycamera_release(value: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public getOnPoseDetectedListener$fancycamera_release(): io.github.triniwiz.fancycamera.ImageAnalysisCallback;
+ public getSaveToGallery(): boolean;
+ public setOnObjectDetectedListener$fancycamera_release(value: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public setQuality(param0: io.github.triniwiz.fancycamera.Quality): void;
+ public setListener$fancycamera_release(value: io.github.triniwiz.fancycamera.CameraEventListener): void;
+ public getSupportedRatios(): androidNative.Array;
+ public hasCameraPermission(): boolean;
+ public setOnBarcodeScanningListener(callback: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public setSaveToGallery(param0: boolean): void;
+ public setAudioLevelsEnabled(param0: boolean): void;
+ public setOnPoseDetectedListener$fancycamera_release(value: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public setOnBarcodeScanningListener$fancycamera_release(value: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public setMTimerTask$fancycamera_release(value: java.util.TimerTask): void;
+ public orientationUpdated(): void;
+ public convertFromExifDateTime$fancycamera_release(dateTime: string): java.util.Date;
+ public getOnSelfieSegmentationListener$fancycamera_release(): io.github.triniwiz.fancycamera.ImageAnalysisCallback;
+ public getDATE_FORMAT$fancycamera_release(): java.lang.ThreadLocal;
+ public setCurrentOrientation(value: number): void;
+ public constructor(context: globalAndroid.content.Context);
+ public getCurrentFrame$fancycamera_release(): number;
+ public setRecorder$fancycamera_release(value: globalAndroid.media.MediaRecorder): void;
+ public getOnSurfaceUpdateListener$fancycamera_release(): io.github.triniwiz.fancycamera.SurfaceUpdateListener;
+ public getMDuration$fancycamera_release(): number;
+ public setRetrieveLatestImage(param0: boolean): void;
+ public getPosition(): io.github.triniwiz.fancycamera.CameraPosition;
+ public resetCurrentFrame$fancycamera_release(): void;
+ public constructor(context: globalAndroid.content.Context, attrs: globalAndroid.util.AttributeSet);
+ public getProcessEveryNthFrame(): number;
+ public getMainHandler$fancycamera_release(): globalAndroid.os.Handler;
+ public startDurationTimer$fancycamera_release(): void;
+ public stopDurationTimer$fancycamera_release(): void;
+ public getDuration(): number;
+ public requestAudioPermission(): void;
+ public hasAudioPermission(): boolean;
+ public getOnBarcodeScanningListener$fancycamera_release(): io.github.triniwiz.fancycamera.ImageAnalysisCallback;
+ public constructor(context: globalAndroid.content.Context, attrs: globalAndroid.util.AttributeSet, defStyleAttr: number);
+ public getMaxVideoBitrate(): number;
+ public initListener$fancycamera_release(instance: globalAndroid.media.MediaRecorder): void;
+ public setFlashMode(param0: io.github.triniwiz.fancycamera.CameraFlashMode): void;
+ public getMTimerTask$fancycamera_release(): java.util.TimerTask;
+ public getMaxVideoFrameRate(): number;
+ public takePhoto(): void;
+ public setOnTextRecognitionListener(callback: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public getAvailablePictureSizes(param0: string): androidNative.Array;
+ public getRecorder$fancycamera_release(): globalAndroid.media.MediaRecorder;
+ public setAutoFocus(param0: boolean): void;
+ public getEnableTapToFocus(): boolean;
+ public getEnablePinchZoom(): boolean;
+ public setonSurfaceUpdateListener(callback: io.github.triniwiz.fancycamera.SurfaceUpdateListener): void;
+ public getVIDEO_RECORDER_PERMISSIONS_REQUEST$fancycamera_release(): number;
+ public stopRecording(): void;
+ public hasFlash(): boolean;
+ public getEnableAudio(): boolean;
+ public setMaxAudioBitRate(param0: number): void;
+ public getDb(): number;
+ public convertToExifDateTime$fancycamera_release(timestamp: number): string;
+ public stringSizeToSize$fancycamera_release(width: string): io.github.triniwiz.fancycamera.Size;
+ public cameraRecording(): boolean;
+ public getDisplayRatio(): string;
+ public getRetrieveLatestImage(): boolean;
+ public deInitListener$fancycamera_release(): void;
+ public setEnablePinchZoom(param0: boolean): void;
+ public toggleFlash(): void;
+ public getDisableHEVC(): boolean;
+ public getQuality(): io.github.triniwiz.fancycamera.Quality;
+ public requestCameraPermission(): void;
+ public getMaxAudioBitRate(): number;
+ public getWhiteBalance(): io.github.triniwiz.fancycamera.WhiteBalance;
+ public getImageProcessors(): androidx.databinding.ObservableList>;
+ public getTIME_FORMAT$fancycamera_release(): java.lang.ThreadLocal;
+ public hasStoragePermission(): boolean;
+ public getListener$fancycamera_release(): io.github.triniwiz.fancycamera.CameraEventListener;
+ public isProcessingEveryNthFrame$fancycamera_release(): boolean;
+ public getAutoSquareCrop(): boolean;
+ public getLatestImage$fancycamera_release(): globalAndroid.graphics.Bitmap;
+ public getOverridePhotoWidth(): number;
+ public setWhiteBalance(param0: io.github.triniwiz.fancycamera.WhiteBalance): void;
+ public getPictureSize(): string;
+ public startRecording(): void;
+ public setDisableHEVC(param0: boolean): void;
+ public incrementCurrentFrame$fancycamera_release(): void;
+ public setCurrentFrame$fancycamera_release(value: number): void;
+ public getNumberOfCameras(): number;
+ public setZoom(param0: number): void;
+ public requestPermission(): void;
+ public release(): void;
+ public getOnTextRecognitionListener$fancycamera_release(): io.github.triniwiz.fancycamera.ImageAnalysisCallback;
+ public setOnSelfieSegmentationListener$fancycamera_release(value: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public setGettingAudioLevels$fancycamera_release(value: boolean): void;
+ public getRotation(): io.github.triniwiz.fancycamera.CameraOrientation;
+ public isGettingAudioLevels$fancycamera_release(): boolean;
+ public setPosition(param0: io.github.triniwiz.fancycamera.CameraPosition): void;
+ public getOnFacesDetectedListener$fancycamera_release(): io.github.triniwiz.fancycamera.ImageAnalysisCallback;
+ public isAudioLevelsEnabled(): boolean;
+ public setOverridePhotoHeight(value: number): void;
+ public stop(): void;
+ public setMaxVideoBitrate(param0: number): void;
+ public getOnImageLabelingListener$fancycamera_release(): io.github.triniwiz.fancycamera.ImageAnalysisCallback;
+ public getAmplitudeEMA(): number;
+ public stopPreview(): void;
+ public setMTimer$fancycamera_release(value: java.util.Timer): void;
+ public getMTimer$fancycamera_release(): java.util.Timer;
+ public getOnObjectDetectedListener$fancycamera_release(): io.github.triniwiz.fancycamera.ImageAnalysisCallback;
+ public getOverridePhotoHeight(): number;
+ public setPictureSize(param0: string): void;
+ public setProcessEveryNthFrame(value: number): void;
+ public setOnFacesDetectedListener(callback: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public setDefaultLens(param0: io.github.triniwiz.fancycamera.CameraLens): void;
+ public getFlashMode(): io.github.triniwiz.fancycamera.CameraFlashMode;
+ public setZoomRatio(param0: number): void;
+ public hasPermission(): boolean;
+ public setOnObjectDetectedListener(callback: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public setOnSurfaceUpdateListener$fancycamera_release(value: io.github.triniwiz.fancycamera.SurfaceUpdateListener): void;
+ public getPreviewSurface(): any;
+ public getAmplitude(): number;
+ public getZoom(): number;
+ public getVIDEO_RECORDER_PERMISSIONS$fancycamera_release(): androidNative.Array;
+ public setDisplayRatio(param0: string): void;
+ public requestStoragePermission(): void;
+ public getDefaultLens(): io.github.triniwiz.fancycamera.CameraLens;
+ public toggleCamera(): void;
+ public setEnableTapToFocus(param0: boolean): void;
+ public getPause(): boolean;
+ public setOnTextRecognitionListener$fancycamera_release(value: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public setMDuration$fancycamera_release(value: number): void;
+ public setOverridePhotoWidth(value: number): void;
+ public getCurrentOrientation(): number;
+ public setOnPoseDetectedListener(callback: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public getZoomRatio(): number;
+ }
+ export namespace CameraBase {
+ export class Companion {
+ public static class: java.lang.Class;
+ public getEMA_FILTER$fancycamera_release(): number;
+ }
+ export class WhenMappings {
+ public static class: java.lang.Class;
+ }
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class CameraEventListener {
- public static class: java.lang.Class;
- /**
- * Constructs a new instance of the io.github.triniwiz.fancycamera.CameraEventListener interface with the provided implementation. An empty constructor exists calling super() when extending the interface class.
- */
- public constructor(implementation: {
- onReady(): void;
- onCameraOpen(): void;
- onCameraClose(): void;
- onCameraPhoto(param0: java.io.File): void;
- onCameraVideo(param0: java.io.File): void;
- onCameraAnalysis(param0: io.github.triniwiz.fancycamera.ImageAnalysis): void;
- onCameraError(param0: string, param1: java.lang.Exception): void;
- onCameraVideoStart(): void;
- });
- public constructor();
- public onCameraOpen(): void;
- public onCameraClose(): void;
- public onCameraAnalysis(param0: io.github.triniwiz.fancycamera.ImageAnalysis): void;
- public onCameraVideo(param0: java.io.File): void;
- public onCameraVideoStart(): void;
- public onReady(): void;
- public onCameraError(param0: string, param1: java.lang.Exception): void;
- public onCameraPhoto(param0: java.io.File): void;
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class CameraEventListener {
+ public static class: java.lang.Class;
+ /**
+ * Constructs a new instance of the io.github.triniwiz.fancycamera.CameraEventListener interface with the provided implementation. An empty constructor exists calling super() when extending the interface class.
+ */
+ public constructor(implementation: { onReady(): void; onCameraOpen(): void; onCameraClose(): void; onCameraPhoto(param0: java.io.File): void; onCameraVideo(param0: java.io.File): void; onCameraAnalysis(param0: io.github.triniwiz.fancycamera.ImageAnalysis): void; onCameraError(param0: string, param1: java.lang.Exception): void; onCameraVideoStart(): void });
+ public constructor();
+ public onCameraOpen(): void;
+ public onCameraClose(): void;
+ public onCameraAnalysis(param0: io.github.triniwiz.fancycamera.ImageAnalysis): void;
+ public onCameraVideo(param0: java.io.File): void;
+ public onCameraVideoStart(): void;
+ public onReady(): void;
+ public onCameraError(param0: string, param1: java.lang.Exception): void;
+ public onCameraPhoto(param0: java.io.File): void;
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export abstract class CameraEventListenerUI extends io.github.triniwiz.fancycamera.CameraEventListener {
- public static class: java.lang.Class;
- public static Companion: io.github.triniwiz.fancycamera.CameraEventListenerUI.Companion;
- public onCameraOpenUI(): void;
- public onCameraClose(): void;
- public onCameraVideoUI(param0: java.io.File): void;
- public onCameraError(param0: string, param1: java.lang.Exception): void;
- public onCameraAnalysisUI(param0: io.github.triniwiz.fancycamera.ImageAnalysis): void;
- public onCameraErrorUI(param0: string, param1: java.lang.Exception): void;
- public onCameraPhoto(param0: java.io.File): void;
- public onCameraVideoStartUI(): void;
- public onReadyUI(): void;
- public onCameraOpen(): void;
- public onCameraAnalysis(param0: io.github.triniwiz.fancycamera.ImageAnalysis): void;
- public onCameraVideo(param0: java.io.File): void;
- public onCameraVideoStart(): void;
- public onCameraCloseUI(): void;
- public constructor();
- public onReady(): void;
- public onCameraPhotoUI(param0: java.io.File): void;
- }
- export module CameraEventListenerUI {
- export class Companion {
- public static class: java.lang.Class;
- }
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export abstract class CameraEventListenerUI extends io.github.triniwiz.fancycamera.CameraEventListener {
+ public static class: java.lang.Class;
+ public onCameraOpenUI(): void;
+ public onCameraPhoto(bundle: java.io.File): void;
+ public onCameraClose(): void;
+ public onCameraVideoUI(param0: java.io.File): void;
+ public onCameraError(param0: string, param1: java.lang.Exception): void;
+ public onCameraAnalysisUI(param0: io.github.triniwiz.fancycamera.ImageAnalysis): void;
+ public onCameraErrorUI(param0: string, param1: java.lang.Exception): void;
+ public onCameraVideoStartUI(): void;
+ public onReadyUI(): void;
+ public onCameraOpen(): void;
+ public onCameraAnalysis(param0: io.github.triniwiz.fancycamera.ImageAnalysis): void;
+ public onCameraVideo(param0: java.io.File): void;
+ public constructor();
+ public onCameraVideoStart(): void;
+ public onCameraCloseUI(): void;
+ public onReady(): void;
+ public onCameraPhotoUI(param0: java.io.File): void;
+ }
+ export namespace CameraEventListenerUI {
+ export class Companion {
+ public static class: java.lang.Class;
+ }
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class CameraFlashMode {
- public static class: java.lang.Class;
- public static OFF: io.github.triniwiz.fancycamera.CameraFlashMode;
- public static ON: io.github.triniwiz.fancycamera.CameraFlashMode;
- public static AUTO: io.github.triniwiz.fancycamera.CameraFlashMode;
- public static RED_EYE: io.github.triniwiz.fancycamera.CameraFlashMode;
- public static TORCH: io.github.triniwiz.fancycamera.CameraFlashMode;
- public static Companion: io.github.triniwiz.fancycamera.CameraFlashMode.Companion;
- public static valueOf(param0: string): io.github.triniwiz.fancycamera.CameraFlashMode;
- public static values(): androidNative.Array;
- public getValue(): number;
- }
- export module CameraFlashMode {
- export class Companion {
- public static class: java.lang.Class;
- public from(param0: number): io.github.triniwiz.fancycamera.CameraFlashMode;
- }
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class CameraFlashMode {
+ public static class: java.lang.Class;
+ public static OFF: io.github.triniwiz.fancycamera.CameraFlashMode;
+ public static ON: io.github.triniwiz.fancycamera.CameraFlashMode;
+ public static AUTO: io.github.triniwiz.fancycamera.CameraFlashMode;
+ public static RED_EYE: io.github.triniwiz.fancycamera.CameraFlashMode;
+ public static TORCH: io.github.triniwiz.fancycamera.CameraFlashMode;
+ public static values(): androidNative.Array;
+ public getValue(): number;
+ public static valueOf(value: string): io.github.triniwiz.fancycamera.CameraFlashMode;
+ }
+ export namespace CameraFlashMode {
+ export class Companion {
+ public static class: java.lang.Class;
+ public from(it: number): io.github.triniwiz.fancycamera.CameraFlashMode;
+ }
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class CameraOrientation {
- public static class: java.lang.Class;
- public static UNKNOWN: io.github.triniwiz.fancycamera.CameraOrientation;
- public static PORTRAIT: io.github.triniwiz.fancycamera.CameraOrientation;
- public static PORTRAIT_UPSIDE_DOWN: io.github.triniwiz.fancycamera.CameraOrientation;
- public static LANDSCAPE_LEFT: io.github.triniwiz.fancycamera.CameraOrientation;
- public static LANDSCAPE_RIGHT: io.github.triniwiz.fancycamera.CameraOrientation;
- public static Companion: io.github.triniwiz.fancycamera.CameraOrientation.Companion;
- public static values(): androidNative.Array;
- public static valueOf(param0: string): io.github.triniwiz.fancycamera.CameraOrientation;
- public getValue(): number;
- }
- export module CameraOrientation {
- export class Companion {
- public static class: java.lang.Class;
- public from(param0: number): io.github.triniwiz.fancycamera.CameraOrientation;
- }
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class CameraLens {
+ public static class: java.lang.Class;
+ public static auto: io.github.triniwiz.fancycamera.CameraLens;
+ public static telephoto: io.github.triniwiz.fancycamera.CameraLens;
+ public static wide: io.github.triniwiz.fancycamera.CameraLens;
+ public static ultrawide: io.github.triniwiz.fancycamera.CameraLens;
+ public static valueOf(value: string): io.github.triniwiz.fancycamera.CameraLens;
+ public static values(): androidNative.Array;
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class CameraPosition {
- public static class: java.lang.Class;
- public static BACK: io.github.triniwiz.fancycamera.CameraPosition;
- public static FRONT: io.github.triniwiz.fancycamera.CameraPosition;
- public static Companion: io.github.triniwiz.fancycamera.CameraPosition.Companion;
- public static values(): androidNative.Array;
- public getValue(): number;
- public static valueOf(param0: string): io.github.triniwiz.fancycamera.CameraPosition;
- }
- export module CameraPosition {
- export class Companion {
- public static class: java.lang.Class;
- public from(param0: number): io.github.triniwiz.fancycamera.CameraPosition;
- }
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class CameraOrientation {
+ public static class: java.lang.Class;
+ public static UNKNOWN: io.github.triniwiz.fancycamera.CameraOrientation;
+ public static PORTRAIT: io.github.triniwiz.fancycamera.CameraOrientation;
+ public static PORTRAIT_UPSIDE_DOWN: io.github.triniwiz.fancycamera.CameraOrientation;
+ public static LANDSCAPE_LEFT: io.github.triniwiz.fancycamera.CameraOrientation;
+ public static LANDSCAPE_RIGHT: io.github.triniwiz.fancycamera.CameraOrientation;
+ public static values(): androidNative.Array;
+ public static valueOf(value: string): io.github.triniwiz.fancycamera.CameraOrientation;
+ public getValue(): number;
+ }
+ export namespace CameraOrientation {
+ export class Companion {
+ public static class: java.lang.Class;
+ public from(it: number): io.github.triniwiz.fancycamera.CameraOrientation;
+ }
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class DetectorType {
- public static class: java.lang.Class;
- public static Barcode: io.github.triniwiz.fancycamera.DetectorType;
- public static DigitalInk: io.github.triniwiz.fancycamera.DetectorType;
- public static Face: io.github.triniwiz.fancycamera.DetectorType;
- public static Image: io.github.triniwiz.fancycamera.DetectorType;
- public static Object: io.github.triniwiz.fancycamera.DetectorType;
- public static Pose: io.github.triniwiz.fancycamera.DetectorType;
- public static Text: io.github.triniwiz.fancycamera.DetectorType;
- public static All: io.github.triniwiz.fancycamera.DetectorType;
- public static None: io.github.triniwiz.fancycamera.DetectorType;
- public toString(): string;
- public static valueOf(param0: string): io.github.triniwiz.fancycamera.DetectorType;
- public static values(): androidNative.Array;
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class CameraPosition {
+ public static class: java.lang.Class;
+ public static BACK: io.github.triniwiz.fancycamera.CameraPosition;
+ public static FRONT: io.github.triniwiz.fancycamera.CameraPosition;
+ public static values(): androidNative.Array;
+ public getValue(): number;
+ public static valueOf(value: string): io.github.triniwiz.fancycamera.CameraPosition;
+ public getLenFacing(): number;
+ }
+ export namespace CameraPosition {
+ export class Companion {
+ public static class: java.lang.Class;
+ public from(it: number): io.github.triniwiz.fancycamera.CameraPosition;
+ }
+ export class WhenMappings {
+ public static class: java.lang.Class;
+ }
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class Event {
- public static class: java.lang.Class;
- public constructor(param0: io.github.triniwiz.fancycamera.EventType, param1: java.io.File, param2: string);
- public getMessage(): string;
- public getFile(): java.io.File;
- public getType(): io.github.triniwiz.fancycamera.EventType;
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class DetectorType {
+ public static class: java.lang.Class;
+ public static Barcode: io.github.triniwiz.fancycamera.DetectorType;
+ public static DigitalInk: io.github.triniwiz.fancycamera.DetectorType;
+ public static Face: io.github.triniwiz.fancycamera.DetectorType;
+ public static Image: io.github.triniwiz.fancycamera.DetectorType;
+ public static Object: io.github.triniwiz.fancycamera.DetectorType;
+ public static Pose: io.github.triniwiz.fancycamera.DetectorType;
+ public static Text: io.github.triniwiz.fancycamera.DetectorType;
+ public static All: io.github.triniwiz.fancycamera.DetectorType;
+ public static Selfie: io.github.triniwiz.fancycamera.DetectorType;
+ public static None: io.github.triniwiz.fancycamera.DetectorType;
+ public toString(): string;
+ public static fromInt(value: number): io.github.triniwiz.fancycamera.DetectorType;
+ public static values(): androidNative.Array;
+ public static valueOf(value: string): io.github.triniwiz.fancycamera.DetectorType;
+ public static fromName(value: string): io.github.triniwiz.fancycamera.DetectorType;
+ }
+ export namespace DetectorType {
+ export class Companion {
+ public static class: java.lang.Class;
+ public fromInt(value: number): io.github.triniwiz.fancycamera.DetectorType;
+ public fromName(value: string): io.github.triniwiz.fancycamera.DetectorType;
+ }
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class EventType {
- public static class: java.lang.Class;
- public static Photo: io.github.triniwiz.fancycamera.EventType;
- public static Video: io.github.triniwiz.fancycamera.EventType;
- public static values(): androidNative.Array;
- public static valueOf(param0: string): io.github.triniwiz.fancycamera.EventType;
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class Event {
+ public static class: java.lang.Class;
+ public getMessage(): string;
+ public getFile(): java.io.File;
+ public getType(): io.github.triniwiz.fancycamera.EventType;
+ public constructor(type: io.github.triniwiz.fancycamera.EventType, file: java.io.File, message: string);
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class ExtensionsKt {
- public static class: java.lang.Class;
- public static afterMeasured(param0: globalAndroid.view.View, param1: kotlin.jvm.functions.Function1): void;
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class EventType {
+ public static class: java.lang.Class;
+ public static Photo: io.github.triniwiz.fancycamera.EventType;
+ public static Video: io.github.triniwiz.fancycamera.EventType;
+ public static values(): androidNative.Array;
+ public static valueOf(value: string): io.github.triniwiz.fancycamera.EventType;
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class FancyCamera {
- public static class: java.lang.Class;
- public static Companion: io.github.triniwiz.fancycamera.FancyCamera.Companion;
- public getAllowExifRotation(): boolean;
- public getCameraOrientation(): io.github.triniwiz.fancycamera.CameraOrientation;
- public setMaxVideoFrameRate(param0: number): void;
- public toggleFlash(): void;
- public getDisableHEVC(): boolean;
- public getAutoFocus(): boolean;
- public setAllowExifRotation(param0: boolean): void;
- public getQuality(): io.github.triniwiz.fancycamera.Quality;
- public requestCameraPermission(): void;
- public getMaxAudioBitRate(): number;
- public startPreview(): void;
- public onPermissionHandler(param0: number, param1: androidNative.Array, param2: androidNative.Array): void;
- public getWhiteBalance(): io.github.triniwiz.fancycamera.WhiteBalance;
- public setOverridePhotoWidth(param0: number): void;
- public constructor(param0: globalAndroid.content.Context, param1: globalAndroid.util.AttributeSet);
- public hasStoragePermission(): boolean;
- public setAutoSquareCrop(param0: boolean): void;
- public setOverridePhotoHeight(param0: number): void;
- public getAutoSquareCrop(): boolean;
- public setOnTextRecognitionListener(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- public getOverridePhotoWidth(): number;
- public setWhiteBalance(param0: io.github.triniwiz.fancycamera.WhiteBalance): void;
- public getPictureSize(): string;
- public getSaveToGallery(): boolean;
- public startRecording(): void;
- public setDisableHEVC(param0: boolean): void;
- public getNumberOfCameras(): number;
- public setQuality(param0: io.github.triniwiz.fancycamera.Quality): void;
- public static getForceV1(): boolean;
- public setZoom(param0: number): void;
- public requestPermission(): void;
- public release(): void;
- public hasCameraPermission(): boolean;
- public setSaveToGallery(param0: boolean): void;
- public setAudioLevelsEnabled(param0: boolean): void;
- public setPosition(param0: io.github.triniwiz.fancycamera.CameraPosition): void;
- public setOnObjectDetectedListener(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- public isAudioLevelsEnabled(): boolean;
- public stop(): void;
- public setMaxVideoBitrate(param0: number): void;
- public setOnImageLabelingListener(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- public getRatio(): string;
- public setOnBarcodeScanningListener(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- public stopPreview(): void;
- public getOverridePhotoHeight(): number;
- public setPictureSize(param0: string): void;
- public getPosition(): io.github.triniwiz.fancycamera.CameraPosition;
- public getFlashMode(): io.github.triniwiz.fancycamera.CameraFlashMode;
- public hasPermission(): boolean;
- public getGetSupportedRatios(): androidNative.Array;
- public getDuration(): number;
- public requestAudioPermission(): void;
- public hasAudioPermission(): boolean;
- public getMaxVideoBitrate(): number;
- public setonSurfaceUpdateListener(param0: io.github.triniwiz.fancycamera.SurfaceUpdateListener): void;
- public setFlashMode(param0: io.github.triniwiz.fancycamera.CameraFlashMode): void;
- public getDetectorType(): io.github.triniwiz.fancycamera.DetectorType;
- public getMaxVideoFrameRate(): number;
- public takePhoto(): void;
- public getZoom(): number;
- public getAvailablePictureSizes(param0: string): androidNative.Array;
- public setAutoFocus(param0: boolean): void;
- public requestStoragePermission(): void;
- public setRatio(param0: string): void;
- public toggleCamera(): void;
- public stopRecording(): void;
- public setCameraOrientation(param0: io.github.triniwiz.fancycamera.CameraOrientation): void;
- public setOnPoseDetectedListener(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- public constructor(param0: globalAndroid.content.Context);
- public setDetectorType(param0: io.github.triniwiz.fancycamera.DetectorType): void;
- public setMaxAudioBitRate(param0: number): void;
- public getPreviewView(): any;
- public getHasFlash(): boolean;
- public getDb(): number;
- public setListener(param0: io.github.triniwiz.fancycamera.CameraEventListener): void;
- public setEnableAudioLevels(param0: boolean): void;
- public setOnFacesDetectedListener(param0: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
- public static setForceV1(param0: boolean): void;
- }
- export module FancyCamera {
- export class Companion {
- public static class: java.lang.Class;
- public setForceV1(param0: boolean): void;
- public getForceV1(): boolean;
- }
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class FancyCamera {
+ public static class: java.lang.Class;
+ public getAllowExifRotation(): boolean;
+ public getAutoFocus(): boolean;
+ public setOnImageLabelingListener(callback: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public setEnableTapToFocus(value: boolean): void;
+ public startPreview(): void;
+ public isWideAngleSupported(): boolean;
+ public setOnSelfieSegmentationListener(callback: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public setAutoFocus(value: boolean): void;
+ public getSaveToGallery(): boolean;
+ public setOverridePhotoHeight(value: number): void;
+ public removeImageProcessors(processors: androidNative.Array>): void;
+ public getLatestImage(): globalAndroid.graphics.Bitmap;
+ public addImageProcessor(processor: io.github.triniwiz.fancycamera.ImageProcessor): void;
+ public setFlashMode(value: io.github.triniwiz.fancycamera.CameraFlashMode): void;
+ public hasCameraPermission(): boolean;
+ public setOnBarcodeScanningListener(callback: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public setZoom(value: number): void;
+ public setWhiteBalance(value: io.github.triniwiz.fancycamera.WhiteBalance): void;
+ public constructor(context: globalAndroid.content.Context);
+ public getRatio(): string;
+ public setRetrieveLatestImage(value: boolean): void;
+ public removeImageProcessor(processor: io.github.triniwiz.fancycamera.ImageProcessor): void;
+ public setCameraOrientation(orientation: io.github.triniwiz.fancycamera.CameraOrientation): void;
+ public getPosition(): io.github.triniwiz.fancycamera.CameraPosition;
+ public constructor(context: globalAndroid.content.Context, attrs: globalAndroid.util.AttributeSet);
+ public getProcessEveryNthFrame(): number;
+ public setEnablePinchZoom(value: boolean): void;
+ public getDuration(): number;
+ public requestAudioPermission(): void;
+ public hasAudioPermission(): boolean;
+ public onPermissionHandler(requestCode: number, permissions: androidNative.Array, grantResults: androidNative.Array): void;
+ public getMaxVideoBitrate(): number;
+ public setSaveToGallery(value: boolean): void;
+ public getMaxVideoFrameRate(): number;
+ public takePhoto(): void;
+ public setOnTextRecognitionListener(callback: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public setRatio(value: string): void;
+ public getEnableTapToFocus(): boolean;
+ public getEnablePinchZoom(): boolean;
+ public setPause(value: boolean): void;
+ public setPosition(value: io.github.triniwiz.fancycamera.CameraPosition): void;
+ public setonSurfaceUpdateListener(callback: io.github.triniwiz.fancycamera.SurfaceUpdateListener): void;
+ public stopRecording(): void;
+ public getEnableAudio(): boolean;
+ public static setForceV1(value: boolean): void;
+ public setDefaultLens(value: io.github.triniwiz.fancycamera.CameraLens): void;
+ public getHasFlash(): boolean;
+ public getDb(): number;
+ public getRetrieveLatestImage(): boolean;
+ public getCameraOrientation(): io.github.triniwiz.fancycamera.CameraOrientation;
+ public toggleFlash(): void;
+ public setEnableAudio(value: boolean): void;
+ public getDisableHEVC(): boolean;
+ public setAllowExifRotation(value: boolean): void;
+ public getQuality(): io.github.triniwiz.fancycamera.Quality;
+ public requestCameraPermission(): void;
+ public getMaxAudioBitRate(): number;
+ public setMaxAudioBitRate(value: number): void;
+ public getWhiteBalance(): io.github.triniwiz.fancycamera.WhiteBalance;
+ public setAutoSquareCrop(value: boolean): void;
+ public hasStoragePermission(): boolean;
+ public getAutoSquareCrop(): boolean;
+ public getOverridePhotoWidth(): number;
+ public removeImageProcessor(iterator: number): void;
+ public getPictureSize(): string;
+ public startRecording(): void;
+ public getNumberOfCameras(): number;
+ public static getForceV1(): boolean;
+ public requestPermission(): void;
+ public release(): void;
+ public setMaxVideoBitrate(value: number): void;
+ public clearImageProcessor(): void;
+ public setDisableHEVC(value: boolean): void;
+ public isAudioLevelsEnabled(): boolean;
+ public stop(): void;
+ public stopPreview(): void;
+ public getOverridePhotoHeight(): number;
+ public setOnFacesDetectedListener(callback: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public getFlashMode(): io.github.triniwiz.fancycamera.CameraFlashMode;
+ public setMaxVideoFrameRate(value: number): void;
+ public hasPermission(): boolean;
+ public getGetSupportedRatios(): androidNative.Array;
+ public addImageProcessors(processors: androidNative.Array>): void;
+ public setOnObjectDetectedListener(callback: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public getZoom(): number;
+ public requestStoragePermission(): void;
+ public getDefaultLens(): io.github.triniwiz.fancycamera.CameraLens;
+ public setQuality(value: io.github.triniwiz.fancycamera.Quality): void;
+ public toggleCamera(): void;
+ public getPause(): boolean;
+ public getAvailablePictureSizes(ratio: string): androidNative.Array;
+ public setProcessEveryNthFrame(value: number): void;
+ public setOverridePhotoWidth(value: number): void;
+ public setListener(listener: io.github.triniwiz.fancycamera.CameraEventListener): void;
+ public getPreviewView(): any;
+ public setEnableAudioLevels(enableAudioLevels: boolean): void;
+ public setAudioLevelsEnabled(value: boolean): void;
+ public setPictureSize(value: string): void;
+ public setOnPoseDetectedListener(callback: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public getImageProcessors(): java.util.List>;
+ }
+ export namespace FancyCamera {
+ export class Companion {
+ public static class: java.lang.Class;
+ public setForceV1(value: boolean): void;
+ public getForceV1(): boolean;
+ }
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class FancyCameraFileProvider {
- public static class: java.lang.Class;
- public constructor();
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class FancyCameraFileProvider {
+ public static class: java.lang.Class;
+ public constructor();
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class ImageAnalysis {
- public static class: java.lang.Class;
- public constructor();
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class FrameMetadata {
+ public static class: java.lang.Class;
+ public getRotation(): number;
+ public getHeight(): number;
+ public getWidth(): number;
+ }
+ export namespace FrameMetadata {
+ export class Builder {
+ public static class: java.lang.Class;
+ public constructor();
+ public setWidth(width: number): io.github.triniwiz.fancycamera.FrameMetadata.Builder;
+ public setRotation(rotation: number): io.github.triniwiz.fancycamera.FrameMetadata.Builder;
+ public setHeight(height: number): io.github.triniwiz.fancycamera.FrameMetadata.Builder;
+ public build(): io.github.triniwiz.fancycamera.FrameMetadata;
+ }
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class ImageAnalysisCallback {
- public static class: java.lang.Class;
- /**
- * Constructs a new instance of the io.github.triniwiz.fancycamera.ImageAnalysisCallback interface with the provided implementation. An empty constructor exists calling super() when extending the interface class.
- */
- public constructor(implementation: {
- onSuccess(param0: string): void;
- onError(param0: string, param1: java.lang.Exception): void;
- });
- public constructor();
- public onSuccess(param0: string): void;
- public onError(param0: string, param1: java.lang.Exception): void;
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class ImageAnalysis {
+ public static class: java.lang.Class;
+ public constructor();
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class Quality {
- public static class: java.lang.Class;
- public static MAX_480P: io.github.triniwiz.fancycamera.Quality;
- public static MAX_720P: io.github.triniwiz.fancycamera.Quality;
- public static MAX_1080P: io.github.triniwiz.fancycamera.Quality;
- public static MAX_2160P: io.github.triniwiz.fancycamera.Quality;
- public static HIGHEST: io.github.triniwiz.fancycamera.Quality;
- public static LOWEST: io.github.triniwiz.fancycamera.Quality;
- public static QVGA: io.github.triniwiz.fancycamera.Quality;
- public static Companion: io.github.triniwiz.fancycamera.Quality.Companion;
- public static values(): androidNative.Array;
- public getValue(): number;
- public static valueOf(param0: string): io.github.triniwiz.fancycamera.Quality;
- }
- export module Quality {
- export class Companion {
- public static class: java.lang.Class;
- public from(param0: number): io.github.triniwiz.fancycamera.Quality;
- }
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class ImageAnalysisCallback {
+ public static class: java.lang.Class;
+ /**
+ * Constructs a new instance of the io.github.triniwiz.fancycamera.ImageAnalysisCallback interface with the provided implementation. An empty constructor exists calling super() when extending the interface class.
+ */
+ public constructor(implementation: { onSuccess(param0: any): void; onError(param0: string, param1: java.lang.Exception): void });
+ public constructor();
+ public onSuccess(param0: any): void;
+ public onError(param0: string, param1: java.lang.Exception): void;
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class Size {
- public static class: java.lang.Class;
- public toString(): string;
- public getHeight(): number;
- public getWidth(): number;
- public constructor(param0: number, param1: number);
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class ImageProcessor extends java.lang.Object {
+ public static class: java.lang.Class>;
+ /**
+ * Constructs a new instance of the io.github.triniwiz.fancycamera.ImageProcessor interface with the provided implementation. An empty constructor exists calling super() when extending the interface class.
+ */
+ public constructor(implementation: { getType(): number; process(param0: com.google.mlkit.vision.common.InputImage): java.util.concurrent.FutureTask; process(param0: androidNative.Array, param1: number, param2: number, param3: number, param4: number): java.util.concurrent.FutureTask; process(param0: globalAndroid.media.Image, param1: number): java.util.concurrent.FutureTask; process(param0: globalAndroid.graphics.Bitmap, param1: number): java.util.concurrent.FutureTask });
+ public constructor();
+ public getType(): number;
+ public process(param0: com.google.mlkit.vision.common.InputImage): java.util.concurrent.FutureTask;
+ public process(param0: globalAndroid.media.Image, param1: number): java.util.concurrent.FutureTask;
+ public process(param0: androidNative.Array, param1: number, param2: number, param3: number, param4: number): java.util.concurrent.FutureTask;
+ public process(param0: globalAndroid.graphics.Bitmap, param1: number): java.util.concurrent.FutureTask;
+ }
+ export namespace ImageProcessor {
+ export class DefaultImpls {
+ public static class: java.lang.Class;
+ public static process(input: io.github.triniwiz.fancycamera.ImageProcessor, $this: androidNative.Array, bytes: number, width: number, height: number, rotation: number): java.util.concurrent.FutureTask;
+ public static process($this: io.github.triniwiz.fancycamera.ImageProcessor, image: globalAndroid.media.Image, rotation: number): java.util.concurrent.FutureTask;
+ public static process(input: io.github.triniwiz.fancycamera.ImageProcessor, $this: globalAndroid.graphics.Bitmap, bitmap: number): java.util.concurrent.FutureTask;
+ public static getType($this: io.github.triniwiz.fancycamera.ImageProcessor): number;
+ }
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class SurfaceUpdateListener {
- public static class: java.lang.Class;
- /**
- * Constructs a new instance of the io.github.triniwiz.fancycamera.SurfaceUpdateListener interface with the provided implementation. An empty constructor exists calling super() when extending the interface class.
- */
- public constructor(implementation: {
- onUpdate(): void;
- });
- public constructor();
- public onUpdate(): void;
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class ML {
+ public static class: java.lang.Class;
+ public static processImage(image: globalAndroid.graphics.Bitmap, rotation: number, imageProcessors: java.util.List, callback: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ public constructor();
+ public static process(byteArray: androidNative.Array, width: number, height: number, rotation: number, format: number, imageProcessors: java.util.List, callback: io.github.triniwiz.fancycamera.ImageAnalysisCallback): void;
+ }
+ export namespace ML {
+ export class Companion {
+ public static class: java.lang.Class;
+ }
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export class WhiteBalance {
- public static class: java.lang.Class;
- public static Auto: io.github.triniwiz.fancycamera.WhiteBalance;
- public static Sunny: io.github.triniwiz.fancycamera.WhiteBalance;
- public static Cloudy: io.github.triniwiz.fancycamera.WhiteBalance;
- public static Shadow: io.github.triniwiz.fancycamera.WhiteBalance;
- public static Twilight: io.github.triniwiz.fancycamera.WhiteBalance;
- public static Fluorescent: io.github.triniwiz.fancycamera.WhiteBalance;
- public static Incandescent: io.github.triniwiz.fancycamera.WhiteBalance;
- public static WarmFluorescent: io.github.triniwiz.fancycamera.WhiteBalance;
- public getValue$fancycamera_release(): string;
- public static values(): androidNative.Array;
- public static valueOf(param0: string): io.github.triniwiz.fancycamera.WhiteBalance;
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class Quality {
+ public static class: java.lang.Class;
+ public static MAX_480P: io.github.triniwiz.fancycamera.Quality;
+ public static MAX_720P: io.github.triniwiz.fancycamera.Quality;
+ public static MAX_1080P: io.github.triniwiz.fancycamera.Quality;
+ public static MAX_2160P: io.github.triniwiz.fancycamera.Quality;
+ public static HIGHEST: io.github.triniwiz.fancycamera.Quality;
+ public static LOWEST: io.github.triniwiz.fancycamera.Quality;
+ public static QVGA: io.github.triniwiz.fancycamera.Quality;
+ public static values(): androidNative.Array;
+ public getValue(): number;
+ public static valueOf(value: string): io.github.triniwiz.fancycamera.Quality;
+ }
+ export namespace Quality {
+ export class Companion {
+ public static class: java.lang.Class;
+ public from(it: number): io.github.triniwiz.fancycamera.Quality;
+ }
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export module barcodescanning {
- export class BarcodeScanner {
- public static class: java.lang.Class;
- public constructor();
- public processBytes(param0: androidNative.Array, param1: number, param2: number, param3: number, param4: number, param5: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.Options): com.google.android.gms.tasks.Task;
- public processImage(param0: com.google.mlkit.vision.common.InputImage, param1: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.Options): com.google.android.gms.tasks.Task;
- public processBitmap(param0: globalAndroid.graphics.Bitmap, param1: number, param2: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.Options): com.google.android.gms.tasks.Task;
- }
- export module BarcodeScanner {
- export class BarcodeFormat {
- public static class: java.lang.Class;
- public static ALL: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
- public static CODE_128: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
- public static CODE_39: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
- public static CODE_93: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
- public static CODABAR: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
- public static DATA_MATRIX: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
- public static EAN_13: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
- public static EAN_8: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
- public static ITF: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
- public static QR_CODE: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
- public static UPC_A: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
- public static UPC_E: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
- public static PDF417: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
- public static AZTEC: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
- public static Companion: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat.Companion;
- public getFormat$barcodeScanning_release(): number;
- public static valueOf(param0: string): io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
- public static values(): androidNative.Array;
- }
- export module BarcodeFormat {
- export class Companion {
- public static class: java.lang.Class;
- public fromBarcode$barcodeScanning_release(param0: number): io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
- }
- }
- export class Options {
- public static class: java.lang.Class;
- public getBarcodeFormat(): androidNative.Array;
- public constructor();
- public setBarcodeFormat(param0: androidNative.Array): void;
- }
- }
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class Size {
+ public static class: java.lang.Class;
+ public toString(): string;
+ public getHeight(): number;
+ public getWidth(): number;
+ public constructor(width: number, height: number);
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export module barcodescanning {
- export class BuildConfig {
- public static class: java.lang.Class;
- public static DEBUG: boolean;
- public static LIBRARY_PACKAGE_NAME: string;
- public static BUILD_TYPE: string;
- public constructor();
- }
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class SurfaceUpdateListener {
+ public static class: java.lang.Class;
+ /**
+ * Constructs a new instance of the io.github.triniwiz.fancycamera.SurfaceUpdateListener interface with the provided implementation. An empty constructor exists calling super() when extending the interface class.
+ */
+ public constructor(implementation: { onUpdate(): void });
+ public constructor();
+ public onUpdate(): void;
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export module barcodescanning {
- export class Result {
- public static class: java.lang.Class;
- public getFormat(): io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
- public getRawBytes(): androidNative.Array;
- public getWifi(): io.github.triniwiz.fancycamera.barcodescanning.Result.WiFi;
- public getDriverLicense(): io.github.triniwiz.fancycamera.barcodescanning.Result.DriverLicense;
- public getPoints(): androidNative.Array;
- public getUrl(): io.github.triniwiz.fancycamera.barcodescanning.Result.UrlBookmark;
- public getCalendarEvent(): io.github.triniwiz.fancycamera.barcodescanning.Result.CalenderEvent;
- public getBounds(): io.github.triniwiz.fancycamera.barcodescanning.Result.Bounds;
- public getSms(): io.github.triniwiz.fancycamera.barcodescanning.Result.Sms;
- public getValueType(): io.github.triniwiz.fancycamera.barcodescanning.Result.ValueType;
- public getDisplayValue(): string;
- public getPhone(): io.github.triniwiz.fancycamera.barcodescanning.Result.Phone;
- public constructor(param0: com.google.mlkit.vision.barcode.Barcode);
- public getRawValue(): string;
- public getEmail(): io.github.triniwiz.fancycamera.barcodescanning.Result.Email;
- public getContactInfo(): io.github.triniwiz.fancycamera.barcodescanning.Result.ContactInfo;
- public getGeoPoint(): io.github.triniwiz.fancycamera.barcodescanning.Result.GeoPoint;
- }
- export module Result {
- export class Bounds {
- public static class: java.lang.Class;
- public getSize(): io.github.triniwiz.fancycamera.barcodescanning.Result.Bounds.Size;
- public constructor(param0: globalAndroid.graphics.Rect);
- public getOrigin(): io.github.triniwiz.fancycamera.barcodescanning.Result.Bounds.Origin;
- }
- export module Bounds {
- export class Origin {
- public static class: java.lang.Class;
- public constructor(param0: number, param1: number);
- public getX(): number;
- public getY(): number;
- }
- export class Size {
- public static class: java.lang.Class;
- public constructor(param0: number, param1: number);
- public getHeight(): number;
- public getWidth(): number;
- }
- }
- export class CalenderEvent {
- public static class: java.lang.Class;
- public getSummary(): string;
- public getOrganizer(): string;
- public constructor(param0: com.google.mlkit.vision.barcode.Barcode.CalendarEvent);
- public getStart(): io.github.triniwiz.fancycamera.barcodescanning.Result.CalenderEvent.Date;
- public getEnd(): io.github.triniwiz.fancycamera.barcodescanning.Result.CalenderEvent.Date;
- public getLocation(): string;
- public getDescription(): string;
- public getStatus(): string;
- }
- export module CalenderEvent {
- export class Date {
- public static class: java.lang.Class;
- public getDay(): number;
- public isUtc(): boolean;
- public getRawValue(): string;
- public getHours(): number;
- public getMinutes(): number;
- public getYear(): number;
- public getSeconds(): number;
- public constructor(param0: com.google.mlkit.vision.barcode.Barcode.CalendarDateTime);
- public getDate(): java.util.Date;
- public getMonth(): number;
- }
- }
- export class ContactInfo {
- public static class: java.lang.Class;
- public constructor(param0: com.google.mlkit.vision.barcode.Barcode.ContactInfo);
- public getAddresses(): androidNative.Array;
- }
- export module ContactInfo {
- export class Address {
- public static class: java.lang.Class;
- public constructor(param0: com.google.mlkit.vision.barcode.Barcode.Address);
- public getAddressLines(): androidNative.Array;
- public getType(): io.github.triniwiz.fancycamera.barcodescanning.Result.ContactInfo.Address.Type;
- }
- export module Address {
- export class Type {
- public static class: java.lang.Class;
- public static Unknown: io.github.triniwiz.fancycamera.barcodescanning.Result.ContactInfo.Address.Type;
- public static Home: io.github.triniwiz.fancycamera.barcodescanning.Result.ContactInfo.Address.Type;
- public static Work: io.github.triniwiz.fancycamera.barcodescanning.Result.ContactInfo.Address.Type;
- public static values(): androidNative.Array;
- public static valueOf(param0: string): io.github.triniwiz.fancycamera.barcodescanning.Result.ContactInfo.Address.Type;
- public getTypeName(): string;
- }
- }
- }
- export class DriverLicense {
- public static class: java.lang.Class;
- public getGender(): string;
- public setAddressStreet(param0: string): void;
- public constructor(param0: com.google.mlkit.vision.barcode.Barcode.DriverLicense);
- public getBirthDate(): string;
- public setFirstName(param0: string): void;
- public getAddressStreet(): string;
- public getMiddleName(): string;
- public getIssuingCountry(): string;
- public setIssuingCountry(param0: string): void;
- public getFirstName(): string;
- public setExpiryDate(param0: string): void;
- public getAddressCity(): string;
- public setAddressState(param0: string): void;
- public getDocumentType(): string;
- public setAddressCity(param0: string): void;
- public setGender(param0: string): void;
- public getAddressZip(): string;
- public getAddressState(): string;
- public getLicenseNumber(): string;
- public getIssueDate(): string;
- public setBirthDate(param0: string): void;
- public setAddressZip(param0: string): void;
- public setLicenseNumber(param0: string): void;
- public getLastName(): string;
- public getExpiryDate(): string;
- public setMiddleName(param0: string): void;
- public setIssueDate(param0: string): void;
- public setLastName(param0: string): void;
- }
- export class Email {
- public static class: java.lang.Class;
- public getSubject(): string;
- public getAddress(): string;
- public getType(): io.github.triniwiz.fancycamera.barcodescanning.Result.Email.Type;
- public constructor(param0: com.google.mlkit.vision.barcode.Barcode.Email);
- public getBody(): string;
- }
- export module Email {
- export class Type {
- public static class: java.lang.Class;
- public static Unknown: io.github.triniwiz.fancycamera.barcodescanning.Result.Email.Type;
- public static Home: io.github.triniwiz.fancycamera.barcodescanning.Result.Email.Type;
- public static Work: io.github.triniwiz.fancycamera.barcodescanning.Result.Email.Type;
- public getTypeName(): string;
- public static values(): androidNative.Array;
- public static valueOf(param0: string): io.github.triniwiz.fancycamera.barcodescanning.Result.Email.Type;
- }
- }
- export class GeoPoint {
- public static class: java.lang.Class;
- public getLat(): number;
- public getLng(): number;
- public constructor(param0: com.google.mlkit.vision.barcode.Barcode.GeoPoint);
- }
- export class Phone {
- public static class: java.lang.Class;
- public getNumber(): string;
- public getType(): io.github.triniwiz.fancycamera.barcodescanning.Result.Phone.Type;
- public constructor(param0: com.google.mlkit.vision.barcode.Barcode.Phone);
- }
- export module Phone {
- export class Type {
- public static class: java.lang.Class;
- public static Unknown: io.github.triniwiz.fancycamera.barcodescanning.Result.Phone.Type;
- public static Home: io.github.triniwiz.fancycamera.barcodescanning.Result.Phone.Type;
- public static Work: io.github.triniwiz.fancycamera.barcodescanning.Result.Phone.Type;
- public static Fax: io.github.triniwiz.fancycamera.barcodescanning.Result.Phone.Type;
- public static Mobile: io.github.triniwiz.fancycamera.barcodescanning.Result.Phone.Type;
- public getTypeName(): string;
- public static values(): androidNative.Array;
- public static valueOf(param0: string): io.github.triniwiz.fancycamera.barcodescanning.Result.Phone.Type;
- }
- }
- export class Point {
- public static class: java.lang.Class;
- public getY(): number;
- public getX(): number;
- public constructor(param0: globalAndroid.graphics.Point);
- }
- export class Sms {
- public static class: java.lang.Class;
- public constructor(param0: com.google.mlkit.vision.barcode.Barcode.Sms);
- public getPhoneNumber(): string;
- public getMessage(): string;
- }
- export class UrlBookmark {
- public static class: java.lang.Class;
- public getUrl(): string;
- public getTitle(): string;
- public constructor(param0: com.google.mlkit.vision.barcode.Barcode.UrlBookmark);
- }
- export class ValueType {
- public static class: java.lang.Class;
- public static ContactInfo: io.github.triniwiz.fancycamera.barcodescanning.Result.ValueType;
- public static Email: io.github.triniwiz.fancycamera.barcodescanning.Result.ValueType;
- public static ISBN: io.github.triniwiz.fancycamera.barcodescanning.Result.ValueType;
- public static Phone: io.github.triniwiz.fancycamera.barcodescanning.Result.ValueType;
- public static Product: io.github.triniwiz.fancycamera.barcodescanning.Result.ValueType;
- public static Text: io.github.triniwiz.fancycamera.barcodescanning.Result.ValueType;
- public static Sms: io.github.triniwiz.fancycamera.barcodescanning.Result.ValueType;
- public static URL: io.github.triniwiz.fancycamera.barcodescanning.Result.ValueType;
- public static WiFi: io.github.triniwiz.fancycamera.barcodescanning.Result.ValueType;
- public static Geo: io.github.triniwiz.fancycamera.barcodescanning.Result.ValueType;
- public static CalenderEvent: io.github.triniwiz.fancycamera.barcodescanning.Result.ValueType;
- public static DriverLicense: io.github.triniwiz.fancycamera.barcodescanning.Result.ValueType;
- public static Unknown: io.github.triniwiz.fancycamera.barcodescanning.Result.ValueType;
- public static valueOf(param0: string): io.github.triniwiz.fancycamera.barcodescanning.Result.ValueType;
- public static values(): androidNative.Array;
- public getType(): string;
- }
- export class WiFi {
- public static class: java.lang.Class;
- public constructor(param0: com.google.mlkit.vision.barcode.Barcode.WiFi);
- public getPassword(): string;
- public getEncryptionType(): io.github.triniwiz.fancycamera.barcodescanning.Result.WiFi.EncryptionType;
- public getSsid(): string;
- }
- export module WiFi {
- export class EncryptionType {
- public static class: java.lang.Class;
- public static Open: io.github.triniwiz.fancycamera.barcodescanning.Result.WiFi.EncryptionType;
- public static WPA: io.github.triniwiz.fancycamera.barcodescanning.Result.WiFi.EncryptionType;
- public static WEP: io.github.triniwiz.fancycamera.barcodescanning.Result.WiFi.EncryptionType;
- public static Unknown: io.github.triniwiz.fancycamera.barcodescanning.Result.WiFi.EncryptionType;
- public static values(): androidNative.Array;
- public static valueOf(param0: string): io.github.triniwiz.fancycamera.barcodescanning.Result.WiFi.EncryptionType;
- public getType(): string;
- }
- }
- }
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export class WhiteBalance {
+ public static class: java.lang.Class;
+ public static Auto: io.github.triniwiz.fancycamera.WhiteBalance;
+ public static Sunny: io.github.triniwiz.fancycamera.WhiteBalance;
+ public static Cloudy: io.github.triniwiz.fancycamera.WhiteBalance;
+ public static Shadow: io.github.triniwiz.fancycamera.WhiteBalance;
+ public static Twilight: io.github.triniwiz.fancycamera.WhiteBalance;
+ public static Fluorescent: io.github.triniwiz.fancycamera.WhiteBalance;
+ public static Incandescent: io.github.triniwiz.fancycamera.WhiteBalance;
+ public static WarmFluorescent: io.github.triniwiz.fancycamera.WhiteBalance;
+ public getValue$fancycamera_release(): string;
+ public static valueOf(value: string): io.github.triniwiz.fancycamera.WhiteBalance;
+ public static values(): androidNative.Array;
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export module facedetection {
- export class BuildConfig {
- public static class: java.lang.Class;
- public static DEBUG: boolean;
- public static LIBRARY_PACKAGE_NAME: string;
- public static BUILD_TYPE: string;
- public constructor();
- }
- }
- }
- }
- }
+declare namespace io {
+ export namespace github {
+ export namespace triniwiz {
+ export namespace fancycamera {
+ export namespace barcodescanning {
+ export class BarcodeScanner extends io.github.triniwiz.fancycamera.ImageProcessor {
+ public static class: java.lang.Class;
+ public process(it: com.google.mlkit.vision.common.InputImage): java.util.concurrent.FutureTask;
+ public process(param0: androidNative.Array, param1: number, param2: number, param3: number, param4: number): java.util.concurrent.FutureTask;
+ public process(param0: globalAndroid.graphics.Bitmap, param1: number): java.util.concurrent.FutureTask;
+ public constructor();
+ public getOptions(): io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.Options;
+ public process(image: globalAndroid.media.Image, rotation: number): java.util.concurrent.FutureTask;
+ public process(param0: com.google.mlkit.vision.common.InputImage): java.util.concurrent.FutureTask;
+ public getType(): number;
+ public setOptions(value: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.Options): void;
+ }
+ export namespace BarcodeScanner {
+ export class BarcodeFormat {
+ public static class: java.lang.Class;
+ public static ALL: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
+ public static CODE_128: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
+ public static CODE_39: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
+ public static CODE_93: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
+ public static CODABAR: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
+ public static DATA_MATRIX: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
+ public static EAN_13: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
+ public static EAN_8: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
+ public static ITF: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
+ public static QR_CODE: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
+ public static UPC_A: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
+ public static UPC_E: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
+ public static PDF417: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
+ public static AZTEC: io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
+ public getFormat$barcodeScanning_release(): number;
+ public static valueOf(value: string): io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
+ public getValue(): string;
+ public static values(): androidNative.Array;
+ }
+ export namespace BarcodeFormat {
+ export class Companion {
+ public static class: java.lang.Class;
+ public fromBarcode$barcodeScanning_release(bf: number): io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.BarcodeFormat;
+ }
+ export class WhenMappings {
+ public static class: java.lang.Class;
+ }
+ }
+ export class Options {
+ public static class: java.lang.Class;
+ public constructor();
+ public getBarcodeFormat(): androidNative.Array;
+ public static fromJson(value: string, returnDefault: boolean): io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.Options;
+ public setBarcodeFormat(value: androidNative.Array): void;
+ public static fromJson(value: string): io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.Options;
+ public static fromJson(value: org.json.JSONObject, returnDefault: boolean): io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.Options;
+ }
+ export namespace Options {
+ export class Companion {
+ public static class: java.lang.Class;
+ public fromJson(value: string): io.github.triniwiz.fancycamera.barcodescanning.BarcodeScanner.Options;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
-declare module io {
- export module github {
- export module triniwiz {
- export module fancycamera {
- export module facedetection {
- export class FaceDetection {
- public static class: java.lang.Class