express-sweet 1.0.20 → 1.0.21
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/CHANGELOG.md +46 -1
- package/dist/build.common.js +4 -4
- package/dist/build.esm.js +5 -5
- package/docs/index.html +100 -44
- package/package.json +1 -1
- package/types/services/AWSRekognitionClient.d.ts +16 -13
package/docs/index.html
CHANGED
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
<a class="nav-link" href="#rekognition-class">Class Rekognition</a>
|
|
88
88
|
<a class="nav-link" href="#rekognition-match-interface">Interface FaceMatch</a>
|
|
89
89
|
<a class="nav-link" href="#rekognition-face-details-interface">Interface FaceDetails</a>
|
|
90
|
+
<a class="nav-link" href="#rekognition-index-face-details-interface">Interface IndexFaceDetails</a>
|
|
90
91
|
<a class="nav-link" href="#rekognition-face-details-emotions-interface">Interface FaceDetailsEmotions</a>
|
|
91
92
|
<a class="nav-link" href="#rekognition-bbox-interface">Interface BoundingBox</a>
|
|
92
93
|
</nav>
|
|
@@ -114,7 +115,7 @@
|
|
|
114
115
|
</div>
|
|
115
116
|
<hr class="mx-auto mx-lg-0 my-5">
|
|
116
117
|
<p class="text-muted">
|
|
117
|
-
Currently <a href="https://github.com/takuya-motoshima/express-sweet/releases/tag/v1.0.
|
|
118
|
+
Currently <a href="https://github.com/takuya-motoshima/express-sweet/releases/tag/v1.0.21" target="_blank">v1.0.21</a>
|
|
118
119
|
<span class="px-1">•</span>
|
|
119
120
|
<a href="#quick-start">Quick Start</a>
|
|
120
121
|
<span class="px-1">•</span>
|
|
@@ -4138,13 +4139,18 @@ await client.deleteCollection('MyCollection');</code></pre>
|
|
|
4138
4139
|
</div>
|
|
4139
4140
|
</li>
|
|
4140
4141
|
<li class="list-group-item">
|
|
4141
|
-
<div class="fw-bold"
|
|
4142
|
+
<div class="fw-bold">
|
|
4143
|
+
<code class="h5">
|
|
4144
|
+
public async indexFace(
|
|
4145
|
+
collectionId: string,
|
|
4146
|
+
img: string,
|
|
4147
|
+
options?: {externalImageId? : string, returnDetails?: boolean
|
|
4148
|
+
}): Promise<string|<a href="#rekognition-index-face-details-interface">IndexFaceDetails</a>>
|
|
4149
|
+
</code>
|
|
4150
|
+
</div>
|
|
4142
4151
|
<div class="ms-3">
|
|
4143
4152
|
<p>
|
|
4144
|
-
Detects one face in the input image and adds it to the specified collection
|
|
4145
|
-
This method doesn't save the actual faces that are detected.<br>
|
|
4146
|
-
Instead, the underlying detection algorithm first detects the faces in the input image.<br>
|
|
4147
|
-
The algorithm extracts facial features into a feature vector, and stores it in the backend database.
|
|
4153
|
+
Detects one face in the input image and adds it to the specified collection.
|
|
4148
4154
|
<div class="callout callout-warning">
|
|
4149
4155
|
Note that this method is used to index one face.<br>
|
|
4150
4156
|
Throws an exception if no face is found in the input image or multiple faces are found.
|
|
@@ -4161,7 +4167,7 @@ await client.deleteCollection('MyCollection');</code></pre>
|
|
|
4161
4167
|
<div class="ms-3">Image path or Data Url or image buffer.</div>
|
|
4162
4168
|
</li>
|
|
4163
4169
|
<li class="list-group-item pt-0 border-0">
|
|
4164
|
-
<div class="fw-bold"><code>string</code>externalImageId</div>
|
|
4170
|
+
<div class="fw-bold"><code>string|undefined</code>options.externalImageId</div>
|
|
4165
4171
|
<div class="ms-3">
|
|
4166
4172
|
The ID you want to assign to the faces detected in the image.<br>
|
|
4167
4173
|
When you call the <code>"listFaces"</code> operation, the response returns the external ID.<br>
|
|
@@ -4170,9 +4176,20 @@ await client.deleteCollection('MyCollection');</code></pre>
|
|
|
4170
4176
|
The maximum length is 255, and the characters that can be used are <code>"[a-zA-Z0-9_.\-:]+"</code>.
|
|
4171
4177
|
</div>
|
|
4172
4178
|
</li>
|
|
4179
|
+
<li class="list-group-item pt-0 border-0">
|
|
4180
|
+
<div class="fw-bold"><code>boolean</code>options.returnDetails</div>
|
|
4181
|
+
<div class="ms-3">
|
|
4182
|
+
If <code>false</code>, only the face ID of the created face is returned.<br>
|
|
4183
|
+
If <code>true</code>, returns the face ID of the created face, plus age range, gender, and emotion.
|
|
4184
|
+
</div>
|
|
4185
|
+
</li>
|
|
4173
4186
|
</ul>
|
|
4174
4187
|
<h6>Return value</h6>
|
|
4175
|
-
<p
|
|
4188
|
+
<p>
|
|
4189
|
+
<code>Promise<string|<a href="#rekognition-index-face-details-interface">IndexFaceDetails</a>></code><br>
|
|
4190
|
+
If <code>options.returnDetails</code> is <code>false</code>, the face identifier is returned.<br>
|
|
4191
|
+
If <code>options.returnDetails</code> is <code>true</code>, returns the gender, age group, and emotion in addition to the face identifier.
|
|
4192
|
+
</p>
|
|
4176
4193
|
<h6>Example</h6>
|
|
4177
4194
|
<ul class="nav nav-tabs">
|
|
4178
4195
|
<li class="nav-item">
|
|
@@ -4198,26 +4215,35 @@ const client = new sweet.services.AWSRekognitionClient({
|
|
|
4198
4215
|
region: process.env.AWS_REKOGNITION_REGION
|
|
4199
4216
|
});
|
|
4200
4217
|
|
|
4201
|
-
//
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
//
|
|
4208
|
-
|
|
4218
|
+
// Create a face and get the ID of the created face.
|
|
4219
|
+
// Output: e65d66cb-e7bc-4bbf-966c-b1b49ddf29f8
|
|
4220
|
+
const faceId = await client.indexFace(collectionId, 'img.jpg');
|
|
4221
|
+
console.log(faceId);
|
|
4222
|
+
|
|
4223
|
+
// Create a face and get the details of the created face.
|
|
4224
|
+
// Output: {
|
|
4225
|
+
// faceId: '7f2dd321-f047-44ff-8856-864637e1d286',
|
|
4226
|
+
// ageRange: { high: 29, low: 21 },
|
|
4227
|
+
// gender: 'female',
|
|
4228
|
+
// emotions: {
|
|
4229
|
+
// angry: 77.1907958984375,
|
|
4230
|
+
// surprised: 9.944050788879395,
|
|
4231
|
+
// fear: 7.514361381530762,
|
|
4232
|
+
// confused: 4.780297756195068,
|
|
4233
|
+
// sad: 2.91914963722229,
|
|
4234
|
+
// happy: 2.5718722343444824,
|
|
4235
|
+
// disgusted: 1.933768391609192,
|
|
4236
|
+
// calm: 1.5354809761047363
|
|
4237
|
+
// }
|
|
4238
|
+
// }
|
|
4239
|
+
const faceDetails = await client.indexFace(collectionId, 'img.jpg', {returnDetails: true});
|
|
4240
|
+
console.log(faceDetails);
|
|
4209
4241
|
|
|
4210
|
-
//
|
|
4211
|
-
|
|
4212
|
-
// statusCode: 400
|
|
4213
|
-
// message: No face was found in the image
|
|
4214
|
-
await client.indexFace('MyCollection', 'img.jpg');
|
|
4242
|
+
// You can also index face images in DataURL format.
|
|
4243
|
+
await client.indexFace('MyCollection', 'data:image/png;base64,/9j/4...');
|
|
4215
4244
|
|
|
4216
|
-
//
|
|
4217
|
-
|
|
4218
|
-
// statusCode: 400
|
|
4219
|
-
// message: Multiple faces found in the image
|
|
4220
|
-
await client.indexFace('MyCollection', 'img.jpg');</code></pre>
|
|
4245
|
+
// Buffer face images can also be indexed.
|
|
4246
|
+
await client.indexFace('MyCollection', fs.readFileSync('img.jpg'));</code></pre>
|
|
4221
4247
|
</div>
|
|
4222
4248
|
</div>
|
|
4223
4249
|
<div class="tab-pane fade" id="rekognition-method-index-face-cjs">
|
|
@@ -4235,26 +4261,35 @@ const client = new sweet.services.AWSRekognitionClient({
|
|
|
4235
4261
|
region: process.env.AWS_REKOGNITION_REGION
|
|
4236
4262
|
});
|
|
4237
4263
|
|
|
4238
|
-
//
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
//
|
|
4245
|
-
|
|
4264
|
+
// Create a face and get the ID of the created face.
|
|
4265
|
+
// Output: e65d66cb-e7bc-4bbf-966c-b1b49ddf29f8
|
|
4266
|
+
const faceId = await client.indexFace(collectionId, 'img.jpg');
|
|
4267
|
+
console.log(faceId);
|
|
4268
|
+
|
|
4269
|
+
// Create a face and get the details of the created face.
|
|
4270
|
+
// Output: {
|
|
4271
|
+
// faceId: '7f2dd321-f047-44ff-8856-864637e1d286',
|
|
4272
|
+
// ageRange: { high: 29, low: 21 },
|
|
4273
|
+
// gender: 'female',
|
|
4274
|
+
// emotions: {
|
|
4275
|
+
// angry: 77.1907958984375,
|
|
4276
|
+
// surprised: 9.944050788879395,
|
|
4277
|
+
// fear: 7.514361381530762,
|
|
4278
|
+
// confused: 4.780297756195068,
|
|
4279
|
+
// sad: 2.91914963722229,
|
|
4280
|
+
// happy: 2.5718722343444824,
|
|
4281
|
+
// disgusted: 1.933768391609192,
|
|
4282
|
+
// calm: 1.5354809761047363
|
|
4283
|
+
// }
|
|
4284
|
+
// }
|
|
4285
|
+
const faceDetails = await client.indexFace(collectionId, 'img.jpg', {returnDetails: true});
|
|
4286
|
+
console.log(faceDetails);
|
|
4246
4287
|
|
|
4247
|
-
//
|
|
4248
|
-
|
|
4249
|
-
// statusCode: 400
|
|
4250
|
-
// message: No face was found in the image
|
|
4251
|
-
await client.indexFace('MyCollection', 'img.jpg');
|
|
4288
|
+
// You can also index face images in DataURL format.
|
|
4289
|
+
await client.indexFace('MyCollection', 'data:image/png;base64,/9j/4...');
|
|
4252
4290
|
|
|
4253
|
-
//
|
|
4254
|
-
|
|
4255
|
-
// statusCode: 400
|
|
4256
|
-
// message: Multiple faces found in the image
|
|
4257
|
-
await client.indexFace('MyCollection', 'img.jpg');</code></pre>
|
|
4291
|
+
// Buffer face images can also be indexed.
|
|
4292
|
+
await client.indexFace('MyCollection', fs.readFileSync('img.jpg'));</code></pre>
|
|
4258
4293
|
</div>
|
|
4259
4294
|
</div>
|
|
4260
4295
|
</div>
|
|
@@ -4635,6 +4670,27 @@ await client.deleteFaces('MyCollection', ['f7befa24-3b83-43cc-b21
|
|
|
4635
4670
|
<div class="ms-3">The predicted gender of a detected face. </div>
|
|
4636
4671
|
</li>
|
|
4637
4672
|
</ul>
|
|
4673
|
+
<h2 id="rekognition-index-face-details-interface">Interface IndexFaceDetails<span class="fs-5 ms-2">(express-sweet.interfaces.IndexFaceDetails)</span></h2>
|
|
4674
|
+
<p>Detail of indexed face.</p>
|
|
4675
|
+
<h3>Properties</h3>
|
|
4676
|
+
<ul class="list-group list-group-flush">
|
|
4677
|
+
<li class="list-group-item">
|
|
4678
|
+
<div class="fw-bold"><code class="h5">faceId: string</code></div>
|
|
4679
|
+
<div class="ms-3">A unique identifier assigned to the face.</div>
|
|
4680
|
+
</li>
|
|
4681
|
+
<li class="list-group-item">
|
|
4682
|
+
<div class="fw-bold"><code class="h5">ageRange: {high: UInteger, low: UInteger}</code></div>
|
|
4683
|
+
<div class="ms-3">The estimated age range, in years, for the face. Low represents the lowest estimated age and High represents the highest estimated age.</div>
|
|
4684
|
+
</li>
|
|
4685
|
+
<li class="list-group-item">
|
|
4686
|
+
<div class="fw-bold"><code class="h5">gender: 'male'|'female'</code></div>
|
|
4687
|
+
<div class="ms-3">The predicted gender of a detected face. </div>
|
|
4688
|
+
</li>
|
|
4689
|
+
<li class="list-group-item">
|
|
4690
|
+
<div class="fw-bold"><code class="h5">emotions: <a href="#rekognition-face-details-emotions-interface">FaceDetailsEmotions</a></code></div>
|
|
4691
|
+
<div class="ms-3">The predicted gender of a detected face. </div>
|
|
4692
|
+
</li>
|
|
4693
|
+
</ul>
|
|
4638
4694
|
<h2 id="rekognition-face-details-emotions-interface">Interface FaceDetailsEmotions<span class="fs-5 ms-2">(express-sweet.interfaces.FaceDetailsEmotions)</span></h2>
|
|
4639
4695
|
<p>The emotions that appear to be expressed on the face, and the confidence level in the determination. </p>
|
|
4640
4696
|
<h3>Properties</h3>
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import RekognitionOptions from '~/interfaces/RekognitionOptions';
|
|
|
2
2
|
import FaceMatch from '~/interfaces/FaceMatch';
|
|
3
3
|
import BoundingBox from '~/interfaces/BoundingBox';
|
|
4
4
|
import FaceDetails from '~/interfaces/FaceDetails';
|
|
5
|
+
import IndexFaceDetails from '~/interfaces/IndexFaceDetails';
|
|
5
6
|
/**
|
|
6
7
|
* AWS Rekognition Client.
|
|
7
8
|
*/
|
|
@@ -55,23 +56,25 @@ export default class {
|
|
|
55
56
|
listCollections(): Promise<string[]>;
|
|
56
57
|
/**
|
|
57
58
|
* Detects one face in the input image and adds it to the specified collection.
|
|
58
|
-
* This method doesn't save the actual faces that are detected.
|
|
59
|
-
* Instead, the underlying detection algorithm first detects the faces in the input image.
|
|
60
|
-
* The algorithm extracts facial features into a feature vector, and stores it in the backend database.
|
|
61
|
-
*
|
|
62
59
|
* Note that this method is used to index one face.
|
|
63
60
|
* Throws an exception if no face is found in the input image or multiple faces are found.
|
|
64
61
|
*
|
|
65
|
-
* @param {string}
|
|
66
|
-
* @param {string}
|
|
67
|
-
* @param {string}
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* @
|
|
62
|
+
* @param {string} collectionId The ID of an existing collection to which you want to add the faces that are detected in the input images.
|
|
63
|
+
* @param {string} img Image path or Data Url or image buffer.
|
|
64
|
+
* @param {string|undefined} options.externalImageId The ID you want to assign to the faces detected in the image.
|
|
65
|
+
* When you call the "listFaces" operation, the response returns the external ID.
|
|
66
|
+
* You can use this external image ID to create a client-side index to associate the faces with each image.
|
|
67
|
+
* You can then use the index to find all faces in an image.
|
|
68
|
+
* The maximum length is 255, and the characters that can be used are "[a-zA-Z0-9_.\-:]+".
|
|
69
|
+
* @param {boolean} options.returnDetails If false, only the face ID of the created face is returned.
|
|
70
|
+
* If true, returns the face ID of the created face, plus age range, gender, and emotion.
|
|
71
|
+
* @return {Promise<string|IndexFaceDetails>} If options.returnDetails is false, the face identifier is returned.
|
|
72
|
+
* If options.returnDetails is true, returns the gender, age group, and emotion in addition to the face identifier.
|
|
73
73
|
*/
|
|
74
|
-
indexFace(collectionId: string, img: string,
|
|
74
|
+
indexFace(collectionId: string, img: string, options?: {
|
|
75
|
+
externalImageId?: string;
|
|
76
|
+
returnDetails?: boolean;
|
|
77
|
+
}): Promise<string | IndexFaceDetails>;
|
|
75
78
|
/**
|
|
76
79
|
* For a given input image, first detects the largest face in the image, and then searches the specified collection for matching faces.
|
|
77
80
|
* The operation compares the features of the input face with faces in the specified collection.
|