express-sweet 1.0.39 → 1.0.41

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 CHANGED
@@ -1,6 +1,64 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [1.0.41] - 2023/8/4
5
+ ### Changed
6
+ - Added an option to the method that searches for faces in the collection to throw an exception if a face is not found or if multiple faces are found.
7
+ <table>
8
+ <thead>
9
+ <tr>
10
+ <th>Option</th>
11
+ <th>Type</th>
12
+ <th>Description</th>
13
+ </tr>
14
+ </thead>
15
+ <tbody>
16
+ <tr>
17
+ <td>throwNotFoundFaceException</td>
18
+ <td>boolean</td>
19
+ <td>If true, throws a <code>FaceMissingInPhoto</code> exception when a face is not found in the image; if false, returns null. Default is false.</td>
20
+ </tr>
21
+ <tr>
22
+ <td>throwTooManyFaceException</td>
23
+ <td>boolean</td>
24
+ <td>If true, throws a <code>FacesMultipleInPhoto</code> exception when more than one face is found in the image. Default is false.</td>
25
+ </tr>
26
+ </tbody>
27
+ </table>
28
+
29
+ Example:
30
+ ```js
31
+ const {services: {AWSRekognitionClient}, exceptions: {FaceMissingInPhoto, FacesMultipleInPhoto}} = require('express-sweet');
32
+
33
+ // Rekognition Client.
34
+ const client = new AWSRekognitionClient({
35
+ accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
36
+ secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
37
+ region: process.env.AWS_REKOGNITION_REGION,
38
+ });
39
+
40
+ // Find a face in the collection.
41
+ const collectionId = 'MyCollection';
42
+
43
+ try {
44
+ await client.searchFaces(collectionId, 'face.jpg', {
45
+ throwNotFoundFaceException: true,
46
+ throwTooManyFaceException: true,
47
+ });
48
+ } catch (err) {
49
+ if (err instanceof FaceMissingInPhoto)
50
+ console.log('No face was found');
51
+ else if (err instanceof FacesMultipleInPhoto)
52
+ console.log('Multiple faces were found');
53
+ else
54
+ console.log('Other errors');
55
+ }
56
+ ```
57
+
58
+ ## [1.0.40] - 2023/8/4
59
+ ### Changed
60
+ - Fixed to return null instead of throwing an error when looking for faces in the collection using images without faces (<code>AWSRekognitionClient.searchFaces()</code>).
61
+
4
62
  ## [1.0.39] - 2023/7/24
5
63
  ### Changed
6
64
  - Changed exception class name.
@@ -442,7 +500,7 @@ All notable changes to this project will be documented in this file.
442
500
 
443
501
  // Create a face and get the ID of the created face.
444
502
  // results in: e65d66cb-e7bc-4bbf-966c-b1b49ddf29f8
445
- const faceId = await client.indexFace(collectionId, 'img/face4.jpg');
503
+ const faceId = await client.indexFace(collectionId, 'face4.jpg');
446
504
  console.log(faceId);
447
505
 
448
506
  // Create a face and get the details of the created face.
@@ -461,7 +519,7 @@ All notable changes to this project will be documented in this file.
461
519
  // calm: 1.5354809761047363
462
520
  // }
463
521
  // }
464
- const faceDetails = await client.indexFace(collectionId, 'img/face5.jpg', {returnDetails: true});
522
+ const faceDetails = await client.indexFace(collectionId, 'face5.jpg', {returnDetails: true});
465
523
  console.log(faceDetails);
466
524
  ```
467
525
 
@@ -491,7 +549,7 @@ All notable changes to this project will be documented in this file.
491
549
  // top: 0.11531734466552734
492
550
  // }
493
551
  // ]
494
- let res = await client.detectFaces('img/face.jpg');
552
+ let res = await client.detectFaces('face.jpg');
495
553
  console.log(res);
496
554
 
497
555
  // Detect facial details.
@@ -519,7 +577,7 @@ All notable changes to this project will be documented in this file.
519
577
  // ]
520
578
  const minConfidence = 90;
521
579
  const withDetails = true;
522
- res = await client.detectFaces('img/face.jpg', minConfidence, withDetails);
580
+ res = await client.detectFaces('face.jpg', minConfidence, withDetails);
523
581
  console.log(res);
524
582
  })();
525
583
  ```
@@ -680,7 +738,7 @@ All notable changes to this project will be documented in this file.
680
738
  // }
681
739
  // ]
682
740
  const collectionId = 'MyCollection';
683
- const res = await client.searchFaces(collectionId, 'img/face.jpg');
741
+ const res = await client.searchFaces(collectionId, 'face.jpg');
684
742
  console.log('Face search results:', res);
685
743
  ```
686
744
 
@@ -768,4 +826,6 @@ All notable changes to this project will be documented in this file.
768
826
  [1.0.36]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.35...v1.0.36
769
827
  [1.0.37]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.36...v1.0.37
770
828
  [1.0.38]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.37...v1.0.38
771
- [1.0.39]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.38...v1.0.39
829
+ [1.0.39]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.38...v1.0.39
830
+ [1.0.40]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.39...v1.0.40
831
+ [1.0.41]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.40...v1.0.41