visageSDK
VisageFaceAnalyser.h
1 //
3 // (c) Visage Technologies AB 2002 - 2023 All rights reserved.
4 //
5 // This file is part of visage|SDK(tm).
6 // Unauthorized copying of this file, via any medium is strictly prohibited.
7 //
8 // No warranty, explicit or implicit, provided.
9 //
10 // This is proprietary software. No part of this software may be used or
11 // reproduced in any form or by any means otherwise than in accordance with
12 // any written license granted by Visage Technologies AB.
13 //
15 
16 
17 
18 #ifndef _FACEANALYSER_H
19 #define _FACEANALYSER_H
20 
21 
22 #ifdef VISAGE_STATIC
23  #define VISAGE_ANALYSER_DECLSPEC
24 #else
25 
26  #ifdef VISAGE_ANALYSER_EXPORTS
27  #define VISAGE_ANALYSER_DECLSPEC __declspec(dllexport)
28  #else
29  #define VISAGE_ANALYSER_DECLSPEC __declspec(dllimport)
30  #endif
31 
32 #endif
33 
34 #define VFA_MAX_FACES 20
35 
36 #include "FaceData.h"
37 #include <array>
38 #include <deque>
39 
40 namespace VNN
41 {
42 class INNFrontend;
43 class INNRunner;
44 }
45 
46 namespace VisageSDK
47 {
48 class ScoreFilter;
49 class SmoothingFilter;
50 class VFAConcatenatedInstance;
51 
52 const int VFA_EMOTIONS_COUNT = 7;
53 
57  Anger = 0,
58  Disgust = 1,
59  Fear = 2,
60  Happiness = 3,
61  Sadness = 4,
62  Surprise = 5,
63  Neutral = 6
64 };
65 
70 enum VFAFlags {
71  VFA_AGE = 1,
72  VFA_GENDER = 2,
74 };
75 
78 enum class VFAReturnCode {
79  NoError,
80  InvalidFrame,
84 };
85 
111 struct VISAGE_ANALYSER_DECLSPEC AnalysisData
112 {
113  float age = -1.0f;
114  bool ageValid = false;
115  int gender = -1;
116  bool genderValid = false;
117  std::array<float, VFA_EMOTIONS_COUNT> emotionProbabilities = { 0.0 };
118  bool emotionsValid = false;
119 };
120 
121 #ifndef ANDROID
122 int VISAGE_DECLSPEC initializeLicenseManager(const char *licenseKeyFileFolder);
123 #endif
124 
129 const VISAGE_DECLSPEC char* getVisageSDKVersion(void);
130 
163 class VISAGE_ANALYSER_DECLSPEC VisageFaceAnalyser
164 {
165 
166 public:
173 
214  int init(const char* dataPath);
215 
277  VFAReturnCode analyseImage(const VsImage* image, const FaceData& faceData, const int options, AnalysisData& results);
278 
358  VFAReturnCode analyseStream(const VsImage* frame, const FaceData& faceData, const int options, AnalysisData& results, const int faceIndex = 0);
359 
371  void resetStreamAnalysis(const int faceIndex = -1);
372 
373 private:
374  int m_dataLoaded;
375  std::array<int, VFA_MAX_FACES> m_analyserOptions;
376 
377  VFAConcatenatedInstance* m_emotionRuntime;
378 
379  VNN::INNFrontend* m_ageFrontend;
380  VNN::INNRunner* m_ageRunner;
381 
382  VNN::INNFrontend* m_genderFrontend;
383  VNN::INNRunner* m_genderRunner;
384 
385  std::array<ScoreFilter*, VFA_MAX_FACES> m_scoreFilter;
386  std::array<std::deque<std::array<float, VFA_EMOTIONS_COUNT>>, VFA_MAX_FACES> m_emotionFilter;
387 
388  void estimateAgeAndGender(const VsImage* frame, const FaceData &facedata, const int options, AnalysisData& results);
389  void estimateEmotion(const VsImage* frame, const FaceData &facedata, AnalysisData& results);
390 
391  std::array<float, VFA_EMOTIONS_COUNT> getAverageEmotions(const int faceIndex);
392 
393  const int EMOTION_WINDOW = 500; //ms
394 };
395 }
396 
397 #endif //_FACEANALYSER_H
VisageFaceAnalyser contains face analysis algorithms capable of estimating age, gender and emotion fr...
the FaceData has not been initialized by a previous tracking or detection operation ...
Analysis data structure, used as a container for all face analysis results.
enable age estimation or check whether age data files have been properly initialized ...
the license may be missing, invalid file name passed, expired or another related error ...
enable emotion estimation or check whether emotion data files have been properly initialized ...
Emotion index 1.
VisageFaceAnalyser was not properly initialized by a call to Init() method, or required data files we...
the function has executed successfully
Emotion index 3.
the image pointer or the related data may be null
Emotion index 6.
enable gender estimation or check whether gender data files have been properly initialized ...
Namespace.
Definition: android_header.h:1
Emotion index 4.
VFAFlags
VFAFlags are used to describe whether age, gender and/or emotion data have been loaded succesfully or...
VFAEmotionIndices
VFAEmotionIndices enumeration facilitates easier access to a specific emotion, particularly when iter...
const VISAGE_DECLSPEC char * getVisageSDKVersion(void)
Returns visageSDK version and revision number.
Face data structure, used as container for all face tracking and detection results.
Definition: FaceData.h:259
VFAReturnCode
Enumeration describing potential outcomes of the VisageFaceAnalyser::analyseImage() and VisageFaceAna...
Emotion index 2.
Emotion index 0.
Emotion index 5.
Image store container.