3DiVi Face SDK  3.21.0
 Указатель Классы Пространства имен Файлы Функции Переменные Определения типов Перечисления Элементы перечислений Свойства Группы
EmotionsEstimator.h
См. документацию.
1 
13 #ifndef __PBIO_API__PBIO__EMOTIONS_ESTIMATOR_H_
14 #define __PBIO_API__PBIO__EMOTIONS_ESTIMATOR_H_
15 
16 #include <sstream>
17 #include <vector>
18 
19 
20 #include "ComplexObject.h"
21 #include "RawSample.h"
22 #include "SmartPtr.h"
23 #include "Error.h"
24 #include "stl_wraps_impls/WrapOStreamImpl.h"
25 
26 
27 namespace pbio
28 {
29 
30 class FacerecService;
31 
41 class EmotionsEstimator : public ComplexObject
42 {
43 public:
44 
50  typedef LightSmartPtr<EmotionsEstimator>::tPtr Ptr;
51 
57  enum Emotion
58  {
65 
72 
79 
86 
93 
100 
107  };
108 
115  {
122 
128  float confidence;
129  };
130 
142  typedef std::vector<EmotionConfidence> EstimatedEmotionsVector;
143 
170 
171 private:
172 
174  const DHPtr &dll_handle,
175  void* impl);
176 
177  friend class FacerecService;
178  friend class object_with_ref_counter<EmotionsEstimator>;
179 };
180 
181 } // pbio namespace
182 
183 
184 
188 
189 namespace pbio
190 {
191 
192 
193 inline
194 EmotionsEstimator::EmotionsEstimator(
195  const DHPtr &dll_handle,
196  void* impl):
197 ComplexObject(dll_handle, impl)
198 {
199  // nothing else
200 }
201 
202 
203 inline
204 std::vector<EmotionsEstimator::EmotionConfidence> EmotionsEstimator::estimateEmotions(
205  const pbio::RawSample &sample) const
206 {
207  void* exception = NULL;
208 
209  std::ostringstream data_oss;
210 
211  stl_wraps::WrapOStreamImpl data_oss_w(data_oss);
212 
213  const int count = _dll_handle->EmotionsEstimator_estimateEmotions(
214  _impl,
215  (pbio::facerec::RawSampleImpl const*) sample._impl,
216  &data_oss_w,
217  pbio::stl_wraps::WrapOStreamImpl::write_func,
218  &exception);
219 
220  checkException(exception, *_dll_handle);
221 
222  std::istringstream data_iss(data_oss.str());
223 
224  std::vector<EmotionConfidence> result(count);
225 
226  for(int i = 0; i < count; ++i)
227  {
228  int32_t emotion;
229  float confidence;
230 
231  data_iss.read((char*)&emotion, sizeof(emotion));
232  data_iss.read((char*)&confidence, sizeof(confidence));
233 
234  result[i].emotion = (Emotion) emotion;
235  result[i].confidence = confidence;
236  }
237 
238  return result;
239 }
240 
241 
242 
243 } // pbio namespace
244 
245 #endif // __PBIO_API__PBIO__EMOTIONS_ESTIMATOR_H_
Удивленный.
Definition: EmotionsEstimator.h:85
Интерфейсный объект для создания других интерфейсных объектов.
Definition: FacerecService.h:64
Интерфейсный объект, хранящий образец лица.
Definition: RawSample.h:49
LightSmartPtr< EmotionsEstimator >::tPtr Ptr
Псевдоним для типа умного указателя на EmotionsEstimator.
Definition: EmotionsEstimator.h:50
Нейтральный.
Definition: EmotionsEstimator.h:64
std::vector< EmotionConfidence > EstimatedEmotionsVector
Определенные эмоции с коэффициентами уверенности. В порядке уменьшения уверенности. Сумма всех коэффициентов равна 1.
Definition: EmotionsEstimator.h:142
Грустный.
Definition: EmotionsEstimator.h:106
Error - класс исключений, выбрасываемых при возникновении ошибок.
RawSample - Интерфейсный объект, хранящий образец лица.
Эмоция с коэффициентом уверенности.
Definition: EmotionsEstimator.h:114
float confidence
Положительное вещественное число из диапазона [0; 1].
Definition: EmotionsEstimator.h:128
Emotion emotion
Эмоция.
Definition: EmotionsEstimator.h:121
Счастливый.
Definition: EmotionsEstimator.h:71
Emotion
Эмоции.
Definition: EmotionsEstimator.h:57
Напуганный.
Definition: EmotionsEstimator.h:99
SmartPtr.
EstimatedEmotionsVector estimateEmotions(const pbio::RawSample &sample) const
Определить эмоцию поданного лица.
Definition: EmotionsEstimator.h:204
Злой.
Definition: EmotionsEstimator.h:78
Испытывающий отвращение.
Definition: EmotionsEstimator.h:92
Интерфейсный объект для определения эмоций.
Definition: EmotionsEstimator.h:41