Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * FacerInterface.cpp - 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 #include <interfaces/FacerInterface.h> 00025 00026 #include <core/exceptions/software.h> 00027 00028 #include <cstring> 00029 #include <cstdlib> 00030 00031 namespace fawkes { 00032 00033 /** @class FacerInterface <interfaces/FacerInterface.h> 00034 * FacerInterface Fawkes BlackBoard Interface. 00035 * 00036 The interface provides access to the face recognition plugin 00037 (facer). It provides basic status information about facer and 00038 allows for setting a specific mode and access the resolut. 00039 calling skills via messages. It can also be used to manually 00040 restart the Lua interpreter if something is wedged. 00041 00042 * @ingroup FawkesInterfaces 00043 */ 00044 00045 00046 00047 /** Constructor */ 00048 FacerInterface::FacerInterface() : Interface() 00049 { 00050 data_size = sizeof(FacerInterface_data_t); 00051 data_ptr = malloc(data_size); 00052 data = (FacerInterface_data_t *)data_ptr; 00053 data_ts = (interface_data_ts_t *)data_ptr; 00054 memset(data_ptr, 0, data_size); 00055 add_fieldinfo(IFT_ENUM, "opmode", 1, &data->opmode, "if_facer_opmode_t"); 00056 add_fieldinfo(IFT_UINT32, "num_identities", 1, &data->num_identities); 00057 add_fieldinfo(IFT_UINT32, "recognized_identity", 1, &data->recognized_identity); 00058 add_fieldinfo(IFT_STRING, "recognized_name", 64, data->recognized_name); 00059 add_fieldinfo(IFT_UINT32, "num_detections", 1, &data->num_detections); 00060 add_fieldinfo(IFT_UINT32, "num_recognitions", 1, &data->num_recognitions); 00061 add_fieldinfo(IFT_UINT32, "most_likely_identity", 1, &data->most_likely_identity); 00062 add_fieldinfo(IFT_FLOAT, "history_ratio", 1, &data->history_ratio); 00063 add_fieldinfo(IFT_FLOAT, "sec_since_detection", 1, &data->sec_since_detection); 00064 add_fieldinfo(IFT_INT32, "visibility_history", 1, &data->visibility_history); 00065 add_fieldinfo(IFT_BOOL, "learning_in_progress", 1, &data->learning_in_progress); 00066 add_fieldinfo(IFT_FLOAT, "recording_progress", 1, &data->recording_progress); 00067 add_fieldinfo(IFT_FLOAT, "bearing", 1, &data->bearing); 00068 add_fieldinfo(IFT_FLOAT, "slope", 1, &data->slope); 00069 add_fieldinfo(IFT_UINT32, "requested_index", 1, &data->requested_index); 00070 add_fieldinfo(IFT_STRING, "requested_name", 64, data->requested_name); 00071 add_messageinfo("LearnFaceMessage"); 00072 add_messageinfo("SetOpmodeMessage"); 00073 add_messageinfo("EnableIdentityMessage"); 00074 add_messageinfo("SetNameMessage"); 00075 add_messageinfo("GetNameMessage"); 00076 unsigned char tmp_hash[] = {0xe1, 0x12, 0xd2, 0x51, 0x1d, 0x24, 0x1b, 0x27, 0x86, 0xce, 0x29, 0x32, 0xd6, 0x5a, 0x5e, 0xb3}; 00077 set_hash(tmp_hash); 00078 } 00079 00080 /** Destructor */ 00081 FacerInterface::~FacerInterface() 00082 { 00083 free(data_ptr); 00084 } 00085 /** Convert if_facer_opmode_t constant to string. 00086 * @param value value to convert to string 00087 * @return constant value as string. 00088 */ 00089 const char * 00090 FacerInterface::tostring_if_facer_opmode_t(if_facer_opmode_t value) const 00091 { 00092 switch (value) { 00093 case OPMODE_DISABLED: return "OPMODE_DISABLED"; 00094 case OPMODE_DETECTION: return "OPMODE_DETECTION"; 00095 case OPMODE_RECOGNITION: return "OPMODE_RECOGNITION"; 00096 case OPMODE_LEARNING: return "OPMODE_LEARNING"; 00097 default: return "UNKNOWN"; 00098 } 00099 } 00100 /* Methods */ 00101 /** Get opmode value. 00102 * 00103 Current opmode. 00104 00105 * @return opmode value 00106 */ 00107 FacerInterface::if_facer_opmode_t 00108 FacerInterface::opmode() const 00109 { 00110 return data->opmode; 00111 } 00112 00113 /** Get maximum length of opmode value. 00114 * @return length of opmode value, can be length of the array or number of 00115 * maximum number of characters for a string 00116 */ 00117 size_t 00118 FacerInterface::maxlenof_opmode() const 00119 { 00120 return 1; 00121 } 00122 00123 /** Set opmode value. 00124 * 00125 Current opmode. 00126 00127 * @param new_opmode new opmode value 00128 */ 00129 void 00130 FacerInterface::set_opmode(const if_facer_opmode_t new_opmode) 00131 { 00132 data->opmode = new_opmode; 00133 data_changed = true; 00134 } 00135 00136 /** Get num_identities value. 00137 * 00138 The number of identities in the database. 00139 00140 * @return num_identities value 00141 */ 00142 uint32_t 00143 FacerInterface::num_identities() const 00144 { 00145 return data->num_identities; 00146 } 00147 00148 /** Get maximum length of num_identities value. 00149 * @return length of num_identities value, can be length of the array or number of 00150 * maximum number of characters for a string 00151 */ 00152 size_t 00153 FacerInterface::maxlenof_num_identities() const 00154 { 00155 return 1; 00156 } 00157 00158 /** Set num_identities value. 00159 * 00160 The number of identities in the database. 00161 00162 * @param new_num_identities new num_identities value 00163 */ 00164 void 00165 FacerInterface::set_num_identities(const uint32_t new_num_identities) 00166 { 00167 data->num_identities = new_num_identities; 00168 data_changed = true; 00169 } 00170 00171 /** Get recognized_identity value. 00172 * 00173 The index of the recognized identity. 00174 00175 * @return recognized_identity value 00176 */ 00177 uint32_t 00178 FacerInterface::recognized_identity() const 00179 { 00180 return data->recognized_identity; 00181 } 00182 00183 /** Get maximum length of recognized_identity value. 00184 * @return length of recognized_identity value, can be length of the array or number of 00185 * maximum number of characters for a string 00186 */ 00187 size_t 00188 FacerInterface::maxlenof_recognized_identity() const 00189 { 00190 return 1; 00191 } 00192 00193 /** Set recognized_identity value. 00194 * 00195 The index of the recognized identity. 00196 00197 * @param new_recognized_identity new recognized_identity value 00198 */ 00199 void 00200 FacerInterface::set_recognized_identity(const uint32_t new_recognized_identity) 00201 { 00202 data->recognized_identity = new_recognized_identity; 00203 data_changed = true; 00204 } 00205 00206 /** Get recognized_name value. 00207 * 00208 The name of the recognized identity. 00209 00210 * @return recognized_name value 00211 */ 00212 char * 00213 FacerInterface::recognized_name() const 00214 { 00215 return data->recognized_name; 00216 } 00217 00218 /** Get maximum length of recognized_name value. 00219 * @return length of recognized_name value, can be length of the array or number of 00220 * maximum number of characters for a string 00221 */ 00222 size_t 00223 FacerInterface::maxlenof_recognized_name() const 00224 { 00225 return 64; 00226 } 00227 00228 /** Set recognized_name value. 00229 * 00230 The name of the recognized identity. 00231 00232 * @param new_recognized_name new recognized_name value 00233 */ 00234 void 00235 FacerInterface::set_recognized_name(const char * new_recognized_name) 00236 { 00237 strncpy(data->recognized_name, new_recognized_name, sizeof(data->recognized_name)); 00238 data_changed = true; 00239 } 00240 00241 /** Get num_detections value. 00242 * 00243 Number of currently detected faces. 00244 00245 * @return num_detections value 00246 */ 00247 uint32_t 00248 FacerInterface::num_detections() const 00249 { 00250 return data->num_detections; 00251 } 00252 00253 /** Get maximum length of num_detections value. 00254 * @return length of num_detections value, can be length of the array or number of 00255 * maximum number of characters for a string 00256 */ 00257 size_t 00258 FacerInterface::maxlenof_num_detections() const 00259 { 00260 return 1; 00261 } 00262 00263 /** Set num_detections value. 00264 * 00265 Number of currently detected faces. 00266 00267 * @param new_num_detections new num_detections value 00268 */ 00269 void 00270 FacerInterface::set_num_detections(const uint32_t new_num_detections) 00271 { 00272 data->num_detections = new_num_detections; 00273 data_changed = true; 00274 } 00275 00276 /** Get num_recognitions value. 00277 * 00278 Number of recognized faces. 00279 00280 * @return num_recognitions value 00281 */ 00282 uint32_t 00283 FacerInterface::num_recognitions() const 00284 { 00285 return data->num_recognitions; 00286 } 00287 00288 /** Get maximum length of num_recognitions value. 00289 * @return length of num_recognitions value, can be length of the array or number of 00290 * maximum number of characters for a string 00291 */ 00292 size_t 00293 FacerInterface::maxlenof_num_recognitions() const 00294 { 00295 return 1; 00296 } 00297 00298 /** Set num_recognitions value. 00299 * 00300 Number of recognized faces. 00301 00302 * @param new_num_recognitions new num_recognitions value 00303 */ 00304 void 00305 FacerInterface::set_num_recognitions(const uint32_t new_num_recognitions) 00306 { 00307 data->num_recognitions = new_num_recognitions; 00308 data_changed = true; 00309 } 00310 00311 /** Get most_likely_identity value. 00312 * 00313 The identity that was recognized most prevalently. 00314 00315 * @return most_likely_identity value 00316 */ 00317 uint32_t 00318 FacerInterface::most_likely_identity() const 00319 { 00320 return data->most_likely_identity; 00321 } 00322 00323 /** Get maximum length of most_likely_identity value. 00324 * @return length of most_likely_identity value, can be length of the array or number of 00325 * maximum number of characters for a string 00326 */ 00327 size_t 00328 FacerInterface::maxlenof_most_likely_identity() const 00329 { 00330 return 1; 00331 } 00332 00333 /** Set most_likely_identity value. 00334 * 00335 The identity that was recognized most prevalently. 00336 00337 * @param new_most_likely_identity new most_likely_identity value 00338 */ 00339 void 00340 FacerInterface::set_most_likely_identity(const uint32_t new_most_likely_identity) 00341 { 00342 data->most_likely_identity = new_most_likely_identity; 00343 data_changed = true; 00344 } 00345 00346 /** Get history_ratio value. 00347 * 00348 The ratio of the most likely identity showing up in the history 00349 and the length of the history. 00350 00351 * @return history_ratio value 00352 */ 00353 float 00354 FacerInterface::history_ratio() const 00355 { 00356 return data->history_ratio; 00357 } 00358 00359 /** Get maximum length of history_ratio value. 00360 * @return length of history_ratio value, can be length of the array or number of 00361 * maximum number of characters for a string 00362 */ 00363 size_t 00364 FacerInterface::maxlenof_history_ratio() const 00365 { 00366 return 1; 00367 } 00368 00369 /** Set history_ratio value. 00370 * 00371 The ratio of the most likely identity showing up in the history 00372 and the length of the history. 00373 00374 * @param new_history_ratio new history_ratio value 00375 */ 00376 void 00377 FacerInterface::set_history_ratio(const float new_history_ratio) 00378 { 00379 data->history_ratio = new_history_ratio; 00380 data_changed = true; 00381 } 00382 00383 /** Get sec_since_detection value. 00384 * 00385 Time in seconds since the last successful detection. 00386 00387 * @return sec_since_detection value 00388 */ 00389 float 00390 FacerInterface::sec_since_detection() const 00391 { 00392 return data->sec_since_detection; 00393 } 00394 00395 /** Get maximum length of sec_since_detection value. 00396 * @return length of sec_since_detection value, can be length of the array or number of 00397 * maximum number of characters for a string 00398 */ 00399 size_t 00400 FacerInterface::maxlenof_sec_since_detection() const 00401 { 00402 return 1; 00403 } 00404 00405 /** Set sec_since_detection value. 00406 * 00407 Time in seconds since the last successful detection. 00408 00409 * @param new_sec_since_detection new sec_since_detection value 00410 */ 00411 void 00412 FacerInterface::set_sec_since_detection(const float new_sec_since_detection) 00413 { 00414 data->sec_since_detection = new_sec_since_detection; 00415 data_changed = true; 00416 } 00417 00418 /** Get visibility_history value. 00419 * 00420 The number of consecutive sighting ( <= 1 ) and non-sightings 00421 ( >= -1 ), respectively. 00422 00423 * @return visibility_history value 00424 */ 00425 int32_t 00426 FacerInterface::visibility_history() const 00427 { 00428 return data->visibility_history; 00429 } 00430 00431 /** Get maximum length of visibility_history value. 00432 * @return length of visibility_history value, can be length of the array or number of 00433 * maximum number of characters for a string 00434 */ 00435 size_t 00436 FacerInterface::maxlenof_visibility_history() const 00437 { 00438 return 1; 00439 } 00440 00441 /** Set visibility_history value. 00442 * 00443 The number of consecutive sighting ( <= 1 ) and non-sightings 00444 ( >= -1 ), respectively. 00445 00446 * @param new_visibility_history new visibility_history value 00447 */ 00448 void 00449 FacerInterface::set_visibility_history(const int32_t new_visibility_history) 00450 { 00451 data->visibility_history = new_visibility_history; 00452 data_changed = true; 00453 } 00454 00455 /** Get learning_in_progress value. 00456 * 00457 Indicates whether a new identity is currently learnt. If 00458 learning is in progress only "old" faces can be recognized. 00459 00460 * @return learning_in_progress value 00461 */ 00462 bool 00463 FacerInterface::is_learning_in_progress() const 00464 { 00465 return data->learning_in_progress; 00466 } 00467 00468 /** Get maximum length of learning_in_progress value. 00469 * @return length of learning_in_progress value, can be length of the array or number of 00470 * maximum number of characters for a string 00471 */ 00472 size_t 00473 FacerInterface::maxlenof_learning_in_progress() const 00474 { 00475 return 1; 00476 } 00477 00478 /** Set learning_in_progress value. 00479 * 00480 Indicates whether a new identity is currently learnt. If 00481 learning is in progress only "old" faces can be recognized. 00482 00483 * @param new_learning_in_progress new learning_in_progress value 00484 */ 00485 void 00486 FacerInterface::set_learning_in_progress(const bool new_learning_in_progress) 00487 { 00488 data->learning_in_progress = new_learning_in_progress; 00489 data_changed = true; 00490 } 00491 00492 /** Get recording_progress value. 00493 * 00494 Indicates the progress of recording images of a new face. 00495 00496 * @return recording_progress value 00497 */ 00498 float 00499 FacerInterface::recording_progress() const 00500 { 00501 return data->recording_progress; 00502 } 00503 00504 /** Get maximum length of recording_progress value. 00505 * @return length of recording_progress value, can be length of the array or number of 00506 * maximum number of characters for a string 00507 */ 00508 size_t 00509 FacerInterface::maxlenof_recording_progress() const 00510 { 00511 return 1; 00512 } 00513 00514 /** Set recording_progress value. 00515 * 00516 Indicates the progress of recording images of a new face. 00517 00518 * @param new_recording_progress new recording_progress value 00519 */ 00520 void 00521 FacerInterface::set_recording_progress(const float new_recording_progress) 00522 { 00523 data->recording_progress = new_recording_progress; 00524 data_changed = true; 00525 } 00526 00527 /** Get bearing value. 00528 * 00529 The relative bearing to the recognized face in radians. 00530 00531 * @return bearing value 00532 */ 00533 float 00534 FacerInterface::bearing() const 00535 { 00536 return data->bearing; 00537 } 00538 00539 /** Get maximum length of bearing value. 00540 * @return length of bearing value, can be length of the array or number of 00541 * maximum number of characters for a string 00542 */ 00543 size_t 00544 FacerInterface::maxlenof_bearing() const 00545 { 00546 return 1; 00547 } 00548 00549 /** Set bearing value. 00550 * 00551 The relative bearing to the recognized face in radians. 00552 00553 * @param new_bearing new bearing value 00554 */ 00555 void 00556 FacerInterface::set_bearing(const float new_bearing) 00557 { 00558 data->bearing = new_bearing; 00559 data_changed = true; 00560 } 00561 00562 /** Get slope value. 00563 * 00564 The relative slope to the recognized face in radians. 00565 00566 * @return slope value 00567 */ 00568 float 00569 FacerInterface::slope() const 00570 { 00571 return data->slope; 00572 } 00573 00574 /** Get maximum length of slope value. 00575 * @return length of slope value, can be length of the array or number of 00576 * maximum number of characters for a string 00577 */ 00578 size_t 00579 FacerInterface::maxlenof_slope() const 00580 { 00581 return 1; 00582 } 00583 00584 /** Set slope value. 00585 * 00586 The relative slope to the recognized face in radians. 00587 00588 * @param new_slope new slope value 00589 */ 00590 void 00591 FacerInterface::set_slope(const float new_slope) 00592 { 00593 data->slope = new_slope; 00594 data_changed = true; 00595 } 00596 00597 /** Get requested_index value. 00598 * 00599 Index of the identity for which the name was requested. 00600 00601 * @return requested_index value 00602 */ 00603 uint32_t 00604 FacerInterface::requested_index() const 00605 { 00606 return data->requested_index; 00607 } 00608 00609 /** Get maximum length of requested_index value. 00610 * @return length of requested_index value, can be length of the array or number of 00611 * maximum number of characters for a string 00612 */ 00613 size_t 00614 FacerInterface::maxlenof_requested_index() const 00615 { 00616 return 1; 00617 } 00618 00619 /** Set requested_index value. 00620 * 00621 Index of the identity for which the name was requested. 00622 00623 * @param new_requested_index new requested_index value 00624 */ 00625 void 00626 FacerInterface::set_requested_index(const uint32_t new_requested_index) 00627 { 00628 data->requested_index = new_requested_index; 00629 data_changed = true; 00630 } 00631 00632 /** Get requested_name value. 00633 * 00634 Requested name. 00635 00636 * @return requested_name value 00637 */ 00638 char * 00639 FacerInterface::requested_name() const 00640 { 00641 return data->requested_name; 00642 } 00643 00644 /** Get maximum length of requested_name value. 00645 * @return length of requested_name value, can be length of the array or number of 00646 * maximum number of characters for a string 00647 */ 00648 size_t 00649 FacerInterface::maxlenof_requested_name() const 00650 { 00651 return 64; 00652 } 00653 00654 /** Set requested_name value. 00655 * 00656 Requested name. 00657 00658 * @param new_requested_name new requested_name value 00659 */ 00660 void 00661 FacerInterface::set_requested_name(const char * new_requested_name) 00662 { 00663 strncpy(data->requested_name, new_requested_name, sizeof(data->requested_name)); 00664 data_changed = true; 00665 } 00666 00667 /* =========== message create =========== */ 00668 Message * 00669 FacerInterface::create_message(const char *type) const 00670 { 00671 if ( strncmp("LearnFaceMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) { 00672 return new LearnFaceMessage(); 00673 } else if ( strncmp("SetOpmodeMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) { 00674 return new SetOpmodeMessage(); 00675 } else if ( strncmp("EnableIdentityMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) { 00676 return new EnableIdentityMessage(); 00677 } else if ( strncmp("SetNameMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) { 00678 return new SetNameMessage(); 00679 } else if ( strncmp("GetNameMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) { 00680 return new GetNameMessage(); 00681 } else { 00682 throw UnknownTypeException("The given type '%s' does not match any known " 00683 "message type for this interface type.", type); 00684 } 00685 } 00686 00687 00688 /** Copy values from other interface. 00689 * @param other other interface to copy values from 00690 */ 00691 void 00692 FacerInterface::copy_values(const Interface *other) 00693 { 00694 const FacerInterface *oi = dynamic_cast<const FacerInterface *>(other); 00695 if (oi == NULL) { 00696 throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)", 00697 type(), other->type()); 00698 } 00699 memcpy(data, oi->data, sizeof(FacerInterface_data_t)); 00700 } 00701 00702 const char * 00703 FacerInterface::enum_tostring(const char *enumtype, int val) const 00704 { 00705 if (strcmp(enumtype, "if_facer_opmode_t") == 0) { 00706 return tostring_if_facer_opmode_t((if_facer_opmode_t)val); 00707 } 00708 throw UnknownTypeException("Unknown enum type %s", enumtype); 00709 } 00710 00711 /* =========== messages =========== */ 00712 /** @class FacerInterface::LearnFaceMessage <interfaces/FacerInterface.h> 00713 * LearnFaceMessage Fawkes BlackBoard Interface Message. 00714 * 00715 00716 */ 00717 00718 00719 /** Constructor with initial values. 00720 * @param ini_name initial value for name 00721 */ 00722 FacerInterface::LearnFaceMessage::LearnFaceMessage(const char * ini_name) : Message("LearnFaceMessage") 00723 { 00724 data_size = sizeof(LearnFaceMessage_data_t); 00725 data_ptr = malloc(data_size); 00726 memset(data_ptr, 0, data_size); 00727 data = (LearnFaceMessage_data_t *)data_ptr; 00728 data_ts = (message_data_ts_t *)data_ptr; 00729 strncpy(data->name, ini_name, 64); 00730 add_fieldinfo(IFT_STRING, "name", 64, data->name); 00731 } 00732 /** Constructor */ 00733 FacerInterface::LearnFaceMessage::LearnFaceMessage() : Message("LearnFaceMessage") 00734 { 00735 data_size = sizeof(LearnFaceMessage_data_t); 00736 data_ptr = malloc(data_size); 00737 memset(data_ptr, 0, data_size); 00738 data = (LearnFaceMessage_data_t *)data_ptr; 00739 data_ts = (message_data_ts_t *)data_ptr; 00740 add_fieldinfo(IFT_STRING, "name", 64, data->name); 00741 } 00742 00743 /** Destructor */ 00744 FacerInterface::LearnFaceMessage::~LearnFaceMessage() 00745 { 00746 free(data_ptr); 00747 } 00748 00749 /** Copy constructor. 00750 * @param m message to copy from 00751 */ 00752 FacerInterface::LearnFaceMessage::LearnFaceMessage(const LearnFaceMessage *m) : Message("LearnFaceMessage") 00753 { 00754 data_size = m->data_size; 00755 data_ptr = malloc(data_size); 00756 memcpy(data_ptr, m->data_ptr, data_size); 00757 data = (LearnFaceMessage_data_t *)data_ptr; 00758 data_ts = (message_data_ts_t *)data_ptr; 00759 } 00760 00761 /* Methods */ 00762 /** Get name value. 00763 * The name assigned to the new identity. 00764 * @return name value 00765 */ 00766 char * 00767 FacerInterface::LearnFaceMessage::name() const 00768 { 00769 return data->name; 00770 } 00771 00772 /** Get maximum length of name value. 00773 * @return length of name value, can be length of the array or number of 00774 * maximum number of characters for a string 00775 */ 00776 size_t 00777 FacerInterface::LearnFaceMessage::maxlenof_name() const 00778 { 00779 return 64; 00780 } 00781 00782 /** Set name value. 00783 * The name assigned to the new identity. 00784 * @param new_name new name value 00785 */ 00786 void 00787 FacerInterface::LearnFaceMessage::set_name(const char * new_name) 00788 { 00789 strncpy(data->name, new_name, sizeof(data->name)); 00790 } 00791 00792 /** Clone this message. 00793 * Produces a message of the same type as this message and copies the 00794 * data to the new message. 00795 * @return clone of this message 00796 */ 00797 Message * 00798 FacerInterface::LearnFaceMessage::clone() const 00799 { 00800 return new FacerInterface::LearnFaceMessage(this); 00801 } 00802 /** @class FacerInterface::SetOpmodeMessage <interfaces/FacerInterface.h> 00803 * SetOpmodeMessage Fawkes BlackBoard Interface Message. 00804 * 00805 00806 */ 00807 00808 00809 /** Constructor with initial values. 00810 * @param ini_opmode initial value for opmode 00811 */ 00812 FacerInterface::SetOpmodeMessage::SetOpmodeMessage(const if_facer_opmode_t ini_opmode) : Message("SetOpmodeMessage") 00813 { 00814 data_size = sizeof(SetOpmodeMessage_data_t); 00815 data_ptr = malloc(data_size); 00816 memset(data_ptr, 0, data_size); 00817 data = (SetOpmodeMessage_data_t *)data_ptr; 00818 data_ts = (message_data_ts_t *)data_ptr; 00819 data->opmode = ini_opmode; 00820 add_fieldinfo(IFT_ENUM, "opmode", 1, &data->opmode, "if_facer_opmode_t"); 00821 } 00822 /** Constructor */ 00823 FacerInterface::SetOpmodeMessage::SetOpmodeMessage() : Message("SetOpmodeMessage") 00824 { 00825 data_size = sizeof(SetOpmodeMessage_data_t); 00826 data_ptr = malloc(data_size); 00827 memset(data_ptr, 0, data_size); 00828 data = (SetOpmodeMessage_data_t *)data_ptr; 00829 data_ts = (message_data_ts_t *)data_ptr; 00830 add_fieldinfo(IFT_ENUM, "opmode", 1, &data->opmode, "if_facer_opmode_t"); 00831 } 00832 00833 /** Destructor */ 00834 FacerInterface::SetOpmodeMessage::~SetOpmodeMessage() 00835 { 00836 free(data_ptr); 00837 } 00838 00839 /** Copy constructor. 00840 * @param m message to copy from 00841 */ 00842 FacerInterface::SetOpmodeMessage::SetOpmodeMessage(const SetOpmodeMessage *m) : Message("SetOpmodeMessage") 00843 { 00844 data_size = m->data_size; 00845 data_ptr = malloc(data_size); 00846 memcpy(data_ptr, m->data_ptr, data_size); 00847 data = (SetOpmodeMessage_data_t *)data_ptr; 00848 data_ts = (message_data_ts_t *)data_ptr; 00849 } 00850 00851 /* Methods */ 00852 /** Get opmode value. 00853 * 00854 Current opmode. 00855 00856 * @return opmode value 00857 */ 00858 FacerInterface::if_facer_opmode_t 00859 FacerInterface::SetOpmodeMessage::opmode() const 00860 { 00861 return data->opmode; 00862 } 00863 00864 /** Get maximum length of opmode value. 00865 * @return length of opmode value, can be length of the array or number of 00866 * maximum number of characters for a string 00867 */ 00868 size_t 00869 FacerInterface::SetOpmodeMessage::maxlenof_opmode() const 00870 { 00871 return 1; 00872 } 00873 00874 /** Set opmode value. 00875 * 00876 Current opmode. 00877 00878 * @param new_opmode new opmode value 00879 */ 00880 void 00881 FacerInterface::SetOpmodeMessage::set_opmode(const if_facer_opmode_t new_opmode) 00882 { 00883 data->opmode = new_opmode; 00884 } 00885 00886 /** Clone this message. 00887 * Produces a message of the same type as this message and copies the 00888 * data to the new message. 00889 * @return clone of this message 00890 */ 00891 Message * 00892 FacerInterface::SetOpmodeMessage::clone() const 00893 { 00894 return new FacerInterface::SetOpmodeMessage(this); 00895 } 00896 /** @class FacerInterface::EnableIdentityMessage <interfaces/FacerInterface.h> 00897 * EnableIdentityMessage Fawkes BlackBoard Interface Message. 00898 * 00899 00900 */ 00901 00902 00903 /** Constructor with initial values. 00904 * @param ini_index initial value for index 00905 * @param ini_enable initial value for enable 00906 */ 00907 FacerInterface::EnableIdentityMessage::EnableIdentityMessage(const uint32_t ini_index, const bool ini_enable) : Message("EnableIdentityMessage") 00908 { 00909 data_size = sizeof(EnableIdentityMessage_data_t); 00910 data_ptr = malloc(data_size); 00911 memset(data_ptr, 0, data_size); 00912 data = (EnableIdentityMessage_data_t *)data_ptr; 00913 data_ts = (message_data_ts_t *)data_ptr; 00914 data->index = ini_index; 00915 data->enable = ini_enable; 00916 add_fieldinfo(IFT_UINT32, "index", 1, &data->index); 00917 add_fieldinfo(IFT_BOOL, "enable", 1, &data->enable); 00918 } 00919 /** Constructor */ 00920 FacerInterface::EnableIdentityMessage::EnableIdentityMessage() : Message("EnableIdentityMessage") 00921 { 00922 data_size = sizeof(EnableIdentityMessage_data_t); 00923 data_ptr = malloc(data_size); 00924 memset(data_ptr, 0, data_size); 00925 data = (EnableIdentityMessage_data_t *)data_ptr; 00926 data_ts = (message_data_ts_t *)data_ptr; 00927 add_fieldinfo(IFT_UINT32, "index", 1, &data->index); 00928 add_fieldinfo(IFT_BOOL, "enable", 1, &data->enable); 00929 } 00930 00931 /** Destructor */ 00932 FacerInterface::EnableIdentityMessage::~EnableIdentityMessage() 00933 { 00934 free(data_ptr); 00935 } 00936 00937 /** Copy constructor. 00938 * @param m message to copy from 00939 */ 00940 FacerInterface::EnableIdentityMessage::EnableIdentityMessage(const EnableIdentityMessage *m) : Message("EnableIdentityMessage") 00941 { 00942 data_size = m->data_size; 00943 data_ptr = malloc(data_size); 00944 memcpy(data_ptr, m->data_ptr, data_size); 00945 data = (EnableIdentityMessage_data_t *)data_ptr; 00946 data_ts = (message_data_ts_t *)data_ptr; 00947 } 00948 00949 /* Methods */ 00950 /** Get index value. 00951 * Index of the identity. 00952 * @return index value 00953 */ 00954 uint32_t 00955 FacerInterface::EnableIdentityMessage::index() const 00956 { 00957 return data->index; 00958 } 00959 00960 /** Get maximum length of index value. 00961 * @return length of index value, can be length of the array or number of 00962 * maximum number of characters for a string 00963 */ 00964 size_t 00965 FacerInterface::EnableIdentityMessage::maxlenof_index() const 00966 { 00967 return 1; 00968 } 00969 00970 /** Set index value. 00971 * Index of the identity. 00972 * @param new_index new index value 00973 */ 00974 void 00975 FacerInterface::EnableIdentityMessage::set_index(const uint32_t new_index) 00976 { 00977 data->index = new_index; 00978 } 00979 00980 /** Get enable value. 00981 * En-/disable flag. 00982 * @return enable value 00983 */ 00984 bool 00985 FacerInterface::EnableIdentityMessage::is_enable() const 00986 { 00987 return data->enable; 00988 } 00989 00990 /** Get maximum length of enable value. 00991 * @return length of enable value, can be length of the array or number of 00992 * maximum number of characters for a string 00993 */ 00994 size_t 00995 FacerInterface::EnableIdentityMessage::maxlenof_enable() const 00996 { 00997 return 1; 00998 } 00999 01000 /** Set enable value. 01001 * En-/disable flag. 01002 * @param new_enable new enable value 01003 */ 01004 void 01005 FacerInterface::EnableIdentityMessage::set_enable(const bool new_enable) 01006 { 01007 data->enable = new_enable; 01008 } 01009 01010 /** Clone this message. 01011 * Produces a message of the same type as this message and copies the 01012 * data to the new message. 01013 * @return clone of this message 01014 */ 01015 Message * 01016 FacerInterface::EnableIdentityMessage::clone() const 01017 { 01018 return new FacerInterface::EnableIdentityMessage(this); 01019 } 01020 /** @class FacerInterface::SetNameMessage <interfaces/FacerInterface.h> 01021 * SetNameMessage Fawkes BlackBoard Interface Message. 01022 * 01023 01024 */ 01025 01026 01027 /** Constructor with initial values. 01028 * @param ini_index initial value for index 01029 * @param ini_name initial value for name 01030 */ 01031 FacerInterface::SetNameMessage::SetNameMessage(const uint32_t ini_index, const char * ini_name) : Message("SetNameMessage") 01032 { 01033 data_size = sizeof(SetNameMessage_data_t); 01034 data_ptr = malloc(data_size); 01035 memset(data_ptr, 0, data_size); 01036 data = (SetNameMessage_data_t *)data_ptr; 01037 data_ts = (message_data_ts_t *)data_ptr; 01038 data->index = ini_index; 01039 strncpy(data->name, ini_name, 64); 01040 add_fieldinfo(IFT_UINT32, "index", 1, &data->index); 01041 add_fieldinfo(IFT_STRING, "name", 64, data->name); 01042 } 01043 /** Constructor */ 01044 FacerInterface::SetNameMessage::SetNameMessage() : Message("SetNameMessage") 01045 { 01046 data_size = sizeof(SetNameMessage_data_t); 01047 data_ptr = malloc(data_size); 01048 memset(data_ptr, 0, data_size); 01049 data = (SetNameMessage_data_t *)data_ptr; 01050 data_ts = (message_data_ts_t *)data_ptr; 01051 add_fieldinfo(IFT_UINT32, "index", 1, &data->index); 01052 add_fieldinfo(IFT_STRING, "name", 64, data->name); 01053 } 01054 01055 /** Destructor */ 01056 FacerInterface::SetNameMessage::~SetNameMessage() 01057 { 01058 free(data_ptr); 01059 } 01060 01061 /** Copy constructor. 01062 * @param m message to copy from 01063 */ 01064 FacerInterface::SetNameMessage::SetNameMessage(const SetNameMessage *m) : Message("SetNameMessage") 01065 { 01066 data_size = m->data_size; 01067 data_ptr = malloc(data_size); 01068 memcpy(data_ptr, m->data_ptr, data_size); 01069 data = (SetNameMessage_data_t *)data_ptr; 01070 data_ts = (message_data_ts_t *)data_ptr; 01071 } 01072 01073 /* Methods */ 01074 /** Get index value. 01075 * Index of the identity. 01076 * @return index value 01077 */ 01078 uint32_t 01079 FacerInterface::SetNameMessage::index() const 01080 { 01081 return data->index; 01082 } 01083 01084 /** Get maximum length of index value. 01085 * @return length of index value, can be length of the array or number of 01086 * maximum number of characters for a string 01087 */ 01088 size_t 01089 FacerInterface::SetNameMessage::maxlenof_index() const 01090 { 01091 return 1; 01092 } 01093 01094 /** Set index value. 01095 * Index of the identity. 01096 * @param new_index new index value 01097 */ 01098 void 01099 FacerInterface::SetNameMessage::set_index(const uint32_t new_index) 01100 { 01101 data->index = new_index; 01102 } 01103 01104 /** Get name value. 01105 * Name of the identity. 01106 * @return name value 01107 */ 01108 char * 01109 FacerInterface::SetNameMessage::name() const 01110 { 01111 return data->name; 01112 } 01113 01114 /** Get maximum length of name value. 01115 * @return length of name value, can be length of the array or number of 01116 * maximum number of characters for a string 01117 */ 01118 size_t 01119 FacerInterface::SetNameMessage::maxlenof_name() const 01120 { 01121 return 64; 01122 } 01123 01124 /** Set name value. 01125 * Name of the identity. 01126 * @param new_name new name value 01127 */ 01128 void 01129 FacerInterface::SetNameMessage::set_name(const char * new_name) 01130 { 01131 strncpy(data->name, new_name, sizeof(data->name)); 01132 } 01133 01134 /** Clone this message. 01135 * Produces a message of the same type as this message and copies the 01136 * data to the new message. 01137 * @return clone of this message 01138 */ 01139 Message * 01140 FacerInterface::SetNameMessage::clone() const 01141 { 01142 return new FacerInterface::SetNameMessage(this); 01143 } 01144 /** @class FacerInterface::GetNameMessage <interfaces/FacerInterface.h> 01145 * GetNameMessage Fawkes BlackBoard Interface Message. 01146 * 01147 01148 */ 01149 01150 01151 /** Constructor with initial values. 01152 * @param ini_index initial value for index 01153 */ 01154 FacerInterface::GetNameMessage::GetNameMessage(const uint32_t ini_index) : Message("GetNameMessage") 01155 { 01156 data_size = sizeof(GetNameMessage_data_t); 01157 data_ptr = malloc(data_size); 01158 memset(data_ptr, 0, data_size); 01159 data = (GetNameMessage_data_t *)data_ptr; 01160 data_ts = (message_data_ts_t *)data_ptr; 01161 data->index = ini_index; 01162 add_fieldinfo(IFT_UINT32, "index", 1, &data->index); 01163 } 01164 /** Constructor */ 01165 FacerInterface::GetNameMessage::GetNameMessage() : Message("GetNameMessage") 01166 { 01167 data_size = sizeof(GetNameMessage_data_t); 01168 data_ptr = malloc(data_size); 01169 memset(data_ptr, 0, data_size); 01170 data = (GetNameMessage_data_t *)data_ptr; 01171 data_ts = (message_data_ts_t *)data_ptr; 01172 add_fieldinfo(IFT_UINT32, "index", 1, &data->index); 01173 } 01174 01175 /** Destructor */ 01176 FacerInterface::GetNameMessage::~GetNameMessage() 01177 { 01178 free(data_ptr); 01179 } 01180 01181 /** Copy constructor. 01182 * @param m message to copy from 01183 */ 01184 FacerInterface::GetNameMessage::GetNameMessage(const GetNameMessage *m) : Message("GetNameMessage") 01185 { 01186 data_size = m->data_size; 01187 data_ptr = malloc(data_size); 01188 memcpy(data_ptr, m->data_ptr, data_size); 01189 data = (GetNameMessage_data_t *)data_ptr; 01190 data_ts = (message_data_ts_t *)data_ptr; 01191 } 01192 01193 /* Methods */ 01194 /** Get index value. 01195 * Index of the identity. 01196 * @return index value 01197 */ 01198 uint32_t 01199 FacerInterface::GetNameMessage::index() const 01200 { 01201 return data->index; 01202 } 01203 01204 /** Get maximum length of index value. 01205 * @return length of index value, can be length of the array or number of 01206 * maximum number of characters for a string 01207 */ 01208 size_t 01209 FacerInterface::GetNameMessage::maxlenof_index() const 01210 { 01211 return 1; 01212 } 01213 01214 /** Set index value. 01215 * Index of the identity. 01216 * @param new_index new index value 01217 */ 01218 void 01219 FacerInterface::GetNameMessage::set_index(const uint32_t new_index) 01220 { 01221 data->index = new_index; 01222 } 01223 01224 /** Clone this message. 01225 * Produces a message of the same type as this message and copies the 01226 * data to the new message. 01227 * @return clone of this message 01228 */ 01229 Message * 01230 FacerInterface::GetNameMessage::clone() const 01231 { 01232 return new FacerInterface::GetNameMessage(this); 01233 } 01234 /** Check if message is valid and can be enqueued. 01235 * @param message Message to check 01236 * @return true if the message is valid, false otherwise. 01237 */ 01238 bool 01239 FacerInterface::message_valid(const Message *message) const 01240 { 01241 const LearnFaceMessage *m0 = dynamic_cast<const LearnFaceMessage *>(message); 01242 if ( m0 != NULL ) { 01243 return true; 01244 } 01245 const SetOpmodeMessage *m1 = dynamic_cast<const SetOpmodeMessage *>(message); 01246 if ( m1 != NULL ) { 01247 return true; 01248 } 01249 const EnableIdentityMessage *m2 = dynamic_cast<const EnableIdentityMessage *>(message); 01250 if ( m2 != NULL ) { 01251 return true; 01252 } 01253 const SetNameMessage *m3 = dynamic_cast<const SetNameMessage *>(message); 01254 if ( m3 != NULL ) { 01255 return true; 01256 } 01257 const GetNameMessage *m4 = dynamic_cast<const GetNameMessage *>(message); 01258 if ( m4 != NULL ) { 01259 return true; 01260 } 01261 return false; 01262 } 01263 01264 /// @cond INTERNALS 01265 EXPORT_INTERFACE(FacerInterface) 01266 /// @endcond 01267 01268 01269 } // end namespace fawkes