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
56 enum VFAEmotionIndices {
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,
73 VFA_EMOTION = 4
74 };
75
78 enum class VFAReturnCode {
79 NoError,
80 InvalidFrame,
81 InvalidFaceData,
82 InvalidLicense,
83 DataUninitialized
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:
169 VisageFaceAnalyser();
172 ~VisageFaceAnalyser();
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
VisageSDK::VisageFaceAnalyser
VisageFaceAnalyser contains face analysis algorithms capable of estimating age, gender and emotion fr...
Definition: VisageFaceAnalyser.h:163
VisageSDK::VFAReturnCode::InvalidFaceData
the FaceData has not been initialized by a previous tracking or detection operation ...
VisageSDK::AnalysisData
Analysis data structure, used as a container for all face analysis results.
Definition: VisageFaceAnalyser.h:111
VisageSDK::VFA_AGE
enable age estimation or check whether age data files have been properly initialized ...
Definition: VisageFaceAnalyser.h:71
VisageSDK::VFAReturnCode::InvalidLicense
the license may be missing, invalid file name passed, expired or another related error ...
VisageSDK::VFA_EMOTION
enable emotion estimation or check whether emotion data files have been properly initialized ...
Definition: VisageFaceAnalyser.h:73
VNN
Definition: VisageFeaturesDetector.h:34
VisageSDK::Disgust
Emotion index 1.
Definition: VisageFaceAnalyser.h:58
VisageSDK::VFAReturnCode::DataUninitialized
VisageFaceAnalyser was not properly initialized by a call to Init() method, or required data files we...
VisageSDK::VFAReturnCode::NoError
the function has executed successfully
VisageSDK::Happiness
Emotion index 3.
Definition: VisageFaceAnalyser.h:60
VisageSDK::VFAReturnCode::InvalidFrame
the image pointer or the related data may be null
VisageSDK::Neutral
Emotion index 6.
Definition: VisageFaceAnalyser.h:63
VisageSDK::VFA_GENDER
enable gender estimation or check whether gender data files have been properly initialized ...
Definition: VisageFaceAnalyser.h:72
VisageSDK
Namespace.
Definition: linux_header.h:1
VisageSDK::Sadness
Emotion index 4.
Definition: VisageFaceAnalyser.h:61
VisageSDK::VFAFlags
VFAFlags
VFAFlags are used to describe whether age, gender and/or emotion data have been loaded succesfully or...
Definition: VisageFaceAnalyser.h:70
VisageSDK::VFAEmotionIndices
VFAEmotionIndices
VFAEmotionIndices enumeration facilitates easier access to a specific emotion, particularly when iter...
Definition: VisageFaceAnalyser.h:56
VisageSDK::getVisageSDKVersion
const VISAGE_DECLSPEC char * getVisageSDKVersion(void)
Returns visageSDK version and revision number.
VisageSDK::FaceData
Face data structure, used as container for all face tracking and detection results.
Definition: FaceData.h:259
VisageSDK::VFAReturnCode
VFAReturnCode
Enumeration describing potential outcomes of the VisageFaceAnalyser::analyseImage() and VisageFaceAna...
Definition: VisageFaceAnalyser.h:78
VisageSDK::Fear
Emotion index 2.
Definition: VisageFaceAnalyser.h:59
VisageSDK::Anger
Emotion index 0.
Definition: VisageFaceAnalyser.h:57
VisageSDK::Surprise
Emotion index 5.
Definition: VisageFaceAnalyser.h:62
VsImage
Image store container.
Definition: vs_core_types_c.h:460