express-sweet 1.0.40 → 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,60 @@
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
+
4
58
  ## [1.0.40] - 2023/8/4
5
59
  ### Changed
6
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>).
@@ -446,7 +500,7 @@ All notable changes to this project will be documented in this file.
446
500
 
447
501
  // Create a face and get the ID of the created face.
448
502
  // results in: e65d66cb-e7bc-4bbf-966c-b1b49ddf29f8
449
- const faceId = await client.indexFace(collectionId, 'img/face4.jpg');
503
+ const faceId = await client.indexFace(collectionId, 'face4.jpg');
450
504
  console.log(faceId);
451
505
 
452
506
  // Create a face and get the details of the created face.
@@ -465,7 +519,7 @@ All notable changes to this project will be documented in this file.
465
519
  // calm: 1.5354809761047363
466
520
  // }
467
521
  // }
468
- const faceDetails = await client.indexFace(collectionId, 'img/face5.jpg', {returnDetails: true});
522
+ const faceDetails = await client.indexFace(collectionId, 'face5.jpg', {returnDetails: true});
469
523
  console.log(faceDetails);
470
524
  ```
471
525
 
@@ -495,7 +549,7 @@ All notable changes to this project will be documented in this file.
495
549
  // top: 0.11531734466552734
496
550
  // }
497
551
  // ]
498
- let res = await client.detectFaces('img/face.jpg');
552
+ let res = await client.detectFaces('face.jpg');
499
553
  console.log(res);
500
554
 
501
555
  // Detect facial details.
@@ -523,7 +577,7 @@ All notable changes to this project will be documented in this file.
523
577
  // ]
524
578
  const minConfidence = 90;
525
579
  const withDetails = true;
526
- res = await client.detectFaces('img/face.jpg', minConfidence, withDetails);
580
+ res = await client.detectFaces('face.jpg', minConfidence, withDetails);
527
581
  console.log(res);
528
582
  })();
529
583
  ```
@@ -684,7 +738,7 @@ All notable changes to this project will be documented in this file.
684
738
  // }
685
739
  // ]
686
740
  const collectionId = 'MyCollection';
687
- const res = await client.searchFaces(collectionId, 'img/face.jpg');
741
+ const res = await client.searchFaces(collectionId, 'face.jpg');
688
742
  console.log('Face search results:', res);
689
743
  ```
690
744
 
@@ -773,4 +827,5 @@ All notable changes to this project will be documented in this file.
773
827
  [1.0.37]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.36...v1.0.37
774
828
  [1.0.38]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.37...v1.0.38
775
829
  [1.0.39]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.38...v1.0.39
776
- [1.0.40]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.39...v1.0.40
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