Fawkes API Fawkes Development Version
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
31namespace fawkes {
32
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. */,
49 OPMODE_GENDER /**< Facer will detect faces and try to identify the gender of the faces */
51 const char * tostring_if_facer_opmode_t(if_facer_opmode_t value) const;
52
53 private:
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 char most_likely_gender[64]; /**<
80 The gender that was recogniced.
81 */
82 float history_ratio; /**<
83 The ratio of the most likely identity showing up in the history
84 and the length of the history.
85 */
86 float sec_since_detection; /**<
87 Time in seconds since the last successful detection.
88 */
89 int32_t visibility_history; /**<
90 The number of consecutive sighting ( <= 1 ) and non-sightings
91 ( >= -1 ), respectively.
92 */
93 bool learning_in_progress; /**<
94 Indicates whether a new identity is currently learnt. If
95 learning is in progress only "old" faces can be recognized.
96 */
97 bool searching_person; /**<
98 Indicates whether the plugin is searching for a specified person.
99 If set to true, the index and name will be listed in the fields
100 "requested_index" and "requested_name".
101 */
102 float recording_progress; /**<
103 Indicates the progress of recording images of a new face.
104 */
105 float bearing; /**<
106 The relative bearing to the recognized face in radians.
107 */
108 float slope; /**<
109 The relative slope to the recognized face in radians.
110 */
111 uint32_t requested_index; /**<
112 Index of the identity for which the name was requested.
113 */
114 char requested_name[64]; /**<
115 Requested name.
116 */
117 uint32_t index_last_learned; /**<
118 Index of the identity which was learned last.
119 */
120 } FacerInterface_data_t;
121
122 FacerInterface_data_t *data;
123
124 interface_enum_map_t enum_map_if_facer_opmode_t;
125 public:
126 /* messages */
128 {
129 private:
130 /** Internal data storage, do NOT modify! */
131 typedef struct {
132 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
133 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
134 char name[64]; /**< The name assigned to the new identity. */
135 } LearnFaceMessage_data_t;
136
137 LearnFaceMessage_data_t *data;
138
139 interface_enum_map_t enum_map_if_facer_opmode_t;
140 public:
141 LearnFaceMessage(const char * ini_name);
144
145 explicit LearnFaceMessage(const LearnFaceMessage *m);
146 /* Methods */
147 char * name() const;
148 void set_name(const char * new_name);
149 size_t maxlenof_name() const;
150 virtual Message * clone() const;
151 };
152
154 {
155 private:
156 /** Internal data storage, do NOT modify! */
157 typedef struct {
158 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
159 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
160 int32_t opmode; /**<
161 Current opmode.
162 */
163 } SetOpmodeMessage_data_t;
164
165 SetOpmodeMessage_data_t *data;
166
167 interface_enum_map_t enum_map_if_facer_opmode_t;
168 public:
169 SetOpmodeMessage(const if_facer_opmode_t ini_opmode);
172
173 explicit SetOpmodeMessage(const SetOpmodeMessage *m);
174 /* Methods */
176 void set_opmode(const if_facer_opmode_t new_opmode);
177 size_t maxlenof_opmode() const;
178 virtual Message * clone() const;
179 };
180
182 {
183 private:
184 /** Internal data storage, do NOT modify! */
185 typedef struct {
186 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
187 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
188 uint32_t index; /**< Index of the identity. */
189 bool enable; /**< En-/disable flag. */
190 } EnableIdentityMessage_data_t;
191
192 EnableIdentityMessage_data_t *data;
193
194 interface_enum_map_t enum_map_if_facer_opmode_t;
195 public:
196 EnableIdentityMessage(const uint32_t ini_index, const bool ini_enable);
199
201 /* Methods */
202 uint32_t index() const;
203 void set_index(const uint32_t new_index);
204 size_t maxlenof_index() const;
205 bool is_enable() const;
206 void set_enable(const bool new_enable);
207 size_t maxlenof_enable() const;
208 virtual Message * clone() const;
209 };
210
211 class SetNameMessage : public Message
212 {
213 private:
214 /** Internal data storage, do NOT modify! */
215 typedef struct {
216 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
217 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
218 uint32_t index; /**< Index of the identity. */
219 char name[64]; /**< Name of the identity. */
220 } SetNameMessage_data_t;
221
222 SetNameMessage_data_t *data;
223
224 interface_enum_map_t enum_map_if_facer_opmode_t;
225 public:
226 SetNameMessage(const uint32_t ini_index, const char * ini_name);
229
230 explicit SetNameMessage(const SetNameMessage *m);
231 /* Methods */
232 uint32_t index() const;
233 void set_index(const uint32_t new_index);
234 size_t maxlenof_index() const;
235 char * name() const;
236 void set_name(const char * new_name);
237 size_t maxlenof_name() const;
238 virtual Message * clone() const;
239 };
240
241 class GetNameMessage : public Message
242 {
243 private:
244 /** Internal data storage, do NOT modify! */
245 typedef struct {
246 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
247 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
248 uint32_t index; /**< Index of the identity. */
249 } GetNameMessage_data_t;
250
251 GetNameMessage_data_t *data;
252
253 interface_enum_map_t enum_map_if_facer_opmode_t;
254 public:
255 GetNameMessage(const uint32_t ini_index);
258
259 explicit GetNameMessage(const GetNameMessage *m);
260 /* Methods */
261 uint32_t index() const;
262 void set_index(const uint32_t new_index);
263 size_t maxlenof_index() const;
264 virtual Message * clone() const;
265 };
266
268 {
269 private:
270 /** Internal data storage, do NOT modify! */
271 typedef struct {
272 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
273 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
274 uint32_t index; /**< Index of the identity. */
275 } StartSearchPersonMessage_data_t;
276
277 StartSearchPersonMessage_data_t *data;
278
279 interface_enum_map_t enum_map_if_facer_opmode_t;
280 public:
281 StartSearchPersonMessage(const uint32_t ini_index);
284
286 /* Methods */
287 uint32_t index() const;
288 void set_index(const uint32_t new_index);
289 size_t maxlenof_index() const;
290 virtual Message * clone() const;
291 };
292
294 {
295 private:
296 /** Internal data storage, do NOT modify! */
297 typedef struct {
298 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
299 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
300 } StopSearchPersonMessage_data_t;
301
302 StopSearchPersonMessage_data_t *data;
303
304 interface_enum_map_t enum_map_if_facer_opmode_t;
305 public:
308
310 /* Methods */
311 virtual Message * clone() const;
312 };
313
314 virtual bool message_valid(const Message *message) const;
315 private:
318
319 public:
320 /* Methods */
322 void set_opmode(const if_facer_opmode_t new_opmode);
323 size_t maxlenof_opmode() const;
324 uint32_t num_identities() const;
325 void set_num_identities(const uint32_t new_num_identities);
326 size_t maxlenof_num_identities() const;
327 uint32_t recognized_identity() const;
328 void set_recognized_identity(const uint32_t new_recognized_identity);
329 size_t maxlenof_recognized_identity() const;
330 char * recognized_name() const;
331 void set_recognized_name(const char * new_recognized_name);
332 size_t maxlenof_recognized_name() const;
333 uint32_t num_detections() const;
334 void set_num_detections(const uint32_t new_num_detections);
335 size_t maxlenof_num_detections() const;
336 uint32_t num_recognitions() const;
337 void set_num_recognitions(const uint32_t new_num_recognitions);
338 size_t maxlenof_num_recognitions() const;
339 uint32_t most_likely_identity() const;
340 void set_most_likely_identity(const uint32_t new_most_likely_identity);
341 size_t maxlenof_most_likely_identity() const;
342 char * most_likely_gender() const;
343 void set_most_likely_gender(const char * new_most_likely_gender);
344 size_t maxlenof_most_likely_gender() const;
345 float history_ratio() const;
346 void set_history_ratio(const float new_history_ratio);
347 size_t maxlenof_history_ratio() const;
348 float sec_since_detection() const;
349 void set_sec_since_detection(const float new_sec_since_detection);
350 size_t maxlenof_sec_since_detection() const;
351 int32_t visibility_history() const;
352 void set_visibility_history(const int32_t new_visibility_history);
353 size_t maxlenof_visibility_history() const;
354 bool is_learning_in_progress() const;
355 void set_learning_in_progress(const bool new_learning_in_progress);
356 size_t maxlenof_learning_in_progress() const;
357 bool is_searching_person() const;
358 void set_searching_person(const bool new_searching_person);
359 size_t maxlenof_searching_person() const;
360 float recording_progress() const;
361 void set_recording_progress(const float new_recording_progress);
362 size_t maxlenof_recording_progress() const;
363 float bearing() const;
364 void set_bearing(const float new_bearing);
365 size_t maxlenof_bearing() const;
366 float slope() const;
367 void set_slope(const float new_slope);
368 size_t maxlenof_slope() const;
369 uint32_t requested_index() const;
370 void set_requested_index(const uint32_t new_requested_index);
371 size_t maxlenof_requested_index() const;
372 char * requested_name() const;
373 void set_requested_name(const char * new_requested_name);
374 size_t maxlenof_requested_name() const;
375 uint32_t index_last_learned() const;
376 void set_index_last_learned(const uint32_t new_index_last_learned);
377 size_t maxlenof_index_last_learned() const;
378 virtual Message * create_message(const char *type) const;
379
380 virtual void copy_values(const Interface *other);
381 virtual const char * enum_tostring(const char *enumtype, int val) const;
382
383};
384
385} // end namespace fawkes
386
387#endif
EnableIdentityMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
size_t maxlenof_index() const
Get maximum length of index value.
void set_index(const uint32_t new_index)
Set index value.
void set_enable(const bool new_enable)
Set enable value.
uint32_t index() const
Get index value.
size_t maxlenof_enable() const
Get maximum length of enable value.
GetNameMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
void set_index(const uint32_t new_index)
Set index value.
size_t maxlenof_index() const
Get maximum length of index value.
uint32_t index() const
Get index value.
LearnFaceMessage Fawkes BlackBoard Interface Message.
void set_name(const char *new_name)
Set name value.
virtual Message * clone() const
Clone this message.
char * name() const
Get name value.
size_t maxlenof_name() const
Get maximum length of name value.
SetNameMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
uint32_t index() const
Get index value.
size_t maxlenof_index() const
Get maximum length of index value.
char * name() const
Get name value.
size_t maxlenof_name() const
Get maximum length of name value.
void set_name(const char *new_name)
Set name value.
void set_index(const uint32_t new_index)
Set index value.
SetOpmodeMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_opmode() const
Get maximum length of opmode value.
void set_opmode(const if_facer_opmode_t new_opmode)
Set opmode value.
if_facer_opmode_t opmode() const
Get opmode value.
virtual Message * clone() const
Clone this message.
StartSearchPersonMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
void set_index(const uint32_t new_index)
Set index value.
size_t maxlenof_index() const
Get maximum length of index value.
StopSearchPersonMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
FacerInterface Fawkes BlackBoard Interface.
void set_learning_in_progress(const bool new_learning_in_progress)
Set learning_in_progress value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
uint32_t requested_index() const
Get requested_index value.
virtual void copy_values(const Interface *other)
Copy values from other interface.
size_t maxlenof_num_recognitions() const
Get maximum length of num_recognitions value.
void set_num_detections(const uint32_t new_num_detections)
Set num_detections value.
bool is_searching_person() const
Get searching_person value.
char * most_likely_gender() const
Get most_likely_gender value.
char * requested_name() const
Get requested_name value.
size_t maxlenof_opmode() const
Get maximum length of opmode value.
void set_recognized_identity(const uint32_t new_recognized_identity)
Set recognized_identity value.
size_t maxlenof_learning_in_progress() const
Get maximum length of learning_in_progress value.
char * recognized_name() const
Get recognized_name value.
void set_recognized_name(const char *new_recognized_name)
Set recognized_name value.
void set_opmode(const if_facer_opmode_t new_opmode)
Set opmode value.
void set_sec_since_detection(const float new_sec_since_detection)
Set sec_since_detection value.
void set_history_ratio(const float new_history_ratio)
Set history_ratio value.
bool is_learning_in_progress() const
Get learning_in_progress value.
void set_most_likely_gender(const char *new_most_likely_gender)
Set most_likely_gender value.
uint32_t index_last_learned() const
Get index_last_learned value.
uint32_t num_identities() const
Get num_identities value.
size_t maxlenof_recording_progress() const
Get maximum length of recording_progress value.
uint32_t num_detections() const
Get num_detections value.
int32_t visibility_history() const
Get visibility_history value.
size_t maxlenof_slope() const
Get maximum length of slope value.
if_facer_opmode_t
This determines the current status of skill execution.
@ OPMODE_GENDER
Facer will detect faces and try to identify the gender of the faces.
@ OPMODE_DETECTION
Facer will detect faces, but not try to recognize them.
@ OPMODE_RECOGNITION
Facer will detect faces, and then try to recognize the most dominant face.
@ OPMODE_DISABLED
Facer will not process any images.
@ OPMODE_LEARNING
Facer will gather images and learn an identity.
float bearing() const
Get bearing value.
void set_visibility_history(const int32_t new_visibility_history)
Set visibility_history value.
size_t maxlenof_sec_since_detection() const
Get maximum length of sec_since_detection value.
float sec_since_detection() const
Get sec_since_detection value.
void set_num_recognitions(const uint32_t new_num_recognitions)
Set num_recognitions value.
float history_ratio() const
Get history_ratio value.
size_t maxlenof_history_ratio() const
Get maximum length of history_ratio value.
void set_recording_progress(const float new_recording_progress)
Set recording_progress value.
uint32_t num_recognitions() const
Get num_recognitions value.
size_t maxlenof_num_detections() const
Get maximum length of num_detections value.
uint32_t most_likely_identity() const
Get most_likely_identity value.
if_facer_opmode_t opmode() const
Get opmode value.
void set_bearing(const float new_bearing)
Set bearing value.
size_t maxlenof_most_likely_gender() const
Get maximum length of most_likely_gender value.
size_t maxlenof_recognized_identity() const
Get maximum length of recognized_identity value.
size_t maxlenof_recognized_name() const
Get maximum length of recognized_name value.
void set_requested_index(const uint32_t new_requested_index)
Set requested_index value.
size_t maxlenof_num_identities() const
Get maximum length of num_identities value.
virtual Message * create_message(const char *type) const
Create message based on type name.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
void set_most_likely_identity(const uint32_t new_most_likely_identity)
Set most_likely_identity value.
void set_index_last_learned(const uint32_t new_index_last_learned)
Set index_last_learned value.
void set_searching_person(const bool new_searching_person)
Set searching_person value.
void set_num_identities(const uint32_t new_num_identities)
Set num_identities value.
float recording_progress() const
Get recording_progress value.
size_t maxlenof_index_last_learned() const
Get maximum length of index_last_learned value.
size_t maxlenof_requested_name() const
Get maximum length of requested_name value.
size_t maxlenof_searching_person() const
Get maximum length of searching_person value.
size_t maxlenof_most_likely_identity() const
Get maximum length of most_likely_identity value.
size_t maxlenof_requested_index() const
Get maximum length of requested_index value.
float slope() const
Get slope value.
void set_slope(const float new_slope)
Set slope value.
const char * tostring_if_facer_opmode_t(if_facer_opmode_t value) const
Convert if_facer_opmode_t constant to string.
uint32_t recognized_identity() const
Get recognized_identity value.
size_t maxlenof_visibility_history() const
Get maximum length of visibility_history value.
size_t maxlenof_bearing() const
Get maximum length of bearing value.
void set_requested_name(const char *new_requested_name)
Set requested_name value.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
const char * type() const
Get type of interface.
Definition: interface.cpp:652
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
Fawkes library namespace.
std::map< int, std::string > interface_enum_map_t
Map of enum integer to string values.
Definition: types.h:54