@cronapp/mlkit-api 1.0.4 → 4.4.0-RC.10
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/cronapp.json +8 -8
- package/i18n/locale_en_us.json +4 -1
- package/i18n/locale_pt_br.json +4 -1
- package/mlkit-api.cronapi.js +104 -2
- package/package.json +1 -1
package/cronapp.json
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
"script": "node_modules/@cronapp/mlkit-api/mlkit-api.cronapi.js",
|
|
8
8
|
"type": "script"
|
|
9
9
|
}
|
|
10
|
+
],
|
|
11
|
+
"cordova": [
|
|
12
|
+
{
|
|
13
|
+
"name": "cronapp-plugin-mlkit",
|
|
14
|
+
"version": "4.4.0-SNAPSHOT.20260408230128"
|
|
15
|
+
}
|
|
10
16
|
]
|
|
11
|
-
}
|
|
12
|
-
"cordova": [
|
|
13
|
-
{
|
|
14
|
-
"name": "cronapp-plugin-mlkit",
|
|
15
|
-
"version": "1.0.4"
|
|
16
|
-
}
|
|
17
|
-
]
|
|
17
|
+
}
|
|
18
18
|
}
|
|
19
|
-
}
|
|
19
|
+
}
|
package/i18n/locale_en_us.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"faceDetector": "Face Detector",
|
|
3
3
|
"faceDetectorDescription": "Detects faces and features in an image",
|
|
4
|
+
"faceDescription": "Face Description",
|
|
5
|
+
"faceDescriptionDescription": "Generates a textual description from the face detector result",
|
|
6
|
+
"faceDescriptionInput": "Face detector result",
|
|
4
7
|
"image": "Image: File path or Base64 with pattern data:image/<jpeg|png>;base64,<data>",
|
|
5
8
|
"options": "Options: Json with options. Possible keys: classificationMode: 1 for none or 2 all, performanceMode: 1 for fast or 2 accurate, contourMode: 1 for none 2 for all and landmarkMode: 1 for none and 2 for all"
|
|
6
|
-
}
|
|
9
|
+
}
|
package/i18n/locale_pt_br.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"faceDetector": "Detector de Rosto",
|
|
3
3
|
"faceDetectorDescription": "Detecta rostos e suas propriedades em uma imagem",
|
|
4
|
+
"faceDescription": "Descricao da Face",
|
|
5
|
+
"faceDescriptionDescription": "Gera uma descricao textual a partir do retorno do detector facial",
|
|
6
|
+
"faceDescriptionInput": "Retorno do detector facial",
|
|
4
7
|
"image": "Imagem: Caminho do arquivo ou Base64 com padrão data:image/<jpeg|png>;base64,<data>",
|
|
5
8
|
"options": "Opções: Json com opções. Possíveis chaves: classificationMode: 1 para nenhum ou 2 todos, performanceMode: 1 para rápida ou 2 acurada, contourMode: 1 para nenhum 2 para todos e landmarkMode: 1 para nenhum e 2 para todos"
|
|
6
|
-
}
|
|
9
|
+
}
|
package/mlkit-api.cronapi.js
CHANGED
|
@@ -25,7 +25,12 @@
|
|
|
25
25
|
if (typeof options === 'string') {
|
|
26
26
|
options = JSON.parse(options);
|
|
27
27
|
}
|
|
28
|
-
CronappMLKitPlugin
|
|
28
|
+
const plugin = window.CronappMLKitPlugin;
|
|
29
|
+
if (!plugin || typeof plugin.faceDetector !== 'function') {
|
|
30
|
+
reject(new Error('Cronapp ML Kit plugin is unavailable. Check the Cordova plugin installation in the mobile build.'));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
plugin.faceDetector(
|
|
29
34
|
image,
|
|
30
35
|
options,
|
|
31
36
|
(json) => {
|
|
@@ -40,4 +45,101 @@
|
|
|
40
45
|
}
|
|
41
46
|
});
|
|
42
47
|
};
|
|
43
|
-
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @type function
|
|
51
|
+
* @name {{faceDescription}}
|
|
52
|
+
* @nameTags Face Description | Descricao da Face | Descrição da Face
|
|
53
|
+
* @platform M
|
|
54
|
+
* @returns {ObjectType.STRING}
|
|
55
|
+
* @description {{faceDescriptionDescription}}
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
this.cronapi.mlkit.faceDescription = function (/** @type {ObjectType.OBJECT} @description {{faceDescriptionInput}} */ data) {
|
|
59
|
+
if (data === null || data === undefined) {
|
|
60
|
+
return 'Sem retorno do detector facial';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (typeof data === 'string') {
|
|
64
|
+
try {
|
|
65
|
+
data = JSON.parse(data);
|
|
66
|
+
} catch (e) {
|
|
67
|
+
return data;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!Array.isArray(data)) {
|
|
72
|
+
data = [data];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (data.length === 0) {
|
|
76
|
+
return 'Nenhum rosto detectado';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var result = '';
|
|
80
|
+
|
|
81
|
+
for (var i = 0; i < data.length; i++) {
|
|
82
|
+
var faceData = data[i] || {};
|
|
83
|
+
|
|
84
|
+
if (i > 0) {
|
|
85
|
+
result += ', ';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
result += '[Face ' + (i + 1) + ' ';
|
|
89
|
+
|
|
90
|
+
if (faceData.smilingProbability !== undefined) {
|
|
91
|
+
result += 'Probabilidade de Sorriso: ' + faceData.smilingProbability + '\n';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (faceData.leftEyeOpenProbability !== undefined) {
|
|
95
|
+
result += 'Probabilidade de Olho Esquerdo Aberto: ' + faceData.leftEyeOpenProbability + '\n';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (faceData.rightEyeOpenProbability !== undefined) {
|
|
99
|
+
result += 'Probabilidade de Olho Direito Aberto: ' + faceData.rightEyeOpenProbability + '\n';
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (faceData.headEulerAngleX !== undefined) {
|
|
103
|
+
result += 'Angulo da Cabeca (X): ' + faceData.headEulerAngleX + '\n';
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (faceData.headEulerAngleY !== undefined) {
|
|
107
|
+
result += 'Angulo da Cabeca (Y): ' + faceData.headEulerAngleY + '\n';
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (faceData.headEulerAngleZ !== undefined) {
|
|
111
|
+
result += 'Angulo da Cabeca (Z): ' + faceData.headEulerAngleZ + '\n';
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
var boundingBox = faceData.boundingBox;
|
|
115
|
+
if (boundingBox) {
|
|
116
|
+
result += 'Bounding Box (X: ' + boundingBox.x + ', Y: ' + boundingBox.y + ', Largura: ' + boundingBox.width + ', Altura: ' + boundingBox.height + ')\n';
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (Array.isArray(faceData.landmarks) && faceData.landmarks.length > 0) {
|
|
120
|
+
result += 'Landmarks Detectados:\n';
|
|
121
|
+
faceData.landmarks.forEach(function (landmark, index) {
|
|
122
|
+
result += ' Landmark ' + (index + 1) + ' - Tipo: ' + landmark.type + ', Posicao (X: ' + landmark.x + ', Y: ' + landmark.y + ')\n';
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (Array.isArray(faceData.contours) && faceData.contours.length > 0) {
|
|
127
|
+
result += 'Contornos Detectados:\n';
|
|
128
|
+
faceData.contours.forEach(function (contour, index) {
|
|
129
|
+
result += ' Contorno ' + (index + 1) + ' - Tipo: ' + contour.type + ', Pontos: [';
|
|
130
|
+
(contour.points || []).forEach(function (point) {
|
|
131
|
+
result += ' (X: ' + point.x + ', Y: ' + point.y + ')';
|
|
132
|
+
});
|
|
133
|
+
result += ' ]\n';
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
result += ']';
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return result;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// Compatibility alias for projects using the old misspelled name.
|
|
144
|
+
this.cronapi.mlkit.faceDeacription = this.cronapi.mlkit.faceDescription;
|
|
145
|
+
}).bind(window)();
|