express-sweet 1.0.18 → 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 +116 -1
- package/dist/build.common.js +14 -12
- package/dist/build.esm.js +14 -12
- package/docs/index.html +395 -99
- package/package.json +2 -2
- package/types/database/Model.d.ts +1 -1
- package/types/handlebars_helpers/date.d.ts +10 -17
- package/types/handlebars_helpers/index.d.ts +2 -1
- package/types/interfaces/BoundingBox.d.ts +1 -1
- package/types/interfaces/FaceDetailsEmotions.d.ts +40 -0
- package/types/services/AWSRekognitionClient.d.ts +25 -254
- package/types/utils/index.d.ts +1 -0
- package/types/utils/isArray.d.ts +8 -0
- package/types/utils/isString.d.ts +1 -1
package/docs/index.html
CHANGED
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
<a class="nav-link" href="#views-html-helpers">HTML helpers</a>
|
|
66
66
|
<a class="nav-link" href="#views-object-helpers">Object helpers</a>
|
|
67
67
|
<a class="nav-link" href="#views-string-helpers">String helpers</a>
|
|
68
|
+
<a class="nav-link" href="#views-date-helpers">Date helpers</a>
|
|
68
69
|
</nav>
|
|
69
70
|
<a class="nav-link" href="#model">Model</a>
|
|
70
71
|
<nav class="nav nav-pills flex-column flex-nowrap fw-normal small">
|
|
@@ -85,6 +86,9 @@
|
|
|
85
86
|
<nav class="nav nav-pills flex-column flex-nowrap fw-normal small">
|
|
86
87
|
<a class="nav-link" href="#rekognition-class">Class Rekognition</a>
|
|
87
88
|
<a class="nav-link" href="#rekognition-match-interface">Interface FaceMatch</a>
|
|
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>
|
|
91
|
+
<a class="nav-link" href="#rekognition-face-details-emotions-interface">Interface FaceDetailsEmotions</a>
|
|
88
92
|
<a class="nav-link" href="#rekognition-bbox-interface">Interface BoundingBox</a>
|
|
89
93
|
</nav>
|
|
90
94
|
<a class="nav-link" href="#changelog">Changelog</a>
|
|
@@ -111,7 +115,7 @@
|
|
|
111
115
|
</div>
|
|
112
116
|
<hr class="mx-auto mx-lg-0 my-5">
|
|
113
117
|
<p class="text-muted">
|
|
114
|
-
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>
|
|
115
119
|
<span class="px-1">•</span>
|
|
116
120
|
<a href="#quick-start">Quick Start</a>
|
|
117
121
|
<span class="px-1">•</span>
|
|
@@ -1303,6 +1307,37 @@ let val = '2'
|
|
|
1303
1307
|
</tr>
|
|
1304
1308
|
</tbody>
|
|
1305
1309
|
</table>
|
|
1310
|
+
<h2 id="views-date-helpers">Date helpers</h2>
|
|
1311
|
+
<table class="table">
|
|
1312
|
+
<thead class="table-light">
|
|
1313
|
+
<tr class="text-nowrap">
|
|
1314
|
+
<th>Helper</th>
|
|
1315
|
+
<th>Description</th>
|
|
1316
|
+
</tr>
|
|
1317
|
+
</thead>
|
|
1318
|
+
<tbody>
|
|
1319
|
+
<tr>
|
|
1320
|
+
<td class="text-nowrap"><code class="h5">format_date</code></td>
|
|
1321
|
+
<td class="w-100">
|
|
1322
|
+
<p>Use moment to format the date.</p>
|
|
1323
|
+
<h6>Parameters</h6>
|
|
1324
|
+
<ul>
|
|
1325
|
+
<li><code>string</code> format A format string based on moment.</li>
|
|
1326
|
+
<li><code>string</code> date Date string to format.</li>
|
|
1327
|
+
<li><code>string|string[]</code> locale Language or language-country locale string (or array of strings) available in <a href="https://github.com/moment/moment/tree/develop/locale" target="_blank">https://github.com/moment/moment/tree/develop/locale</a>.</li>
|
|
1328
|
+
</ul>
|
|
1329
|
+
<h6>Return value</h6>
|
|
1330
|
+
<p><code>string</code> Returns formatted date.</p>
|
|
1331
|
+
<h6>Usage:</h6>
|
|
1332
|
+
<div class="highlight">
|
|
1333
|
+
<pre><code class="html">{{format_date 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z"}} => 2021/10/24
|
|
1334
|
+
{{format_date 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z" 'jp'}} => 2021/10/24
|
|
1335
|
+
{{format_date 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z" 'es'}} => 2021/10/24</code></pre>
|
|
1336
|
+
</div>
|
|
1337
|
+
</td>
|
|
1338
|
+
</tr>
|
|
1339
|
+
</tbody>
|
|
1340
|
+
</table>
|
|
1306
1341
|
<!-- end::Views -->
|
|
1307
1342
|
|
|
1308
1343
|
<!-- begin::Model -->
|
|
@@ -3623,6 +3658,10 @@ module.exports = router;</code></pre>
|
|
|
3623
3658
|
<div class="highlight">
|
|
3624
3659
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
3625
3660
|
|
|
3661
|
+
// Load environment variables.
|
|
3662
|
+
sweet.middlewares.Environment.mount();
|
|
3663
|
+
|
|
3664
|
+
// Rekognition Client.
|
|
3626
3665
|
const client = new sweet.services.AWSRekognitionClient({
|
|
3627
3666
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3628
3667
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
@@ -3632,9 +3671,13 @@ const client = new sweet.services.AWSRekognitionClient({
|
|
|
3632
3671
|
</div>
|
|
3633
3672
|
<div class="tab-pane fade" id="rekognition-constructor-cjs">
|
|
3634
3673
|
<div class="highlight">
|
|
3635
|
-
<pre><code class="js">const
|
|
3636
|
-
|
|
3637
|
-
|
|
3674
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
3675
|
+
|
|
3676
|
+
// Load environment variables.
|
|
3677
|
+
sweet.middlewares.Environment.mount();
|
|
3678
|
+
|
|
3679
|
+
// Rekognition Client.
|
|
3680
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
3638
3681
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3639
3682
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
3640
3683
|
region: process.env.AWS_REKOGNITION_REGION
|
|
@@ -3645,7 +3688,11 @@ const client = new AWSRekognitionClient({
|
|
|
3645
3688
|
</div>
|
|
3646
3689
|
</li>
|
|
3647
3690
|
<li class="list-group-item">
|
|
3648
|
-
<div class="fw-bold"
|
|
3691
|
+
<div class="fw-bold">
|
|
3692
|
+
<code class="h5">
|
|
3693
|
+
public async detectFaces(img: string, minConfidence: number = 90, withDetails: boolean = false): Promise<<a href="#rekognition-bbox-interface">BoundingBox</a>[]|<a href="#rekognition-face-details-interface">FaceDetails</a>[]>
|
|
3694
|
+
</code>
|
|
3695
|
+
</div>
|
|
3649
3696
|
<div class="ms-3">
|
|
3650
3697
|
<p>
|
|
3651
3698
|
Detects faces within an image that is provided as input.<br>
|
|
@@ -3664,9 +3711,19 @@ const client = new AWSRekognitionClient({
|
|
|
3664
3711
|
Faces with a confidence lower than this value will not be returned as a result.
|
|
3665
3712
|
</div>
|
|
3666
3713
|
</li>
|
|
3714
|
+
<li class="list-group-item pt-0 border-0">
|
|
3715
|
+
<div class="fw-bold"><code>boolean</code>withDetails</div>
|
|
3716
|
+
<div class="ms-3">
|
|
3717
|
+
If false, returns only the face bounding box.<br>
|
|
3718
|
+
When true, returns the age group, gender, and emotion in addition to the face bounding box.
|
|
3719
|
+
</div>
|
|
3720
|
+
</li>
|
|
3667
3721
|
</ul>
|
|
3668
3722
|
<h6>Return value</h6>
|
|
3669
|
-
<p
|
|
3723
|
+
<p>
|
|
3724
|
+
<code>Promise<<a href="#rekognition-bbox-interface">BoundingBox</a>[]|<a href="#rekognition-face-details-interface">FaceDetails</a>[]></code>
|
|
3725
|
+
Returns the bounding box of the detected face.
|
|
3726
|
+
</p>
|
|
3670
3727
|
<h6>Example</h6>
|
|
3671
3728
|
<ul class="nav nav-tabs">
|
|
3672
3729
|
<li class="nav-item">
|
|
@@ -3682,22 +3739,55 @@ const client = new AWSRekognitionClient({
|
|
|
3682
3739
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
3683
3740
|
import fs from 'fs';
|
|
3684
3741
|
|
|
3742
|
+
// Load environment variables.
|
|
3743
|
+
sweet.middlewares.Environment.mount();
|
|
3744
|
+
|
|
3745
|
+
// Rekognition Client.
|
|
3685
3746
|
const client = new sweet.services.AWSRekognitionClient({
|
|
3686
3747
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3687
3748
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
3688
3749
|
region: process.env.AWS_REKOGNITION_REGION
|
|
3689
3750
|
});
|
|
3690
3751
|
|
|
3691
|
-
//
|
|
3692
|
-
// Output:
|
|
3693
|
-
//
|
|
3694
|
-
//
|
|
3695
|
-
//
|
|
3696
|
-
//
|
|
3697
|
-
//
|
|
3698
|
-
//
|
|
3699
|
-
//
|
|
3700
|
-
await client.detectFaces('img.jpg');
|
|
3752
|
+
// Detects bounding boxes on faces.
|
|
3753
|
+
// Output: [
|
|
3754
|
+
// {
|
|
3755
|
+
// width: 0.3099822998046875,
|
|
3756
|
+
// height: 0.661512017250061,
|
|
3757
|
+
// left: 0.5449195504188538,
|
|
3758
|
+
// top: 0.11531734466552734
|
|
3759
|
+
// }
|
|
3760
|
+
// ]
|
|
3761
|
+
let res = await client.detectFaces('img/face2.jpg');
|
|
3762
|
+
console.log(res);
|
|
3763
|
+
|
|
3764
|
+
// Detect facial details.
|
|
3765
|
+
// Output: [
|
|
3766
|
+
// {
|
|
3767
|
+
// boundingBox: {
|
|
3768
|
+
// width: 0.3099822998046875,
|
|
3769
|
+
// height: 0.661512017250061,
|
|
3770
|
+
// left: 0.5449195504188538,
|
|
3771
|
+
// top: 0.11531734466552734
|
|
3772
|
+
// },
|
|
3773
|
+
// ageRange: { high: 14, low: 6 },
|
|
3774
|
+
// gender: 'female',
|
|
3775
|
+
// emotions: {
|
|
3776
|
+
// happy: 99.78905487060547,
|
|
3777
|
+
// surprised: 6.306276321411133,
|
|
3778
|
+
// fear: 5.880091190338135,
|
|
3779
|
+
// sad: 2.152125835418701,
|
|
3780
|
+
// confused: 0.023256277665495872,
|
|
3781
|
+
// angry: 0.018351631239056587,
|
|
3782
|
+
// calm: 0.015775982290506363,
|
|
3783
|
+
// disgusted: 0.013914424926042557
|
|
3784
|
+
// }
|
|
3785
|
+
// }
|
|
3786
|
+
// ]
|
|
3787
|
+
const minConfidence = 90;
|
|
3788
|
+
const withDetails = true;
|
|
3789
|
+
res = await client.detectFaces('img/face2.jpg', minConfidence, withDetails);
|
|
3790
|
+
console.log(res);
|
|
3701
3791
|
|
|
3702
3792
|
// Detect faces from data URL.
|
|
3703
3793
|
await client.detectFaces('data:image/png;base64,/9j/4...');
|
|
@@ -3708,25 +3798,58 @@ await client.detectFaces(fs.readFileSync('img.jpg'));</code></pre>
|
|
|
3708
3798
|
</div>
|
|
3709
3799
|
<div class="tab-pane fade" id="rekognition-method-detect-faces-cjs">
|
|
3710
3800
|
<div class="highlight">
|
|
3711
|
-
<pre><code class="js">const
|
|
3801
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
3712
3802
|
const fs = require('fs');
|
|
3713
3803
|
|
|
3714
|
-
|
|
3804
|
+
// Load environment variables.
|
|
3805
|
+
sweet.middlewares.Environment.mount();
|
|
3806
|
+
|
|
3807
|
+
// Rekognition Client.
|
|
3808
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
3715
3809
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3716
3810
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
3717
3811
|
region: process.env.AWS_REKOGNITION_REGION
|
|
3718
3812
|
});
|
|
3719
3813
|
|
|
3720
|
-
//
|
|
3721
|
-
// Output:
|
|
3722
|
-
//
|
|
3723
|
-
//
|
|
3724
|
-
//
|
|
3725
|
-
//
|
|
3726
|
-
//
|
|
3727
|
-
//
|
|
3728
|
-
//
|
|
3729
|
-
await client.detectFaces('img.jpg');
|
|
3814
|
+
// Detects bounding boxes on faces.
|
|
3815
|
+
// Output: [
|
|
3816
|
+
// {
|
|
3817
|
+
// width: 0.3099822998046875,
|
|
3818
|
+
// height: 0.661512017250061,
|
|
3819
|
+
// left: 0.5449195504188538,
|
|
3820
|
+
// top: 0.11531734466552734
|
|
3821
|
+
// }
|
|
3822
|
+
// ]
|
|
3823
|
+
let res = await client.detectFaces('img/face2.jpg');
|
|
3824
|
+
console.log(res);
|
|
3825
|
+
|
|
3826
|
+
// Detect facial details.
|
|
3827
|
+
// Output: [
|
|
3828
|
+
// {
|
|
3829
|
+
// boundingBox: {
|
|
3830
|
+
// width: 0.3099822998046875,
|
|
3831
|
+
// height: 0.661512017250061,
|
|
3832
|
+
// left: 0.5449195504188538,
|
|
3833
|
+
// top: 0.11531734466552734
|
|
3834
|
+
// },
|
|
3835
|
+
// ageRange: { high: 14, low: 6 },
|
|
3836
|
+
// gender: 'female',
|
|
3837
|
+
// emotions: {
|
|
3838
|
+
// happy: 99.78905487060547,
|
|
3839
|
+
// surprised: 6.306276321411133,
|
|
3840
|
+
// fear: 5.880091190338135,
|
|
3841
|
+
// sad: 2.152125835418701,
|
|
3842
|
+
// confused: 0.023256277665495872,
|
|
3843
|
+
// angry: 0.018351631239056587,
|
|
3844
|
+
// calm: 0.015775982290506363,
|
|
3845
|
+
// disgusted: 0.013914424926042557
|
|
3846
|
+
// }
|
|
3847
|
+
// }
|
|
3848
|
+
// ]
|
|
3849
|
+
const minConfidence = 90;
|
|
3850
|
+
const withDetails = true;
|
|
3851
|
+
res = await client.detectFaces('img/face2.jpg', minConfidence, withDetails);
|
|
3852
|
+
console.log(res);
|
|
3730
3853
|
|
|
3731
3854
|
// Detect faces from data URL.
|
|
3732
3855
|
await client.detectFaces('data:image/png;base64,/9j/4...');
|
|
@@ -3770,6 +3893,10 @@ await client.detectFaces(fs.readFileSync('img.jpg'));</code></pre>
|
|
|
3770
3893
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
3771
3894
|
import fs from 'fs';
|
|
3772
3895
|
|
|
3896
|
+
// Load environment variables.
|
|
3897
|
+
sweet.middlewares.Environment.mount();
|
|
3898
|
+
|
|
3899
|
+
// Rekognition Client.
|
|
3773
3900
|
const client = new sweet.services.AWSRekognitionClient({
|
|
3774
3901
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3775
3902
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
@@ -3788,10 +3915,14 @@ await client.compareFaces(fs.readFileSync('img1.jpg'), fs.readFileSync
|
|
|
3788
3915
|
</div>
|
|
3789
3916
|
<div class="tab-pane fade" id="rekognition-method-compare-faces-cjs">
|
|
3790
3917
|
<div class="highlight">
|
|
3791
|
-
<pre><code class="js">const
|
|
3918
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
3792
3919
|
const fs = require('fs');
|
|
3793
3920
|
|
|
3794
|
-
|
|
3921
|
+
// Load environment variables.
|
|
3922
|
+
sweet.middlewares.Environment.mount();
|
|
3923
|
+
|
|
3924
|
+
// Rekognition Client.
|
|
3925
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
3795
3926
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3796
3927
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
3797
3928
|
region: process.env.AWS_REKOGNITION_REGION
|
|
@@ -3844,6 +3975,10 @@ await client.compareFaces(fs.readFileSync('img1.jpg'), fs.readFileSync
|
|
|
3844
3975
|
<div class="highlight">
|
|
3845
3976
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
3846
3977
|
|
|
3978
|
+
// Load environment variables.
|
|
3979
|
+
sweet.middlewares.Environment.mount();
|
|
3980
|
+
|
|
3981
|
+
// Rekognition Client.
|
|
3847
3982
|
const client = new sweet.services.AWSRekognitionClient({
|
|
3848
3983
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3849
3984
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
@@ -3856,9 +3991,13 @@ await client.createCollection('MyCollection');</code></pre>
|
|
|
3856
3991
|
</div>
|
|
3857
3992
|
<div class="tab-pane fade" id="rekognition-method-create-collection-cjs">
|
|
3858
3993
|
<div class="highlight">
|
|
3859
|
-
<pre><code class="js">const
|
|
3994
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
3995
|
+
|
|
3996
|
+
// Load environment variables.
|
|
3997
|
+
sweet.middlewares.Environment.mount();
|
|
3860
3998
|
|
|
3861
|
-
|
|
3999
|
+
// Rekognition Client.
|
|
4000
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
3862
4001
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3863
4002
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
3864
4003
|
region: process.env.AWS_REKOGNITION_REGION
|
|
@@ -3893,6 +4032,10 @@ await client.createCollection('MyCollection');</code></pre>
|
|
|
3893
4032
|
<div class="highlight">
|
|
3894
4033
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
3895
4034
|
|
|
4035
|
+
// Load environment variables.
|
|
4036
|
+
sweet.middlewares.Environment.mount();
|
|
4037
|
+
|
|
4038
|
+
// Rekognition Client.
|
|
3896
4039
|
const client = new sweet.services.AWSRekognitionClient({
|
|
3897
4040
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3898
4041
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
@@ -3909,9 +4052,13 @@ await client.listCollections();</code></pre>
|
|
|
3909
4052
|
</div>
|
|
3910
4053
|
<div class="tab-pane fade" id="rekognition-method-list-collections-cjs">
|
|
3911
4054
|
<div class="highlight">
|
|
3912
|
-
<pre><code class="js">const
|
|
3913
|
-
|
|
3914
|
-
|
|
4055
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
4056
|
+
|
|
4057
|
+
// Load environment variables.
|
|
4058
|
+
sweet.middlewares.Environment.mount();
|
|
4059
|
+
|
|
4060
|
+
// Rekognition Client.
|
|
4061
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
3915
4062
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3916
4063
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
3917
4064
|
region: process.env.AWS_REKOGNITION_REGION
|
|
@@ -3955,7 +4102,11 @@ await client.listCollections();</code></pre>
|
|
|
3955
4102
|
<div class="tab-pane fade show active" id="rekognition-method-delete-collection-esm">
|
|
3956
4103
|
<div class="highlight">
|
|
3957
4104
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
3958
|
-
|
|
4105
|
+
|
|
4106
|
+
// Load environment variables.
|
|
4107
|
+
sweet.middlewares.Environment.mount();
|
|
4108
|
+
|
|
4109
|
+
// Rekognition Client.
|
|
3959
4110
|
const client = new sweet.services.AWSRekognitionClient({
|
|
3960
4111
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3961
4112
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
@@ -3968,9 +4119,13 @@ await client.deleteCollection('MyCollection');</code></pre>
|
|
|
3968
4119
|
</div>
|
|
3969
4120
|
<div class="tab-pane fade" id="rekognition-method-delete-collection-cjs">
|
|
3970
4121
|
<div class="highlight">
|
|
3971
|
-
<pre><code class="js">const
|
|
3972
|
-
|
|
3973
|
-
|
|
4122
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
4123
|
+
|
|
4124
|
+
// Load environment variables.
|
|
4125
|
+
sweet.middlewares.Environment.mount();
|
|
4126
|
+
|
|
4127
|
+
// Rekognition Client.
|
|
4128
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
3974
4129
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
3975
4130
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
3976
4131
|
region: process.env.AWS_REKOGNITION_REGION
|
|
@@ -3984,13 +4139,18 @@ await client.deleteCollection('MyCollection');</code></pre>
|
|
|
3984
4139
|
</div>
|
|
3985
4140
|
</li>
|
|
3986
4141
|
<li class="list-group-item">
|
|
3987
|
-
<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>
|
|
3988
4151
|
<div class="ms-3">
|
|
3989
4152
|
<p>
|
|
3990
|
-
Detects one face in the input image and adds it to the specified collection
|
|
3991
|
-
This method doesn't save the actual faces that are detected.<br>
|
|
3992
|
-
Instead, the underlying detection algorithm first detects the faces in the input image.<br>
|
|
3993
|
-
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.
|
|
3994
4154
|
<div class="callout callout-warning">
|
|
3995
4155
|
Note that this method is used to index one face.<br>
|
|
3996
4156
|
Throws an exception if no face is found in the input image or multiple faces are found.
|
|
@@ -4007,7 +4167,7 @@ await client.deleteCollection('MyCollection');</code></pre>
|
|
|
4007
4167
|
<div class="ms-3">Image path or Data Url or image buffer.</div>
|
|
4008
4168
|
</li>
|
|
4009
4169
|
<li class="list-group-item pt-0 border-0">
|
|
4010
|
-
<div class="fw-bold"><code>string</code>externalImageId</div>
|
|
4170
|
+
<div class="fw-bold"><code>string|undefined</code>options.externalImageId</div>
|
|
4011
4171
|
<div class="ms-3">
|
|
4012
4172
|
The ID you want to assign to the faces detected in the image.<br>
|
|
4013
4173
|
When you call the <code>"listFaces"</code> operation, the response returns the external ID.<br>
|
|
@@ -4016,9 +4176,20 @@ await client.deleteCollection('MyCollection');</code></pre>
|
|
|
4016
4176
|
The maximum length is 255, and the characters that can be used are <code>"[a-zA-Z0-9_.\-:]+"</code>.
|
|
4017
4177
|
</div>
|
|
4018
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>
|
|
4019
4186
|
</ul>
|
|
4020
4187
|
<h6>Return value</h6>
|
|
4021
|
-
<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>
|
|
4022
4193
|
<h6>Example</h6>
|
|
4023
4194
|
<ul class="nav nav-tabs">
|
|
4024
4195
|
<li class="nav-item">
|
|
@@ -4034,65 +4205,91 @@ await client.deleteCollection('MyCollection');</code></pre>
|
|
|
4034
4205
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
4035
4206
|
import fs from 'fs';
|
|
4036
4207
|
|
|
4208
|
+
// Load environment variables.
|
|
4209
|
+
sweet.middlewares.Environment.mount();
|
|
4210
|
+
|
|
4211
|
+
// Rekognition Client.
|
|
4037
4212
|
const client = new sweet.services.AWSRekognitionClient({
|
|
4038
4213
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
4039
4214
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
4040
4215
|
region: process.env.AWS_REKOGNITION_REGION
|
|
4041
4216
|
});
|
|
4042
4217
|
|
|
4043
|
-
//
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
//
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
//
|
|
4053
|
-
//
|
|
4054
|
-
//
|
|
4055
|
-
//
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
//
|
|
4059
|
-
//
|
|
4060
|
-
//
|
|
4061
|
-
//
|
|
4062
|
-
|
|
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);
|
|
4241
|
+
|
|
4242
|
+
// You can also index face images in DataURL format.
|
|
4243
|
+
await client.indexFace('MyCollection', 'data:image/png;base64,/9j/4...');
|
|
4244
|
+
|
|
4245
|
+
// Buffer face images can also be indexed.
|
|
4246
|
+
await client.indexFace('MyCollection', fs.readFileSync('img.jpg'));</code></pre>
|
|
4063
4247
|
</div>
|
|
4064
4248
|
</div>
|
|
4065
4249
|
<div class="tab-pane fade" id="rekognition-method-index-face-cjs">
|
|
4066
4250
|
<div class="highlight">
|
|
4067
|
-
<pre><code class="js">const
|
|
4251
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
4068
4252
|
const fs = require('fs');
|
|
4069
4253
|
|
|
4070
|
-
|
|
4254
|
+
// Load environment variables.
|
|
4255
|
+
sweet.middlewares.Environment.mount();
|
|
4256
|
+
|
|
4257
|
+
// Rekognition Client.
|
|
4258
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
4071
4259
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
4072
4260
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
4073
4261
|
region: process.env.AWS_REKOGNITION_REGION
|
|
4074
4262
|
});
|
|
4075
4263
|
|
|
4076
|
-
//
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
//
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
//
|
|
4086
|
-
//
|
|
4087
|
-
//
|
|
4088
|
-
//
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
//
|
|
4092
|
-
//
|
|
4093
|
-
//
|
|
4094
|
-
//
|
|
4095
|
-
|
|
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);
|
|
4287
|
+
|
|
4288
|
+
// You can also index face images in DataURL format.
|
|
4289
|
+
await client.indexFace('MyCollection', 'data:image/png;base64,/9j/4...');
|
|
4290
|
+
|
|
4291
|
+
// Buffer face images can also be indexed.
|
|
4292
|
+
await client.indexFace('MyCollection', fs.readFileSync('img.jpg'));</code></pre>
|
|
4096
4293
|
</div>
|
|
4097
4294
|
</div>
|
|
4098
4295
|
</div>
|
|
@@ -4154,6 +4351,10 @@ await client.indexFace('MyCollection', 'img.jpg');</code></p
|
|
|
4154
4351
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
4155
4352
|
import fs from 'fs';
|
|
4156
4353
|
|
|
4354
|
+
// Load environment variables.
|
|
4355
|
+
sweet.middlewares.Environment.mount();
|
|
4356
|
+
|
|
4357
|
+
// Rekognition Client.
|
|
4157
4358
|
const client = new sweet.services.AWSRekognitionClient({
|
|
4158
4359
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
4159
4360
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
@@ -4201,10 +4402,14 @@ await client.searchFaces('MyCollection', fs.readFileSync('img.jpg
|
|
|
4201
4402
|
</div>
|
|
4202
4403
|
<div class="tab-pane fade" id="rekognition-method-search-faces-cjs">
|
|
4203
4404
|
<div class="highlight">
|
|
4204
|
-
<pre><code class="js">const
|
|
4405
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
4205
4406
|
const fs = require('fs');
|
|
4206
4407
|
|
|
4207
|
-
|
|
4408
|
+
// Load environment variables.
|
|
4409
|
+
sweet.middlewares.Environment.mount();
|
|
4410
|
+
|
|
4411
|
+
// Rekognition Client.
|
|
4412
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
4208
4413
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
4209
4414
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
4210
4415
|
region: process.env.AWS_REKOGNITION_REGION
|
|
@@ -4285,7 +4490,11 @@ await client.searchFaces('MyCollection', fs.readFileSync('img.jpg
|
|
|
4285
4490
|
<div class="tab-pane fade show active" id="rekognition-method-list-faces-esm">
|
|
4286
4491
|
<div class="highlight">
|
|
4287
4492
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
4288
|
-
|
|
4493
|
+
|
|
4494
|
+
// Load environment variables.
|
|
4495
|
+
sweet.middlewares.Environment.mount();
|
|
4496
|
+
|
|
4497
|
+
// Rekognition Client.
|
|
4289
4498
|
const client = new sweet.services.AWSRekognitionClient({
|
|
4290
4499
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
4291
4500
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
@@ -4311,9 +4520,13 @@ console.log(result);</code></pre>
|
|
|
4311
4520
|
</div>
|
|
4312
4521
|
<div class="tab-pane fade" id="rekognition-method-list-faces-cjs">
|
|
4313
4522
|
<div class="highlight">
|
|
4314
|
-
<pre><code class="js">const
|
|
4315
|
-
|
|
4316
|
-
|
|
4523
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
4524
|
+
|
|
4525
|
+
// Load environment variables.
|
|
4526
|
+
sweet.middlewares.Environment.mount();
|
|
4527
|
+
|
|
4528
|
+
// Rekognition Client.
|
|
4529
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
4317
4530
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
4318
4531
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
4319
4532
|
region: process.env.AWS_REKOGNITION_REGION
|
|
@@ -4370,7 +4583,11 @@ console.log(result);</code></pre>
|
|
|
4370
4583
|
<div class="tab-pane fade show active" id="rekognition-method-delete-faces-esm">
|
|
4371
4584
|
<div class="highlight">
|
|
4372
4585
|
<pre><code class="js">import * as sweet from 'express-sweet';
|
|
4373
|
-
|
|
4586
|
+
|
|
4587
|
+
// Load environment variables.
|
|
4588
|
+
sweet.middlewares.Environment.mount();
|
|
4589
|
+
|
|
4590
|
+
// Rekognition Client.
|
|
4374
4591
|
const client = new sweet.services.AWSRekognitionClient({
|
|
4375
4592
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
4376
4593
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
@@ -4383,9 +4600,13 @@ await client.deleteFaces('MyCollection', ['f7befa24-3b83-43cc-b21
|
|
|
4383
4600
|
</div>
|
|
4384
4601
|
<div class="tab-pane fade" id="rekognition-method-delete-faces-cjs">
|
|
4385
4602
|
<div class="highlight">
|
|
4386
|
-
<pre><code class="js">const
|
|
4387
|
-
|
|
4388
|
-
|
|
4603
|
+
<pre><code class="js">const sweet = require('express-sweet');
|
|
4604
|
+
|
|
4605
|
+
// Load environment variables.
|
|
4606
|
+
sweet.middlewares.Environment.mount();
|
|
4607
|
+
|
|
4608
|
+
// Rekognition Client.
|
|
4609
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
4389
4610
|
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
4390
4611
|
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
4391
4612
|
region: process.env.AWS_REKOGNITION_REGION
|
|
@@ -4428,8 +4649,83 @@ await client.deleteFaces('MyCollection', ['f7befa24-3b83-43cc-b21
|
|
|
4428
4649
|
<div class="ms-3">Confidence in the match of this face with the input face.<br>Valid Range: Minimum value of 0. Maximum value of 100.</div>
|
|
4429
4650
|
</li>
|
|
4430
4651
|
</ul>
|
|
4652
|
+
<h2 id="rekognition-face-details-interface">Interface FaceDetails<span class="fs-5 ms-2">(express-sweet.interfaces.FaceDetails)</span></h2>
|
|
4653
|
+
<p>Details of each face found in the image. </p>
|
|
4654
|
+
<h3>Properties</h3>
|
|
4655
|
+
<ul class="list-group list-group-flush">
|
|
4656
|
+
<li class="list-group-item">
|
|
4657
|
+
<div class="fw-bold"><code class="h5">boundingBox: <a href="#rekognition-bbox-interface">BoundingBox</a></code></div>
|
|
4658
|
+
<div class="ms-3">Bounding box of the face.</div>
|
|
4659
|
+
</li>
|
|
4660
|
+
<li class="list-group-item">
|
|
4661
|
+
<div class="fw-bold"><code class="h5">ageRange?: {high: UInteger, low: UInteger}</code></div>
|
|
4662
|
+
<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>
|
|
4663
|
+
</li>
|
|
4664
|
+
<li class="list-group-item">
|
|
4665
|
+
<div class="fw-bold"><code class="h5">gender?: 'male'|'female'</code></div>
|
|
4666
|
+
<div class="ms-3">The predicted gender of a detected face. </div>
|
|
4667
|
+
</li>
|
|
4668
|
+
<li class="list-group-item">
|
|
4669
|
+
<div class="fw-bold"><code class="h5">emotions?: <a href="#rekognition-face-details-emotions-interface">FaceDetailsEmotions</a></code></div>
|
|
4670
|
+
<div class="ms-3">The predicted gender of a detected face. </div>
|
|
4671
|
+
</li>
|
|
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>
|
|
4694
|
+
<h2 id="rekognition-face-details-emotions-interface">Interface FaceDetailsEmotions<span class="fs-5 ms-2">(express-sweet.interfaces.FaceDetailsEmotions)</span></h2>
|
|
4695
|
+
<p>The emotions that appear to be expressed on the face, and the confidence level in the determination. </p>
|
|
4696
|
+
<h3>Properties</h3>
|
|
4697
|
+
<ul class="list-group list-group-flush">
|
|
4698
|
+
<li class="list-group-item">
|
|
4699
|
+
<div class="fw-bold"><code class="h5">disgusted: number</code></div>
|
|
4700
|
+
<div class="ms-3">Confidence level of "disgusted" predicted from the face.</div>
|
|
4701
|
+
</li>
|
|
4702
|
+
<li class="list-group-item">
|
|
4703
|
+
<div class="fw-bold"><code class="h5">happy: number</code></div>
|
|
4704
|
+
<div class="ms-3">Confidence level of "happy" predicted from the face.</div>
|
|
4705
|
+
</li>
|
|
4706
|
+
<li class="list-group-item">
|
|
4707
|
+
<div class="fw-bold"><code class="h5">surprised: number</code></div>
|
|
4708
|
+
<div class="ms-3">Confidence level of "surprised" predicted from the face.</div>
|
|
4709
|
+
</li>
|
|
4710
|
+
<li class="list-group-item">
|
|
4711
|
+
<div class="fw-bold"><code class="h5">angry: number</code></div>
|
|
4712
|
+
<div class="ms-3">Confidence level of "angry" predicted from the face.</div>
|
|
4713
|
+
</li>
|
|
4714
|
+
<li class="list-group-item">
|
|
4715
|
+
<div class="fw-bold"><code class="h5">confused: number</code></div>
|
|
4716
|
+
<div class="ms-3">Confidence level of "confused" predicted from the face.</div>
|
|
4717
|
+
</li>
|
|
4718
|
+
<li class="list-group-item">
|
|
4719
|
+
<div class="fw-bold"><code class="h5">calm: number</code></div>
|
|
4720
|
+
<div class="ms-3">Confidence level of "calm" predicted from the face.</div>
|
|
4721
|
+
</li>
|
|
4722
|
+
<li class="list-group-item">
|
|
4723
|
+
<div class="fw-bold"><code class="h5">sad: number</code></div>
|
|
4724
|
+
<div class="ms-3">Confidence level of "sad" predicted from the face.</div>
|
|
4725
|
+
</li>
|
|
4726
|
+
</ul>
|
|
4431
4727
|
<h2 id="rekognition-bbox-interface">Interface BoundingBox<span class="fs-5 ms-2">(express-sweet.interfaces.BoundingBox)</span></h2>
|
|
4432
|
-
<p>Bounding box
|
|
4728
|
+
<p>Bounding box of the face.</p>
|
|
4433
4729
|
<h3>Properties</h3>
|
|
4434
4730
|
<ul class="list-group list-group-flush">
|
|
4435
4731
|
<li class="list-group-item">
|