24#include <interfaces/FacerInterface.h>
26#include <core/exceptions/software.h>
50FacerInterface::FacerInterface() : Interface()
52 data_size =
sizeof(FacerInterface_data_t);
53 data_ptr = malloc(data_size);
54 data = (FacerInterface_data_t *)data_ptr;
55 data_ts = (interface_data_ts_t *)data_ptr;
56 memset(data_ptr, 0, data_size);
57 enum_map_if_facer_opmode_t[(int)OPMODE_DISABLED] =
"OPMODE_DISABLED";
58 enum_map_if_facer_opmode_t[(int)OPMODE_DETECTION] =
"OPMODE_DETECTION";
59 enum_map_if_facer_opmode_t[(int)OPMODE_RECOGNITION] =
"OPMODE_RECOGNITION";
60 enum_map_if_facer_opmode_t[(int)OPMODE_LEARNING] =
"OPMODE_LEARNING";
61 enum_map_if_facer_opmode_t[(int)OPMODE_GENDER] =
"OPMODE_GENDER";
62 add_fieldinfo(IFT_ENUM,
"opmode", 1, &data->opmode,
"if_facer_opmode_t", &enum_map_if_facer_opmode_t);
63 add_fieldinfo(IFT_UINT32,
"num_identities", 1, &data->num_identities);
64 add_fieldinfo(IFT_UINT32,
"recognized_identity", 1, &data->recognized_identity);
65 add_fieldinfo(IFT_STRING,
"recognized_name", 64, data->recognized_name);
66 add_fieldinfo(IFT_UINT32,
"num_detections", 1, &data->num_detections);
67 add_fieldinfo(IFT_UINT32,
"num_recognitions", 1, &data->num_recognitions);
68 add_fieldinfo(IFT_UINT32,
"most_likely_identity", 1, &data->most_likely_identity);
69 add_fieldinfo(IFT_STRING,
"most_likely_gender", 64, data->most_likely_gender);
70 add_fieldinfo(IFT_FLOAT,
"history_ratio", 1, &data->history_ratio);
71 add_fieldinfo(IFT_FLOAT,
"sec_since_detection", 1, &data->sec_since_detection);
72 add_fieldinfo(IFT_INT32,
"visibility_history", 1, &data->visibility_history);
73 add_fieldinfo(IFT_BOOL,
"learning_in_progress", 1, &data->learning_in_progress);
74 add_fieldinfo(IFT_BOOL,
"searching_person", 1, &data->searching_person);
75 add_fieldinfo(IFT_FLOAT,
"recording_progress", 1, &data->recording_progress);
76 add_fieldinfo(IFT_FLOAT,
"bearing", 1, &data->bearing);
77 add_fieldinfo(IFT_FLOAT,
"slope", 1, &data->slope);
78 add_fieldinfo(IFT_UINT32,
"requested_index", 1, &data->requested_index);
79 add_fieldinfo(IFT_STRING,
"requested_name", 64, data->requested_name);
80 add_fieldinfo(IFT_UINT32,
"index_last_learned", 1, &data->index_last_learned);
81 add_messageinfo(
"LearnFaceMessage");
82 add_messageinfo(
"SetOpmodeMessage");
83 add_messageinfo(
"EnableIdentityMessage");
84 add_messageinfo(
"SetNameMessage");
85 add_messageinfo(
"GetNameMessage");
86 add_messageinfo(
"StartSearchPersonMessage");
87 add_messageinfo(
"StopSearchPersonMessage");
88 unsigned char tmp_hash[] = {0x5d, 0xd, 0xac, 0xa1, 0xe1, 0x23, 0x82, 0xc4, 0x22, 0xed, 0x8b, 0xa7, 0x3e, 0x1f, 0x2d, 0x7c};
93FacerInterface::~FacerInterface()
105 case OPMODE_DISABLED:
return "OPMODE_DISABLED";
106 case OPMODE_DETECTION:
return "OPMODE_DETECTION";
107 case OPMODE_RECOGNITION:
return "OPMODE_RECOGNITION";
108 case OPMODE_LEARNING:
return "OPMODE_LEARNING";
109 case OPMODE_GENDER:
return "OPMODE_GENDER";
110 default:
return "UNKNOWN";
121FacerInterface::opmode()
const
131FacerInterface::maxlenof_opmode()
const
145 set_field(data->opmode, new_opmode);
155FacerInterface::num_identities()
const
157 return data->num_identities;
165FacerInterface::maxlenof_num_identities()
const
177FacerInterface::set_num_identities(
const uint32_t new_num_identities)
179 set_field(data->num_identities, new_num_identities);
189FacerInterface::recognized_identity()
const
191 return data->recognized_identity;
199FacerInterface::maxlenof_recognized_identity()
const
211FacerInterface::set_recognized_identity(
const uint32_t new_recognized_identity)
213 set_field(data->recognized_identity, new_recognized_identity);
223FacerInterface::recognized_name()
const
225 return data->recognized_name;
233FacerInterface::maxlenof_recognized_name()
const
245FacerInterface::set_recognized_name(
const char * new_recognized_name)
247 set_field(data->recognized_name, new_recognized_name);
257FacerInterface::num_detections()
const
259 return data->num_detections;
267FacerInterface::maxlenof_num_detections()
const
279FacerInterface::set_num_detections(
const uint32_t new_num_detections)
281 set_field(data->num_detections, new_num_detections);
291FacerInterface::num_recognitions()
const
293 return data->num_recognitions;
301FacerInterface::maxlenof_num_recognitions()
const
313FacerInterface::set_num_recognitions(
const uint32_t new_num_recognitions)
315 set_field(data->num_recognitions, new_num_recognitions);
325FacerInterface::most_likely_identity()
const
327 return data->most_likely_identity;
335FacerInterface::maxlenof_most_likely_identity()
const
347FacerInterface::set_most_likely_identity(
const uint32_t new_most_likely_identity)
349 set_field(data->most_likely_identity, new_most_likely_identity);
359FacerInterface::most_likely_gender()
const
361 return data->most_likely_gender;
369FacerInterface::maxlenof_most_likely_gender()
const
381FacerInterface::set_most_likely_gender(
const char * new_most_likely_gender)
383 set_field(data->most_likely_gender, new_most_likely_gender);
394FacerInterface::history_ratio()
const
396 return data->history_ratio;
404FacerInterface::maxlenof_history_ratio()
const
417FacerInterface::set_history_ratio(
const float new_history_ratio)
419 set_field(data->history_ratio, new_history_ratio);
429FacerInterface::sec_since_detection()
const
431 return data->sec_since_detection;
439FacerInterface::maxlenof_sec_since_detection()
const
451FacerInterface::set_sec_since_detection(
const float new_sec_since_detection)
453 set_field(data->sec_since_detection, new_sec_since_detection);
464FacerInterface::visibility_history()
const
466 return data->visibility_history;
474FacerInterface::maxlenof_visibility_history()
const
487FacerInterface::set_visibility_history(
const int32_t new_visibility_history)
489 set_field(data->visibility_history, new_visibility_history);
500FacerInterface::is_learning_in_progress()
const
502 return data->learning_in_progress;
510FacerInterface::maxlenof_learning_in_progress()
const
523FacerInterface::set_learning_in_progress(
const bool new_learning_in_progress)
525 set_field(data->learning_in_progress, new_learning_in_progress);
537FacerInterface::is_searching_person()
const
539 return data->searching_person;
547FacerInterface::maxlenof_searching_person()
const
561FacerInterface::set_searching_person(
const bool new_searching_person)
563 set_field(data->searching_person, new_searching_person);
573FacerInterface::recording_progress()
const
575 return data->recording_progress;
583FacerInterface::maxlenof_recording_progress()
const
595FacerInterface::set_recording_progress(
const float new_recording_progress)
597 set_field(data->recording_progress, new_recording_progress);
607FacerInterface::bearing()
const
609 return data->bearing;
617FacerInterface::maxlenof_bearing()
const
629FacerInterface::set_bearing(
const float new_bearing)
631 set_field(data->bearing, new_bearing);
641FacerInterface::slope()
const
651FacerInterface::maxlenof_slope()
const
663FacerInterface::set_slope(
const float new_slope)
665 set_field(data->slope, new_slope);
675FacerInterface::requested_index()
const
677 return data->requested_index;
685FacerInterface::maxlenof_requested_index()
const
697FacerInterface::set_requested_index(
const uint32_t new_requested_index)
699 set_field(data->requested_index, new_requested_index);
709FacerInterface::requested_name()
const
711 return data->requested_name;
719FacerInterface::maxlenof_requested_name()
const
731FacerInterface::set_requested_name(
const char * new_requested_name)
733 set_field(data->requested_name, new_requested_name);
743FacerInterface::index_last_learned()
const
745 return data->index_last_learned;
753FacerInterface::maxlenof_index_last_learned()
const
765FacerInterface::set_index_last_learned(
const uint32_t new_index_last_learned)
767 set_field(data->index_last_learned, new_index_last_learned);
772FacerInterface::create_message(
const char *type)
const
774 if ( strncmp(
"LearnFaceMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
776 }
else if ( strncmp(
"SetOpmodeMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
778 }
else if ( strncmp(
"EnableIdentityMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
780 }
else if ( strncmp(
"SetNameMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
782 }
else if ( strncmp(
"GetNameMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
784 }
else if ( strncmp(
"StartSearchPersonMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
786 }
else if ( strncmp(
"StopSearchPersonMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
790 "message type for this interface type.", type);
804 type(), other->
type());
806 memcpy(data, oi->data,
sizeof(FacerInterface_data_t));
810FacerInterface::enum_tostring(
const char *enumtype,
int val)
const
812 if (strcmp(enumtype,
"if_facer_opmode_t") == 0) {
829FacerInterface::LearnFaceMessage::LearnFaceMessage(
const char * ini_name) :
Message(
"LearnFaceMessage")
831 data_size =
sizeof(LearnFaceMessage_data_t);
834 data = (LearnFaceMessage_data_t *)
data_ptr;
836 strncpy(data->name, ini_name, 64-1);
837 data->name[64-1] = 0;
842 enum_map_if_facer_opmode_t[(int)
OPMODE_GENDER] =
"OPMODE_GENDER";
848 data_size =
sizeof(LearnFaceMessage_data_t);
851 data = (LearnFaceMessage_data_t *)
data_ptr;
857 enum_map_if_facer_opmode_t[(int)
OPMODE_GENDER] =
"OPMODE_GENDER";
875 data = (LearnFaceMessage_data_t *)
data_ptr;
932 data_size =
sizeof(SetOpmodeMessage_data_t);
935 data = (SetOpmodeMessage_data_t *)
data_ptr;
937 data->opmode = ini_opmode;
942 enum_map_if_facer_opmode_t[(int)
OPMODE_GENDER] =
"OPMODE_GENDER";
943 add_fieldinfo(
IFT_ENUM,
"opmode", 1, &data->opmode,
"if_facer_opmode_t", &enum_map_if_facer_opmode_t);
948 data_size =
sizeof(SetOpmodeMessage_data_t);
951 data = (SetOpmodeMessage_data_t *)
data_ptr;
957 enum_map_if_facer_opmode_t[(int)
OPMODE_GENDER] =
"OPMODE_GENDER";
958 add_fieldinfo(
IFT_ENUM,
"opmode", 1, &data->opmode,
"if_facer_opmode_t", &enum_map_if_facer_opmode_t);
975 data = (SetOpmodeMessage_data_t *)
data_ptr;
1037 data_size =
sizeof(EnableIdentityMessage_data_t);
1040 data = (EnableIdentityMessage_data_t *)
data_ptr;
1042 data->index = ini_index;
1043 data->enable = ini_enable;
1048 enum_map_if_facer_opmode_t[(int)
OPMODE_GENDER] =
"OPMODE_GENDER";
1055 data_size =
sizeof(EnableIdentityMessage_data_t);
1058 data = (EnableIdentityMessage_data_t *)
data_ptr;
1064 enum_map_if_facer_opmode_t[(int)
OPMODE_GENDER] =
"OPMODE_GENDER";
1083 data = (EnableIdentityMessage_data_t *)
data_ptr;
1125 return data->enable;
1171 data_size =
sizeof(SetNameMessage_data_t);
1174 data = (SetNameMessage_data_t *)
data_ptr;
1176 data->index = ini_index;
1177 strncpy(data->name, ini_name, 64-1);
1178 data->name[64-1] = 0;
1183 enum_map_if_facer_opmode_t[(int)
OPMODE_GENDER] =
"OPMODE_GENDER";
1190 data_size =
sizeof(SetNameMessage_data_t);
1193 data = (SetNameMessage_data_t *)
data_ptr;
1199 enum_map_if_facer_opmode_t[(int)
OPMODE_GENDER] =
"OPMODE_GENDER";
1218 data = (SetNameMessage_data_t *)
data_ptr;
1305 data_size =
sizeof(GetNameMessage_data_t);
1308 data = (GetNameMessage_data_t *)
data_ptr;
1310 data->index = ini_index;
1315 enum_map_if_facer_opmode_t[(int)
OPMODE_GENDER] =
"OPMODE_GENDER";
1321 data_size =
sizeof(GetNameMessage_data_t);
1324 data = (GetNameMessage_data_t *)
data_ptr;
1330 enum_map_if_facer_opmode_t[(int)
OPMODE_GENDER] =
"OPMODE_GENDER";
1348 data = (GetNameMessage_data_t *)
data_ptr;
1405 data_size =
sizeof(StartSearchPersonMessage_data_t);
1408 data = (StartSearchPersonMessage_data_t *)
data_ptr;
1410 data->index = ini_index;
1415 enum_map_if_facer_opmode_t[(int)
OPMODE_GENDER] =
"OPMODE_GENDER";
1421 data_size =
sizeof(StartSearchPersonMessage_data_t);
1424 data = (StartSearchPersonMessage_data_t *)
data_ptr;
1430 enum_map_if_facer_opmode_t[(int)
OPMODE_GENDER] =
"OPMODE_GENDER";
1448 data = (StartSearchPersonMessage_data_t *)
data_ptr;
1503 data_size =
sizeof(StopSearchPersonMessage_data_t);
1506 data = (StopSearchPersonMessage_data_t *)
data_ptr;
1512 enum_map_if_facer_opmode_t[(int)
OPMODE_GENDER] =
"OPMODE_GENDER";
1529 data = (StopSearchPersonMessage_data_t *)
data_ptr;
EnableIdentityMessage Fawkes BlackBoard Interface Message.
~EnableIdentityMessage()
Destructor.
EnableIdentityMessage()
Constructor.
virtual Message * clone() const
Clone this message.
bool is_enable() const
Get enable value.
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.
GetNameMessage()
Constructor.
~GetNameMessage()
Destructor.
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.
LearnFaceMessage()
Constructor.
virtual Message * clone() const
Clone this message.
~LearnFaceMessage()
Destructor.
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.
SetNameMessage()
Constructor.
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.
~SetNameMessage()
Destructor.
SetOpmodeMessage Fawkes BlackBoard Interface Message.
~SetOpmodeMessage()
Destructor.
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.
SetOpmodeMessage()
Constructor.
virtual Message * clone() const
Clone this message.
StartSearchPersonMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
~StartSearchPersonMessage()
Destructor.
void set_index(const uint32_t new_index)
Set index value.
StartSearchPersonMessage()
Constructor.
uint32_t index() const
Get 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.
~StopSearchPersonMessage()
Destructor.
StopSearchPersonMessage()
Constructor.
FacerInterface Fawkes BlackBoard Interface.
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.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
Base class for all Fawkes BlackBoard interfaces.
const char * type() const
Get type of interface.
void * data_ptr
Pointer to local memory storage.
void set_field(FieldT &field, DataT &data)
Set a field, set data_changed to true and update data_changed accordingly.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0, const interface_enum_map_t *enum_map=0)
Add an entry to the info list.
void * data_ptr
Pointer to memory that contains local data.
message_data_ts_t * data_ts
data timestamp aliasing pointer
unsigned int data_size
Size of memory needed to hold all data.
Fawkes library namespace.
@ IFT_UINT32
32 bit unsigned integer field
@ IFT_ENUM
field with interface specific enum type
Timestamp data, must be present and first entries for each interface data structs!...