visageSDK
FaceModel.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 #pragma once
17 
18 #include "SystemModel.h"
19 
20 // Define bit flags used or fitting
21 #define POSE_FITTING 0x1
22 #define SHAPE_FITTING 0x2
23 #define ACTION_FITTING 0x4
24 #define POSE_SHAPE_FITTING (POSE_FITTING | SHAPE_FITTING)
25 #define POSE_ACTION_FITTING (POSE_FITTING | ACTION_FITTING)
26 #define FULL_FITTING (POSE_FITTING | SHAPE_FITTING | ACTION_FITTING)
27 
28 // Points whose R value is bigger or equal to this value are not processed
29 // This define should be defined in FaceModel.h header not here.
30 #define LIMIT_R_VALUE 100000.0f
31 
32 namespace VisageSDK
33 {
34 
35 class FaceModel: public SystemModel
36 {
37 public:
38 
39  FaceModel()
40  {
41  isCreated = false;
42 
43  fitting_flags = 0;
44  su_offset = 0;
45  au_offset = 0;
46 
47  M = 0;
48  N = 0;
49 
50  bVertexCount = 0;
51 
52  Wb = 0;
53  WbVertexCount = 0;
54 
55  WA = 0;
56  a = 0;
57  a_use = 0;
58  nAU = 0;
59 
60  WS = 0;
61  s = 0;
62  s_use = 0;
63  nSU = 0;
64 
65  au_limits = 0;
66  su_limits = 0;
67 
68  f = 0;
69  scale = 0;
70 
71  diagQ = 0;
72  diagR = 0;
73 
74  Wbs = 0;
75  Wbsa = 0;
76  Wbsart = 0;
77 
78  }
79 
80  bool IsCreated()
81  {
82  return isCreated;
83  }
84 
85  virtual bool Create(unsigned int nAUs, unsigned int nSUs, unsigned int nVerts, unsigned int nFPs, float focal_len, float _scale, float *_au_limits, int _fitting_flags)=0;
86 
87  virtual void SetInitialState(float* r, float* t, VsMat* s, VsMat* a, VsMat* x)=0;
88  virtual void SetNoiseCovariance(VsMat* pose_sensitivity, VsMat* su_sensitivity, VsMat* au_sensitivity)=0;
89  virtual void ExtractData(float* r, float* t, VsMat* s, VsMat* a, VsMat* x)=0;
90 
91  // process
92  unsigned int GetNumberOfStates()
93  {
94  return M;
95  }
96 
97  // observation
98  unsigned int GetNumberOfObservations()
99  {
100  return N;
101  }
102 
103  //
104  virtual void Destroy()=0;
105 
106  virtual ~FaceModel() {}
107 
108 
109  // Bool flag which is set when FaceModel is crreated.
110  bool isCreated;
111 
112  // Flags used for fitting switch
113  int fitting_flags;
114  // Shape units coefficients offset
115  int su_offset;
116  // Action units coefficients offset
117  int au_offset;
118 
119  // Number of states
120  unsigned int M;
121  // Number of measurements
122  unsigned int N;
123 
124  // Total number of vertices in model
125  unsigned int bVertexCount;
126 
127  // Matrix containing feature point vertices
128  VsMat* Wb;
129  // Number of feature point vertices in model
130  unsigned int WbVertexCount;
131 
132  // Matrix containing action units for feature points vertices
133  VsMat* WA;
134  // Matrix containing action units coefficients
135  VsMat* a;
136  // Matrix containing information which action units are used
137  VsMat* a_use;
138  // Number of action units
139  unsigned int nAU;
140  // Matrix containing action units limits
141  VsMat* au_limits;
142 
143  // Matrix containing shape units for feature points vertices
144  VsMat* WS;
145  // Matrix containing shape units coefficients
146  VsMat* s;
147  // Matrix containing information which shape units are used
148  VsMat* s_use;
149  unsigned int nSU;
150  // Matrix containing shape units limits
151  VsMat* su_limits;
152 
153  // Camera focal length, used for model projection
154  float f;
155  // Model scale
156  float scale;
157 
158  // Process noise covariance matrix
159  VsMat* diagQ;
160  // Observation (measurement) noise covariance matrix
161  VsMat* diagR;
162 
163  // Feature points matrix with shape units applied
164  VsMat* Wbs;
165  // Feature points matrix with shape units and action units applied
166  VsMat* Wbsa;
167  // Feature points matrix with shape units, action units, rotation and translation applied
168  VsMat* Wbsart;
169 };
170 
171 }
Namespace.
Definition: win_header.h:1