express-sweet 1.0.19 → 1.0.22
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 +132 -1
- package/dist/build.common.js +4 -4
- package/dist/build.esm.js +5 -5
- package/docs/index.html +403 -115
- package/package.json +2 -2
- package/types/database/Model.d.ts +1 -1
- package/types/interfaces/AuthenticationOptions.d.ts +0 -1
- package/types/interfaces/BoundingBox.d.ts +1 -1
- package/types/interfaces/FaceDetailsEmotions.d.ts +40 -0
- package/types/interfaces/ViewOptions.d.ts +14 -0
- package/types/services/AWSRekognitionClient.d.ts +25 -254
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,133 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
## [1.0.22] - 2022-07-27
|
|
5
|
+
### Fixed
|
|
6
|
+
- You can now set hook functions that are called before the view is rendered.
|
|
7
|
+
Hook functions can be used, for example, to set local variables that can be used in the view.
|
|
8
|
+
|
|
9
|
+
To use, add the beforeRender hook function to "config/view.js" as follows.
|
|
10
|
+
```js
|
|
11
|
+
/**
|
|
12
|
+
* Hook function just before the view is rendered.
|
|
13
|
+
* For example, you can set your own local variables that can be used within the view.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // The message set here can be referenced in the view as {{message}}.
|
|
17
|
+
* beforeRender: res => {
|
|
18
|
+
* res.loclas.message = 'Hello World';
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* @type {(res: express.Response) => void}
|
|
22
|
+
*/
|
|
23
|
+
beforeRender: res => {
|
|
24
|
+
res.loclas.message = 'Hello World';
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## [1.0.21] - 2022-05-26
|
|
29
|
+
### Fixed
|
|
30
|
+
- Added an option to the face indexing method to retrieve details (gender, emotion, age group) of indexed faces.
|
|
31
|
+
```js
|
|
32
|
+
const sweet = require('../dist/build.common');
|
|
33
|
+
|
|
34
|
+
// Load environment variables.
|
|
35
|
+
sweet.middlewares.Environment.mount();
|
|
36
|
+
|
|
37
|
+
// Rekognition Client.
|
|
38
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
39
|
+
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
40
|
+
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
41
|
+
region: process.env.AWS_REKOGNITION_REGION
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Collection ID for testing.
|
|
45
|
+
const collectionId = 'MyCollection';
|
|
46
|
+
|
|
47
|
+
// Create a face and get the ID of the created face.
|
|
48
|
+
// Output: e65d66cb-e7bc-4bbf-966c-b1b49ddf29f8
|
|
49
|
+
const faceId = await client.indexFace(collectionId, 'img/face4.jpg');
|
|
50
|
+
console.log(faceId);
|
|
51
|
+
|
|
52
|
+
// Create a face and get the details of the created face.
|
|
53
|
+
// Output: {
|
|
54
|
+
// faceId: '7f2dd321-f047-44ff-8856-864637e1d286',
|
|
55
|
+
// ageRange: { high: 29, low: 21 },
|
|
56
|
+
// gender: 'female',
|
|
57
|
+
// emotions: {
|
|
58
|
+
// angry: 77.1907958984375,
|
|
59
|
+
// surprised: 9.944050788879395,
|
|
60
|
+
// fear: 7.514361381530762,
|
|
61
|
+
// confused: 4.780297756195068,
|
|
62
|
+
// sad: 2.91914963722229,
|
|
63
|
+
// happy: 2.5718722343444824,
|
|
64
|
+
// disgusted: 1.933768391609192,
|
|
65
|
+
// calm: 1.5354809761047363
|
|
66
|
+
// }
|
|
67
|
+
// }
|
|
68
|
+
const faceDetails = await client.indexFace(collectionId, 'img/face5.jpg', {returnDetails: true});
|
|
69
|
+
console.log(faceDetails);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## [1.0.20] - 2022-05-25
|
|
73
|
+
### Fixed
|
|
74
|
+
- Added an option to get details (emotion, gender, age group) to the face detection method.
|
|
75
|
+
```js
|
|
76
|
+
const sweet = require('../dist/build.common');
|
|
77
|
+
|
|
78
|
+
// Load environment variables.
|
|
79
|
+
sweet.middlewares.Environment.mount();
|
|
80
|
+
|
|
81
|
+
// Rekognition Client.
|
|
82
|
+
const client = new sweet.services.AWSRekognitionClient({
|
|
83
|
+
accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
|
|
84
|
+
secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
|
|
85
|
+
region: process.env.AWS_REKOGNITION_REGION
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
(async () => {
|
|
89
|
+
// Detects bounding boxes on faces.
|
|
90
|
+
// Output: [
|
|
91
|
+
// {
|
|
92
|
+
// width: 0.3099822998046875,
|
|
93
|
+
// height: 0.661512017250061,
|
|
94
|
+
// left: 0.5449195504188538,
|
|
95
|
+
// top: 0.11531734466552734
|
|
96
|
+
// }
|
|
97
|
+
// ]
|
|
98
|
+
let res = await client.detectFaces('img/face.jpg');
|
|
99
|
+
console.log(res);
|
|
100
|
+
|
|
101
|
+
// Detect facial details.
|
|
102
|
+
// Output: [
|
|
103
|
+
// {
|
|
104
|
+
// boundingBox: {
|
|
105
|
+
// width: 0.3099822998046875,
|
|
106
|
+
// height: 0.661512017250061,
|
|
107
|
+
// left: 0.5449195504188538,
|
|
108
|
+
// top: 0.11531734466552734
|
|
109
|
+
// },
|
|
110
|
+
// ageRange: { high: 14, low: 6 },
|
|
111
|
+
// gender: 'female',
|
|
112
|
+
// emotions: {
|
|
113
|
+
// happy: 99.78905487060547,
|
|
114
|
+
// surprised: 6.306276321411133,
|
|
115
|
+
// fear: 5.880091190338135,
|
|
116
|
+
// sad: 2.152125835418701,
|
|
117
|
+
// confused: 0.023256277665495872,
|
|
118
|
+
// angry: 0.018351631239056587,
|
|
119
|
+
// calm: 0.015775982290506363,
|
|
120
|
+
// disgusted: 0.013914424926042557
|
|
121
|
+
// }
|
|
122
|
+
// }
|
|
123
|
+
// ]
|
|
124
|
+
const minConfidence = 90;
|
|
125
|
+
const withDetails = true;
|
|
126
|
+
res = await client.detectFaces('img/face.jpg', minConfidence, withDetails);
|
|
127
|
+
console.log(res);
|
|
128
|
+
})();
|
|
129
|
+
```
|
|
130
|
+
|
|
4
131
|
## [1.0.19] - 2022-05-20
|
|
5
132
|
### Fixed
|
|
6
133
|
- Add date format helper to view.
|
|
@@ -221,4 +348,8 @@ All notable changes to this project will be documented in this file.
|
|
|
221
348
|
[1.0.15]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.14...v1.0.15
|
|
222
349
|
[1.0.16]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.15...v1.0.16
|
|
223
350
|
[1.0.17]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.16...v1.0.17
|
|
224
|
-
[1.0.18]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.17...v1.0.18
|
|
351
|
+
[1.0.18]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.17...v1.0.18
|
|
352
|
+
[1.0.19]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.18...v1.0.19
|
|
353
|
+
[1.0.20]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.19...v1.0.20
|
|
354
|
+
[1.0.21]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.20...v1.0.21
|
|
355
|
+
[1.0.22]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.21...v1.0.22
|