@capacitor-mlkit/selfie-segmentation 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapacitorMlkitSelfieSegmentation.podspec +19 -0
- package/LICENSE +201 -0
- package/README.md +112 -0
- package/android/build.gradle +60 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/selfiesegmentation/ProcessImageResultCallback.java +11 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/selfiesegmentation/SelfieSegmentation.java +132 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/selfiesegmentation/SelfieSegmentationPlugin.java +88 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/selfiesegmentation/classes/ProcessImageOptions.java +47 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/selfiesegmentation/classes/ProcessImageResult.java +29 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +156 -0
- package/dist/esm/definitions.d.ts +65 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +6 -0
- package/dist/esm/web.js +10 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +26 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +29 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/Classes/ProcessImageOptions.swift +64 -0
- package/ios/Plugin/Classes/ProcessImageResult.swift +30 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/SelfieSegmentation.swift +199 -0
- package/ios/Plugin/SelfieSegmentationPlugin.h +10 -0
- package/ios/Plugin/SelfieSegmentationPlugin.m +8 -0
- package/ios/Plugin/SelfieSegmentationPlugin.swift +61 -0
- package/package.json +91 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.mlkit.selfiesegmentation.classes;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSObject;
|
|
4
|
+
|
|
5
|
+
public class ProcessImageResult {
|
|
6
|
+
|
|
7
|
+
private final String imagePath;
|
|
8
|
+
|
|
9
|
+
private final int width;
|
|
10
|
+
private final int height;
|
|
11
|
+
|
|
12
|
+
public ProcessImageResult(String imagePath, int width, int height) {
|
|
13
|
+
this.imagePath = imagePath;
|
|
14
|
+
|
|
15
|
+
this.width = width;
|
|
16
|
+
this.height = height;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public JSObject toJSObject() {
|
|
20
|
+
JSObject result = new JSObject();
|
|
21
|
+
|
|
22
|
+
result.put("path", imagePath);
|
|
23
|
+
|
|
24
|
+
result.put("width", width);
|
|
25
|
+
result.put("height", height);
|
|
26
|
+
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "SelfieSegmentationPlugin",
|
|
4
|
+
"slug": "selfiesegmentationplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "processImage",
|
|
10
|
+
"signature": "(options: ProcessImageOptions) => Promise<ProcessImageResult>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "ProcessImageOptions"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<ProcessImageResult>",
|
|
19
|
+
"tags": [
|
|
20
|
+
{
|
|
21
|
+
"name": "since",
|
|
22
|
+
"text": "5.2.0"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"docs": "Performs segmentation on an input image.\n\nOnly available on Android and iOS.",
|
|
26
|
+
"complexTypes": [
|
|
27
|
+
"ProcessImageResult",
|
|
28
|
+
"ProcessImageOptions"
|
|
29
|
+
],
|
|
30
|
+
"slug": "processimage"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"properties": []
|
|
34
|
+
},
|
|
35
|
+
"interfaces": [
|
|
36
|
+
{
|
|
37
|
+
"name": "ProcessImageResult",
|
|
38
|
+
"slug": "processimageresult",
|
|
39
|
+
"docs": "",
|
|
40
|
+
"tags": [
|
|
41
|
+
{
|
|
42
|
+
"text": "5.2.0",
|
|
43
|
+
"name": "since"
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"methods": [],
|
|
47
|
+
"properties": [
|
|
48
|
+
{
|
|
49
|
+
"name": "path",
|
|
50
|
+
"tags": [
|
|
51
|
+
{
|
|
52
|
+
"text": "5.2.0",
|
|
53
|
+
"name": "since"
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"docs": "The path to the segmented image file.",
|
|
57
|
+
"complexTypes": [],
|
|
58
|
+
"type": "string"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "width",
|
|
62
|
+
"tags": [
|
|
63
|
+
{
|
|
64
|
+
"text": "5.2.0",
|
|
65
|
+
"name": "since"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"docs": "Returns the width of the image file.",
|
|
69
|
+
"complexTypes": [],
|
|
70
|
+
"type": "number"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"name": "height",
|
|
74
|
+
"tags": [
|
|
75
|
+
{
|
|
76
|
+
"text": "5.2.0",
|
|
77
|
+
"name": "since"
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"docs": "Returns the height of the image file.",
|
|
81
|
+
"complexTypes": [],
|
|
82
|
+
"type": "number"
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "ProcessImageOptions",
|
|
88
|
+
"slug": "processimageoptions",
|
|
89
|
+
"docs": "",
|
|
90
|
+
"tags": [
|
|
91
|
+
{
|
|
92
|
+
"text": "5.2.0",
|
|
93
|
+
"name": "since"
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
"methods": [],
|
|
97
|
+
"properties": [
|
|
98
|
+
{
|
|
99
|
+
"name": "path",
|
|
100
|
+
"tags": [
|
|
101
|
+
{
|
|
102
|
+
"text": "5.2.0",
|
|
103
|
+
"name": "since"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"docs": "The local path to the image file.",
|
|
107
|
+
"complexTypes": [],
|
|
108
|
+
"type": "string"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "width",
|
|
112
|
+
"tags": [
|
|
113
|
+
{
|
|
114
|
+
"text": "5.2.0",
|
|
115
|
+
"name": "since"
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
"docs": "Scale the image to this width.\nIf no `height` is given, it will respect the aspect ratio.",
|
|
119
|
+
"complexTypes": [],
|
|
120
|
+
"type": "number | undefined"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"name": "height",
|
|
124
|
+
"tags": [
|
|
125
|
+
{
|
|
126
|
+
"text": "5.2.0",
|
|
127
|
+
"name": "since"
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"docs": "Scale the image to this height.\nIf no `width` is given, it will respect the aspect ratio.",
|
|
131
|
+
"complexTypes": [],
|
|
132
|
+
"type": "number | undefined"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "confidence",
|
|
136
|
+
"tags": [
|
|
137
|
+
{
|
|
138
|
+
"text": "5.2.0",
|
|
139
|
+
"name": "since"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"text": "0.9",
|
|
143
|
+
"name": "default"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"docs": "Sets the confidence threshold.",
|
|
147
|
+
"complexTypes": [],
|
|
148
|
+
"type": "number | undefined"
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
"enums": [],
|
|
154
|
+
"typeAliases": [],
|
|
155
|
+
"pluginConfigs": []
|
|
156
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export interface SelfieSegmentationPlugin {
|
|
2
|
+
/**
|
|
3
|
+
* Performs segmentation on an input image.
|
|
4
|
+
*
|
|
5
|
+
* Only available on Android and iOS.
|
|
6
|
+
*
|
|
7
|
+
* @since 5.2.0
|
|
8
|
+
*/
|
|
9
|
+
processImage(options: ProcessImageOptions): Promise<ProcessImageResult>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @since 5.2.0
|
|
13
|
+
*/
|
|
14
|
+
export interface ProcessImageOptions {
|
|
15
|
+
/**
|
|
16
|
+
* The local path to the image file.
|
|
17
|
+
*
|
|
18
|
+
* @since 5.2.0
|
|
19
|
+
*/
|
|
20
|
+
path: string;
|
|
21
|
+
/**
|
|
22
|
+
* Scale the image to this width.
|
|
23
|
+
* If no `height` is given, it will respect the aspect ratio.
|
|
24
|
+
*
|
|
25
|
+
* @since 5.2.0
|
|
26
|
+
*/
|
|
27
|
+
width?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Scale the image to this height.
|
|
30
|
+
* If no `width` is given, it will respect the aspect ratio.
|
|
31
|
+
*
|
|
32
|
+
* @since 5.2.0
|
|
33
|
+
*/
|
|
34
|
+
height?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Sets the confidence threshold.
|
|
37
|
+
*
|
|
38
|
+
* @since 5.2.0
|
|
39
|
+
* @default 0.9
|
|
40
|
+
*/
|
|
41
|
+
confidence?: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @since 5.2.0
|
|
45
|
+
*/
|
|
46
|
+
export interface ProcessImageResult {
|
|
47
|
+
/**
|
|
48
|
+
* The path to the segmented image file.
|
|
49
|
+
*
|
|
50
|
+
* @since 5.2.0
|
|
51
|
+
*/
|
|
52
|
+
path: string;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the width of the image file.
|
|
55
|
+
*
|
|
56
|
+
* @since 5.2.0
|
|
57
|
+
*/
|
|
58
|
+
width: number;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the height of the image file.
|
|
61
|
+
*
|
|
62
|
+
* @since 5.2.0
|
|
63
|
+
*/
|
|
64
|
+
height: number;
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface SelfieSegmentationPlugin {\n /**\n * Performs segmentation on an input image.\n *\n * Only available on Android and iOS.\n *\n * @since 5.2.0\n */\n processImage(options: ProcessImageOptions): Promise<ProcessImageResult>;\n}\n\n/**\n * @since 5.2.0\n */\nexport interface ProcessImageOptions {\n /**\n * The local path to the image file.\n *\n * @since 5.2.0\n */\n path: string;\n\n /**\n * Scale the image to this width.\n * If no `height` is given, it will respect the aspect ratio.\n *\n * @since 5.2.0\n */\n width?: number;\n /**\n * Scale the image to this height.\n * If no `width` is given, it will respect the aspect ratio.\n *\n * @since 5.2.0\n */\n height?: number;\n\n /**\n * Sets the confidence threshold.\n *\n * @since 5.2.0\n * @default 0.9\n */\n confidence?: number;\n}\n\n/**\n * @since 5.2.0\n */\nexport interface ProcessImageResult {\n /**\n * The path to the segmented image file.\n *\n * @since 5.2.0\n */\n path: string;\n /**\n * Returns the width of the image file.\n *\n * @since 5.2.0\n */\n width: number;\n /**\n * Returns the height of the image file.\n *\n * @since 5.2.0\n */\n height: number;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const SelfieSegmentation = registerPlugin('SelfieSegmentation', {
|
|
3
|
+
web: () => import('./web').then(m => new m.SelfieSegmentationWeb()),
|
|
4
|
+
});
|
|
5
|
+
export * from './definitions';
|
|
6
|
+
export { SelfieSegmentation };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,kBAAkB,GAAG,cAAc,CACvC,oBAAoB,EACpB;IACE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAE,CAAC;CACpE,CACF,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { SelfieSegmentationPlugin } from './definitions';\n\nconst SelfieSegmentation = registerPlugin<SelfieSegmentationPlugin>(\n 'SelfieSegmentation',\n {\n web: () => import('./web').then(m => new m.SelfieSegmentationWeb()),\n },\n);\n\nexport * from './definitions';\nexport { SelfieSegmentation };\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { SelfieSegmentationPlugin, ProcessImageOptions, ProcessImageResult } from './definitions';
|
|
3
|
+
export declare class SelfieSegmentationWeb extends WebPlugin implements SelfieSegmentationPlugin {
|
|
4
|
+
processImage(_options: ProcessImageOptions): Promise<ProcessImageResult>;
|
|
5
|
+
private createUnavailableException;
|
|
6
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CapacitorException, ExceptionCode, WebPlugin } from '@capacitor/core';
|
|
2
|
+
export class SelfieSegmentationWeb extends WebPlugin {
|
|
3
|
+
async processImage(_options) {
|
|
4
|
+
throw this.createUnavailableException();
|
|
5
|
+
}
|
|
6
|
+
createUnavailableException() {
|
|
7
|
+
return new CapacitorException('This Selfie Segmentation plugin method is not available on this platform.', ExceptionCode.Unavailable);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQ/E,MAAM,OAAO,qBACX,SAAQ,SAAS;IAGV,KAAK,CAAC,YAAY,CACvB,QAA6B;QAE7B,MAAM,IAAI,CAAC,0BAA0B,EAAE,CAAC;IAC1C,CAAC;IAEO,0BAA0B;QAChC,OAAO,IAAI,kBAAkB,CAC3B,2EAA2E,EAC3E,aAAa,CAAC,WAAW,CAC1B,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { CapacitorException, ExceptionCode, WebPlugin } from '@capacitor/core';\n\nimport type {\n SelfieSegmentationPlugin,\n ProcessImageOptions,\n ProcessImageResult,\n} from './definitions';\n\nexport class SelfieSegmentationWeb\n extends WebPlugin\n implements SelfieSegmentationPlugin\n{\n public async processImage(\n _options: ProcessImageOptions,\n ): Promise<ProcessImageResult> {\n throw this.createUnavailableException();\n }\n\n private createUnavailableException(): CapacitorException {\n return new CapacitorException(\n 'This Selfie Segmentation plugin method is not available on this platform.',\n ExceptionCode.Unavailable,\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@capacitor/core');
|
|
6
|
+
|
|
7
|
+
const SelfieSegmentation = core.registerPlugin('SelfieSegmentation', {
|
|
8
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.SelfieSegmentationWeb()),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
class SelfieSegmentationWeb extends core.WebPlugin {
|
|
12
|
+
async processImage(_options) {
|
|
13
|
+
throw this.createUnavailableException();
|
|
14
|
+
}
|
|
15
|
+
createUnavailableException() {
|
|
16
|
+
return new core.CapacitorException('This Selfie Segmentation plugin method is not available on this platform.', core.ExceptionCode.Unavailable);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
21
|
+
__proto__: null,
|
|
22
|
+
SelfieSegmentationWeb: SelfieSegmentationWeb
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
exports.SelfieSegmentation = SelfieSegmentation;
|
|
26
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst SelfieSegmentation = registerPlugin('SelfieSegmentation', {\n web: () => import('./web').then(m => new m.SelfieSegmentationWeb()),\n});\nexport * from './definitions';\nexport { SelfieSegmentation };\n//# sourceMappingURL=index.js.map","import { CapacitorException, ExceptionCode, WebPlugin } from '@capacitor/core';\nexport class SelfieSegmentationWeb extends WebPlugin {\n async processImage(_options) {\n throw this.createUnavailableException();\n }\n createUnavailableException() {\n return new CapacitorException('This Selfie Segmentation plugin method is not available on this platform.', ExceptionCode.Unavailable);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin","CapacitorException","ExceptionCode"],"mappings":";;;;;;AACK,MAAC,kBAAkB,GAAGA,mBAAc,CAAC,oBAAoB,EAAE;AAChE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,qBAAqB,EAAE,CAAC;AACvE,CAAC;;ACFM,MAAM,qBAAqB,SAASC,cAAS,CAAC;AACrD,IAAI,MAAM,YAAY,CAAC,QAAQ,EAAE;AACjC,QAAQ,MAAM,IAAI,CAAC,0BAA0B,EAAE,CAAC;AAChD,KAAK;AACL,IAAI,0BAA0B,GAAG;AACjC,QAAQ,OAAO,IAAIC,uBAAkB,CAAC,2EAA2E,EAAEC,kBAAa,CAAC,WAAW,CAAC,CAAC;AAC9I,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var capacitorSelfieSegmentation = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const SelfieSegmentation = core.registerPlugin('SelfieSegmentation', {
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.SelfieSegmentationWeb()),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
class SelfieSegmentationWeb extends core.WebPlugin {
|
|
9
|
+
async processImage(_options) {
|
|
10
|
+
throw this.createUnavailableException();
|
|
11
|
+
}
|
|
12
|
+
createUnavailableException() {
|
|
13
|
+
return new core.CapacitorException('This Selfie Segmentation plugin method is not available on this platform.', core.ExceptionCode.Unavailable);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
18
|
+
__proto__: null,
|
|
19
|
+
SelfieSegmentationWeb: SelfieSegmentationWeb
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
exports.SelfieSegmentation = SelfieSegmentation;
|
|
23
|
+
|
|
24
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
25
|
+
|
|
26
|
+
return exports;
|
|
27
|
+
|
|
28
|
+
})({}, capacitorExports);
|
|
29
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst SelfieSegmentation = registerPlugin('SelfieSegmentation', {\n web: () => import('./web').then(m => new m.SelfieSegmentationWeb()),\n});\nexport * from './definitions';\nexport { SelfieSegmentation };\n//# sourceMappingURL=index.js.map","import { CapacitorException, ExceptionCode, WebPlugin } from '@capacitor/core';\nexport class SelfieSegmentationWeb extends WebPlugin {\n async processImage(_options) {\n throw this.createUnavailableException();\n }\n createUnavailableException() {\n return new CapacitorException('This Selfie Segmentation plugin method is not available on this platform.', ExceptionCode.Unavailable);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin","CapacitorException","ExceptionCode"],"mappings":";;;AACK,UAAC,kBAAkB,GAAGA,mBAAc,CAAC,oBAAoB,EAAE;IAChE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,qBAAqB,EAAE,CAAC;IACvE,CAAC;;ICFM,MAAM,qBAAqB,SAASC,cAAS,CAAC;IACrD,IAAI,MAAM,YAAY,CAAC,QAAQ,EAAE;IACjC,QAAQ,MAAM,IAAI,CAAC,0BAA0B,EAAE,CAAC;IAChD,KAAK;IACL,IAAI,0BAA0B,GAAG;IACjC,QAAQ,OAAO,IAAIC,uBAAkB,CAAC,2EAA2E,EAAEC,kBAAa,CAAC,WAAW,CAAC,CAAC;IAC9I,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import UIKit
|
|
3
|
+
|
|
4
|
+
extension UIImage {
|
|
5
|
+
public func scaledImage(width: Int?, height: Int?) -> UIImage {
|
|
6
|
+
let newWidth: CGFloat
|
|
7
|
+
let newHeight: CGFloat
|
|
8
|
+
|
|
9
|
+
if let width = width {
|
|
10
|
+
newWidth = CGFloat(width)
|
|
11
|
+
if let height = height {
|
|
12
|
+
newHeight = CGFloat(height)
|
|
13
|
+
} else {
|
|
14
|
+
let scaleFactor = newWidth / self.size.width
|
|
15
|
+
newHeight = self.size.height * scaleFactor
|
|
16
|
+
}
|
|
17
|
+
} else
|
|
18
|
+
if let height = height {
|
|
19
|
+
newHeight = CGFloat(height)
|
|
20
|
+
if let width = width {
|
|
21
|
+
newWidth = CGFloat(width)
|
|
22
|
+
} else {
|
|
23
|
+
let scaleFactor = newHeight / self.size.height
|
|
24
|
+
newWidth = self.size.width * scaleFactor
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
return self
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let newSize = CGSize(width: newWidth, height: newHeight)
|
|
31
|
+
|
|
32
|
+
if newSize.width >= size.width && newSize.height >= size.height {
|
|
33
|
+
return self
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
UIGraphicsBeginImageContextWithOptions(newSize, false, scale)
|
|
37
|
+
defer { UIGraphicsEndImageContext() }
|
|
38
|
+
draw(in: CGRect(origin: .zero, size: newSize))
|
|
39
|
+
return UIGraphicsGetImageFromCurrentImageContext() ?? self
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@objc class ProcessImageOptions: NSObject {
|
|
44
|
+
private var image: UIImage
|
|
45
|
+
private var confidence: CGFloat
|
|
46
|
+
|
|
47
|
+
init(
|
|
48
|
+
image: UIImage,
|
|
49
|
+
width: Int?,
|
|
50
|
+
height: Int?,
|
|
51
|
+
confidence: CGFloat
|
|
52
|
+
) {
|
|
53
|
+
self.image = image.scaledImage(width: width, height: height)
|
|
54
|
+
self.confidence = confidence
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
func getImage() -> UIImage {
|
|
58
|
+
return image
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
func getConfidence() -> CGFloat {
|
|
62
|
+
return confidence
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc class ProcessImageResult: NSObject {
|
|
5
|
+
let image: UIImage
|
|
6
|
+
|
|
7
|
+
init(image: UIImage) {
|
|
8
|
+
self.image = image
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
func toJSObject() throws -> JSObject {
|
|
12
|
+
var result = JSObject()
|
|
13
|
+
|
|
14
|
+
if let data = image.pngData() {
|
|
15
|
+
let uniqueFileNameWithExtension = UUID().uuidString + ".png"
|
|
16
|
+
var directory = URL(fileURLWithPath: NSTemporaryDirectory())
|
|
17
|
+
if let cachesDirectory = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first {
|
|
18
|
+
directory = cachesDirectory
|
|
19
|
+
}
|
|
20
|
+
let url = directory.appendingPathComponent(uniqueFileNameWithExtension)
|
|
21
|
+
try data.write(to: url)
|
|
22
|
+
|
|
23
|
+
result["path"] = url.absoluteString
|
|
24
|
+
result["width"] = Int(image.size.width)
|
|
25
|
+
result["height"] = Int(image.size.height)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return result
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleVersion</key>
|
|
20
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
+
<key>NSPrincipalClass</key>
|
|
22
|
+
<string></string>
|
|
23
|
+
</dict>
|
|
24
|
+
</plist>
|