FacerInterface.h
00001 00002 /*************************************************************************** 00003 * FacerInterface.h - Fawkes BlackBoard Interface - FacerInterface 00004 * 00005 * Templated created: Thu Oct 12 10:49:19 2006 00006 * Copyright 2008 Tim Niemueller 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __INTERFACES_FACERINTERFACE_H_ 00025 #define __INTERFACES_FACERINTERFACE_H_ 00026 00027 #include <interface/interface.h> 00028 #include <interface/message.h> 00029 #include <interface/field_iterator.h> 00030 00031 namespace fawkes { 00032 00033 class FacerInterface : public Interface 00034 { 00035 /// @cond INTERNALS 00036 INTERFACE_MGMT_FRIENDS(FacerInterface) 00037 /// @endcond 00038 public: 00039 /* constants */ 00040 00041 /** 00042 This determines the current status of skill execution. 00043 */ 00044 typedef enum { 00045 OPMODE_DISABLED /**< Facer will not process any images */, 00046 OPMODE_DETECTION /**< Facer will detect faces, but not try to recognize them. */, 00047 OPMODE_RECOGNITION /**< Facer will detect faces, and then try to recognize the most dominant face. */, 00048 OPMODE_LEARNING /**< Facer will gather images and learn an identity. */ 00049 } if_facer_opmode_t; 00050 00051 private: 00052 /** Internal data storage, do NOT modify! */ 00053 typedef struct { 00054 unsigned int num_identities; /**< 00055 The number of identities in the database. 00056 */ 00057 unsigned int recognized_identity; /**< 00058 The index of the recognized identity. 00059 */ 00060 unsigned int num_detections; /**< 00061 Number of currently detected faces. 00062 */ 00063 unsigned int num_recognitions; /**< 00064 Number of recognized faces. 00065 */ 00066 unsigned int most_likely_identity; /**< 00067 The identity that was recognized most prevalently. 00068 */ 00069 unsigned int requested_index; /**< 00070 Index of the identity for which the name was requested. 00071 */ 00072 int visibility_history; /**< 00073 The number of consecutive sighting ( <= 1 ) and non-sightings 00074 ( >= -1 ), respectively. 00075 */ 00076 float history_ratio; /**< 00077 The ratio of the most likely identity showing up in the history 00078 and the length of the history. 00079 */ 00080 float sec_since_detection; /**< 00081 Time in seconds since the last successful detection. 00082 */ 00083 float recording_progress; /**< 00084 Indicates the progress of recording images of a new face. 00085 */ 00086 float bearing; /**< 00087 The relative bearing to the recognized face in radians. 00088 */ 00089 float slope; /**< 00090 The relative slope to the recognized face in radians. 00091 */ 00092 bool learning_in_progress; /**< 00093 Indicates whether a new identity is currently learnt. If 00094 learning is in progress only "old" faces can be recognized. 00095 */ 00096 if_facer_opmode_t opmode; /**< 00097 Current opmode. 00098 */ 00099 char recognized_name[64]; /**< 00100 The name of the recognized identity. 00101 */ 00102 char requested_name[64]; /**< 00103 Requested name. 00104 */ 00105 } FacerInterface_data_t; 00106 00107 FacerInterface_data_t *data; 00108 00109 public: 00110 /* messages */ 00111 class LearnFaceMessage : public Message 00112 { 00113 private: 00114 /** Internal data storage, do NOT modify! */ 00115 typedef struct { 00116 char name[64]; /**< The name assigned to the new identity. */ 00117 } LearnFaceMessage_data_t; 00118 00119 LearnFaceMessage_data_t *data; 00120 00121 public: 00122 LearnFaceMessage(const char * ini_name); 00123 LearnFaceMessage(); 00124 ~LearnFaceMessage(); 00125 00126 LearnFaceMessage(const LearnFaceMessage *m); 00127 /* Methods */ 00128 char * name() const; 00129 void set_name(const char * new_name); 00130 size_t maxlenof_name() const; 00131 virtual Message * clone() const; 00132 }; 00133 00134 class SetOpmodeMessage : public Message 00135 { 00136 private: 00137 /** Internal data storage, do NOT modify! */ 00138 typedef struct { 00139 if_facer_opmode_t opmode; /**< 00140 Current opmode. 00141 */ 00142 } SetOpmodeMessage_data_t; 00143 00144 SetOpmodeMessage_data_t *data; 00145 00146 public: 00147 SetOpmodeMessage(const if_facer_opmode_t ini_opmode); 00148 SetOpmodeMessage(); 00149 ~SetOpmodeMessage(); 00150 00151 SetOpmodeMessage(const SetOpmodeMessage *m); 00152 /* Methods */ 00153 if_facer_opmode_t opmode() const; 00154 void set_opmode(const if_facer_opmode_t new_opmode); 00155 size_t maxlenof_opmode() const; 00156 virtual Message * clone() const; 00157 }; 00158 00159 class EnableIdentityMessage : public Message 00160 { 00161 private: 00162 /** Internal data storage, do NOT modify! */ 00163 typedef struct { 00164 unsigned int index; /**< Index of the identity. */ 00165 bool enable; /**< En-/disable flag. */ 00166 } EnableIdentityMessage_data_t; 00167 00168 EnableIdentityMessage_data_t *data; 00169 00170 public: 00171 EnableIdentityMessage(const unsigned int ini_index, const bool ini_enable); 00172 EnableIdentityMessage(); 00173 ~EnableIdentityMessage(); 00174 00175 EnableIdentityMessage(const EnableIdentityMessage *m); 00176 /* Methods */ 00177 unsigned int index() const; 00178 void set_index(const unsigned int new_index); 00179 size_t maxlenof_index() const; 00180 bool is_enable() const; 00181 void set_enable(const bool new_enable); 00182 size_t maxlenof_enable() const; 00183 virtual Message * clone() const; 00184 }; 00185 00186 class SetNameMessage : public Message 00187 { 00188 private: 00189 /** Internal data storage, do NOT modify! */ 00190 typedef struct { 00191 unsigned int index; /**< Index of the identity. */ 00192 char name[64]; /**< Name of the identity. */ 00193 } SetNameMessage_data_t; 00194 00195 SetNameMessage_data_t *data; 00196 00197 public: 00198 SetNameMessage(const unsigned int ini_index, const char * ini_name); 00199 SetNameMessage(); 00200 ~SetNameMessage(); 00201 00202 SetNameMessage(const SetNameMessage *m); 00203 /* Methods */ 00204 unsigned int index() const; 00205 void set_index(const unsigned int new_index); 00206 size_t maxlenof_index() const; 00207 char * name() const; 00208 void set_name(const char * new_name); 00209 size_t maxlenof_name() const; 00210 virtual Message * clone() const; 00211 }; 00212 00213 class GetNameMessage : public Message 00214 { 00215 private: 00216 /** Internal data storage, do NOT modify! */ 00217 typedef struct { 00218 unsigned int index; /**< Index of the identity. */ 00219 } GetNameMessage_data_t; 00220 00221 GetNameMessage_data_t *data; 00222 00223 public: 00224 GetNameMessage(const unsigned int ini_index); 00225 GetNameMessage(); 00226 ~GetNameMessage(); 00227 00228 GetNameMessage(const GetNameMessage *m); 00229 /* Methods */ 00230 unsigned int index() const; 00231 void set_index(const unsigned int new_index); 00232 size_t maxlenof_index() const; 00233 virtual Message * clone() const; 00234 }; 00235 00236 virtual bool message_valid(const Message *message) const; 00237 private: 00238 FacerInterface(); 00239 ~FacerInterface(); 00240 00241 public: 00242 /* Methods */ 00243 if_facer_opmode_t opmode() const; 00244 void set_opmode(const if_facer_opmode_t new_opmode); 00245 size_t maxlenof_opmode() const; 00246 unsigned int num_identities() const; 00247 void set_num_identities(const unsigned int new_num_identities); 00248 size_t maxlenof_num_identities() const; 00249 unsigned int recognized_identity() const; 00250 void set_recognized_identity(const unsigned int new_recognized_identity); 00251 size_t maxlenof_recognized_identity() const; 00252 char * recognized_name() const; 00253 void set_recognized_name(const char * new_recognized_name); 00254 size_t maxlenof_recognized_name() const; 00255 unsigned int num_detections() const; 00256 void set_num_detections(const unsigned int new_num_detections); 00257 size_t maxlenof_num_detections() const; 00258 unsigned int num_recognitions() const; 00259 void set_num_recognitions(const unsigned int new_num_recognitions); 00260 size_t maxlenof_num_recognitions() const; 00261 unsigned int most_likely_identity() const; 00262 void set_most_likely_identity(const unsigned int new_most_likely_identity); 00263 size_t maxlenof_most_likely_identity() const; 00264 float history_ratio() const; 00265 void set_history_ratio(const float new_history_ratio); 00266 size_t maxlenof_history_ratio() const; 00267 float sec_since_detection() const; 00268 void set_sec_since_detection(const float new_sec_since_detection); 00269 size_t maxlenof_sec_since_detection() const; 00270 int visibility_history() const; 00271 void set_visibility_history(const int new_visibility_history); 00272 size_t maxlenof_visibility_history() const; 00273 bool is_learning_in_progress() const; 00274 void set_learning_in_progress(const bool new_learning_in_progress); 00275 size_t maxlenof_learning_in_progress() const; 00276 float recording_progress() const; 00277 void set_recording_progress(const float new_recording_progress); 00278 size_t maxlenof_recording_progress() const; 00279 float bearing() const; 00280 void set_bearing(const float new_bearing); 00281 size_t maxlenof_bearing() const; 00282 float slope() const; 00283 void set_slope(const float new_slope); 00284 size_t maxlenof_slope() const; 00285 unsigned int requested_index() const; 00286 void set_requested_index(const unsigned int new_requested_index); 00287 size_t maxlenof_requested_index() const; 00288 char * requested_name() const; 00289 void set_requested_name(const char * new_requested_name); 00290 size_t maxlenof_requested_name() const; 00291 virtual Message * create_message(const char *type) const; 00292 00293 virtual void copy_values(const Interface *other); 00294 00295 }; 00296 00297 } // end namespace fawkes 00298 00299 #endif

