Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
FacerInterface.h
1 
2 /***************************************************************************
3  * FacerInterface.h - Fawkes BlackBoard Interface - FacerInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2008 Tim Niemueller
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __INTERFACES_FACERINTERFACE_H_
25 #define __INTERFACES_FACERINTERFACE_H_
26 
27 #include <interface/interface.h>
28 #include <interface/message.h>
29 #include <interface/field_iterator.h>
30 
31 namespace fawkes {
32 
33 class FacerInterface : public Interface
34 {
35  /// @cond INTERNALS
36  INTERFACE_MGMT_FRIENDS(FacerInterface)
37  /// @endcond
38  public:
39  /* constants */
40 
41  /**
42  This determines the current status of skill execution.
43  */
44  typedef enum {
45  OPMODE_DISABLED /**< Facer will not process any images */,
46  OPMODE_DETECTION /**< Facer will detect faces, but not try to recognize them. */,
47  OPMODE_RECOGNITION /**< Facer will detect faces, and then try to recognize the most dominant face. */,
48  OPMODE_LEARNING /**< Facer will gather images and learn an identity. */
50  const char * tostring_if_facer_opmode_t(if_facer_opmode_t value) const;
51 
52  private:
53 #pragma pack(push,4)
54  /** Internal data storage, do NOT modify! */
55  typedef struct {
56  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
57  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
58  int32_t opmode; /**<
59  Current opmode.
60  */
61  uint32_t num_identities; /**<
62  The number of identities in the database.
63  */
64  uint32_t recognized_identity; /**<
65  The index of the recognized identity.
66  */
67  char recognized_name[64]; /**<
68  The name of the recognized identity.
69  */
70  uint32_t num_detections; /**<
71  Number of currently detected faces.
72  */
73  uint32_t num_recognitions; /**<
74  Number of recognized faces.
75  */
76  uint32_t most_likely_identity; /**<
77  The identity that was recognized most prevalently.
78  */
79  float history_ratio; /**<
80  The ratio of the most likely identity showing up in the history
81  and the length of the history.
82  */
83  float sec_since_detection; /**<
84  Time in seconds since the last successful detection.
85  */
86  int32_t visibility_history; /**<
87  The number of consecutive sighting ( <= 1 ) and non-sightings
88  ( >= -1 ), respectively.
89  */
90  bool learning_in_progress; /**<
91  Indicates whether a new identity is currently learnt. If
92  learning is in progress only "old" faces can be recognized.
93  */
94  float recording_progress; /**<
95  Indicates the progress of recording images of a new face.
96  */
97  float bearing; /**<
98  The relative bearing to the recognized face in radians.
99  */
100  float slope; /**<
101  The relative slope to the recognized face in radians.
102  */
103  uint32_t requested_index; /**<
104  Index of the identity for which the name was requested.
105  */
106  char requested_name[64]; /**<
107  Requested name.
108  */
109  } FacerInterface_data_t;
110 #pragma pack(pop)
111 
112  FacerInterface_data_t *data;
113 
114  public:
115  /* messages */
116  class LearnFaceMessage : public Message
117  {
118  private:
119 #pragma pack(push,4)
120  /** Internal data storage, do NOT modify! */
121  typedef struct {
122  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
123  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
124  char name[64]; /**< The name assigned to the new identity. */
125  } LearnFaceMessage_data_t;
126 #pragma pack(pop)
127 
128  LearnFaceMessage_data_t *data;
129 
130  public:
131  LearnFaceMessage(const char * ini_name);
134 
136  /* Methods */
137  char * name() const;
138  void set_name(const char * new_name);
139  size_t maxlenof_name() const;
140  virtual Message * clone() const;
141  };
142 
143  class SetOpmodeMessage : public Message
144  {
145  private:
146 #pragma pack(push,4)
147  /** Internal data storage, do NOT modify! */
148  typedef struct {
149  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
150  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
151  int32_t opmode; /**<
152  Current opmode.
153  */
154  } SetOpmodeMessage_data_t;
155 #pragma pack(pop)
156 
157  SetOpmodeMessage_data_t *data;
158 
159  public:
160  SetOpmodeMessage(const if_facer_opmode_t ini_opmode);
163 
165  /* Methods */
166  if_facer_opmode_t opmode() const;
167  void set_opmode(const if_facer_opmode_t new_opmode);
168  size_t maxlenof_opmode() const;
169  virtual Message * clone() const;
170  };
171 
173  {
174  private:
175 #pragma pack(push,4)
176  /** Internal data storage, do NOT modify! */
177  typedef struct {
178  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
179  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
180  uint32_t index; /**< Index of the identity. */
181  bool enable; /**< En-/disable flag. */
182  } EnableIdentityMessage_data_t;
183 #pragma pack(pop)
184 
185  EnableIdentityMessage_data_t *data;
186 
187  public:
188  EnableIdentityMessage(const uint32_t ini_index, const bool ini_enable);
191 
193  /* Methods */
194  uint32_t index() const;
195  void set_index(const uint32_t new_index);
196  size_t maxlenof_index() const;
197  bool is_enable() const;
198  void set_enable(const bool new_enable);
199  size_t maxlenof_enable() const;
200  virtual Message * clone() const;
201  };
202 
203  class SetNameMessage : public Message
204  {
205  private:
206 #pragma pack(push,4)
207  /** Internal data storage, do NOT modify! */
208  typedef struct {
209  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
210  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
211  uint32_t index; /**< Index of the identity. */
212  char name[64]; /**< Name of the identity. */
213  } SetNameMessage_data_t;
214 #pragma pack(pop)
215 
216  SetNameMessage_data_t *data;
217 
218  public:
219  SetNameMessage(const uint32_t ini_index, const char * ini_name);
220  SetNameMessage();
221  ~SetNameMessage();
222 
223  SetNameMessage(const SetNameMessage *m);
224  /* Methods */
225  uint32_t index() const;
226  void set_index(const uint32_t new_index);
227  size_t maxlenof_index() const;
228  char * name() const;
229  void set_name(const char * new_name);
230  size_t maxlenof_name() const;
231  virtual Message * clone() const;
232  };
233 
234  class GetNameMessage : public Message
235  {
236  private:
237 #pragma pack(push,4)
238  /** Internal data storage, do NOT modify! */
239  typedef struct {
240  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
241  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
242  uint32_t index; /**< Index of the identity. */
243  } GetNameMessage_data_t;
244 #pragma pack(pop)
245 
246  GetNameMessage_data_t *data;
247 
248  public:
249  GetNameMessage(const uint32_t ini_index);
250  GetNameMessage();
251  ~GetNameMessage();
252 
253  GetNameMessage(const GetNameMessage *m);
254  /* Methods */
255  uint32_t index() const;
256  void set_index(const uint32_t new_index);
257  size_t maxlenof_index() const;
258  virtual Message * clone() const;
259  };
260 
261  virtual bool message_valid(const Message *message) const;
262  private:
263  FacerInterface();
264  ~FacerInterface();
265 
266  public:
267  /* Methods */
268  if_facer_opmode_t opmode() const;
269  void set_opmode(const if_facer_opmode_t new_opmode);
270  size_t maxlenof_opmode() const;
271  uint32_t num_identities() const;
272  void set_num_identities(const uint32_t new_num_identities);
273  size_t maxlenof_num_identities() const;
274  uint32_t recognized_identity() const;
275  void set_recognized_identity(const uint32_t new_recognized_identity);
276  size_t maxlenof_recognized_identity() const;
277  char * recognized_name() const;
278  void set_recognized_name(const char * new_recognized_name);
279  size_t maxlenof_recognized_name() const;
280  uint32_t num_detections() const;
281  void set_num_detections(const uint32_t new_num_detections);
282  size_t maxlenof_num_detections() const;
283  uint32_t num_recognitions() const;
284  void set_num_recognitions(const uint32_t new_num_recognitions);
285  size_t maxlenof_num_recognitions() const;
286  uint32_t most_likely_identity() const;
287  void set_most_likely_identity(const uint32_t new_most_likely_identity);
288  size_t maxlenof_most_likely_identity() const;
289  float history_ratio() const;
290  void set_history_ratio(const float new_history_ratio);
291  size_t maxlenof_history_ratio() const;
292  float sec_since_detection() const;
293  void set_sec_since_detection(const float new_sec_since_detection);
294  size_t maxlenof_sec_since_detection() const;
295  int32_t visibility_history() const;
296  void set_visibility_history(const int32_t new_visibility_history);
297  size_t maxlenof_visibility_history() const;
298  bool is_learning_in_progress() const;
299  void set_learning_in_progress(const bool new_learning_in_progress);
300  size_t maxlenof_learning_in_progress() const;
301  float recording_progress() const;
302  void set_recording_progress(const float new_recording_progress);
303  size_t maxlenof_recording_progress() const;
304  float bearing() const;
305  void set_bearing(const float new_bearing);
306  size_t maxlenof_bearing() const;
307  float slope() const;
308  void set_slope(const float new_slope);
309  size_t maxlenof_slope() const;
310  uint32_t requested_index() const;
311  void set_requested_index(const uint32_t new_requested_index);
312  size_t maxlenof_requested_index() const;
313  char * requested_name() const;
314  void set_requested_name(const char * new_requested_name);
315  size_t maxlenof_requested_name() const;
316  virtual Message * create_message(const char *type) const;
317 
318  virtual void copy_values(const Interface *other);
319  virtual const char * enum_tostring(const char *enumtype, int val) const;
320 
321 };
322 
323 } // end namespace fawkes
324 
325 #endif
uint32_t recognized_identity() const
Get recognized_identity value.
size_t maxlenof_slope() const
Get maximum length of slope value.
size_t maxlenof_index() const
Get maximum length of index value.
bool is_learning_in_progress() const
Get learning_in_progress value.
uint32_t index() const
Get index value.
float sec_since_detection() const
Get sec_since_detection value.
uint32_t num_recognitions() const
Get num_recognitions value.
char * recognized_name() const
Get recognized_name value.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:43
void set_most_likely_identity(const uint32_t new_most_likely_identity)
Set most_likely_identity value.
size_t maxlenof_requested_name() const
Get maximum length of requested_name value.
size_t maxlenof_name() const
Get maximum length of name value.
if_facer_opmode_t opmode() const
Get opmode value.
size_t maxlenof_name() const
Get maximum length of name value.
size_t maxlenof_enable() const
Get maximum length of enable value.
void set_enable(const bool new_enable)
Set enable value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
SetOpmodeMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_recording_progress() const
Get maximum length of recording_progress value.
size_t maxlenof_sec_since_detection() const
Get maximum length of sec_since_detection value.
SetNameMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_most_likely_identity() const
Get maximum length of most_likely_identity value.
char * requested_name() const
Get requested_name value.
float slope() const
Get slope value.
if_facer_opmode_t opmode() const
Get opmode value.
size_t maxlenof_index() const
Get maximum length of index value.
size_t maxlenof_recognized_name() const
Get maximum length of recognized_name value.
void set_index(const uint32_t new_index)
Set index value.
virtual void copy_values(const Interface *other)
Copy values from other interface.
Facer will detect faces, and then try to recognize the most dominant face.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
size_t maxlenof_learning_in_progress() const
Get maximum length of learning_in_progress value.
size_t maxlenof_opmode() const
Get maximum length of opmode value.
void set_num_identities(const uint32_t new_num_identities)
Set num_identities value.
float recording_progress() const
Get recording_progress value.
uint32_t index() const
Get index value.
GetNameMessage Fawkes BlackBoard Interface Message.
void set_sec_since_detection(const float new_sec_since_detection)
Set sec_since_detection value.
void set_slope(const float new_slope)
Set slope value.
size_t maxlenof_bearing() const
Get maximum length of bearing value.
void set_recognized_identity(const uint32_t new_recognized_identity)
Set recognized_identity value.
size_t maxlenof_visibility_history() const
Get maximum length of visibility_history value.
void set_visibility_history(const int32_t new_visibility_history)
Set visibility_history value.
Facer will detect faces, but not try to recognize them.
size_t maxlenof_requested_index() const
Get maximum length of requested_index value.
float history_ratio() const
Get history_ratio value.
uint32_t most_likely_identity() const
Get most_likely_identity value.
char * name() const
Get name value.
const char * tostring_if_facer_opmode_t(if_facer_opmode_t value) const
Convert if_facer_opmode_t constant to string.
void set_name(const char *new_name)
Set name value.
size_t maxlenof_num_detections() const
Get maximum length of num_detections value.
float bearing() const
Get bearing value.
bool is_enable() const
Get enable value.
virtual Message * clone() const
Clone this message.
virtual Message * clone() const
Clone this message.
void set_opmode(const if_facer_opmode_t new_opmode)
Set opmode value.
virtual Message * clone() const
Clone this message.
uint32_t num_detections() const
Get num_detections value.
void set_num_detections(const uint32_t new_num_detections)
Set num_detections value.
uint32_t requested_index() const
Get requested_index value.
virtual Message * clone() const
Clone this message.
virtual Message * create_message(const char *type) const
Create message based on type name.
size_t maxlenof_recognized_identity() const
Get maximum length of recognized_identity value.
Facer will not process any images.
LearnFaceMessage Fawkes BlackBoard Interface Message.
void set_requested_name(const char *new_requested_name)
Set requested_name value.
size_t maxlenof_opmode() const
Get maximum length of opmode value.
size_t maxlenof_history_ratio() const
Get maximum length of history_ratio value.
size_t maxlenof_index() const
Get maximum length of index value.
void set_requested_index(const uint32_t new_requested_index)
Set requested_index value.
virtual Message * clone() const
Clone this message.
void set_opmode(const if_facer_opmode_t new_opmode)
Set opmode value.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
void set_bearing(const float new_bearing)
Set bearing value.
size_t maxlenof_num_identities() const
Get maximum length of num_identities value.
Facer will gather images and learn an identity.
int32_t visibility_history() const
Get visibility_history value.
void set_num_recognitions(const uint32_t new_num_recognitions)
Set num_recognitions value.
FacerInterface Fawkes BlackBoard Interface.
void set_learning_in_progress(const bool new_learning_in_progress)
Set learning_in_progress value.
void set_recording_progress(const float new_recording_progress)
Set recording_progress value.
uint32_t num_identities() const
Get num_identities value.
uint32_t index() const
Get index value.
void set_history_ratio(const float new_history_ratio)
Set history_ratio value.
EnableIdentityMessage Fawkes BlackBoard Interface Message.
const char * type() const
Get type of interface.
Definition: interface.cpp:635
void set_index(const uint32_t new_index)
Set index value.
char * name() const
Get name value.
if_facer_opmode_t
This determines the current status of skill execution.
size_t maxlenof_num_recognitions() const
Get maximum length of num_recognitions value.
void set_index(const uint32_t new_index)
Set index value.
void set_name(const char *new_name)
Set name value.
void set_recognized_name(const char *new_recognized_name)
Set recognized_name value.