Fawkes API  Fawkes Development Version
FacerInterface.cpp
1 
2 /***************************************************************************
3  * FacerInterface.cpp - 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 #include <interfaces/FacerInterface.h>
25 
26 #include <core/exceptions/software.h>
27 
28 #include <cstring>
29 #include <cstdlib>
30 
31 namespace fawkes {
32 
33 /** @class FacerInterface <interfaces/FacerInterface.h>
34  * FacerInterface Fawkes BlackBoard Interface.
35  *
36  The interface provides access to the face recognition plugin
37  (facer). It provides basic status information about facer and
38  allows for setting a specific mode and access the resolut.
39  calling skills via messages. It can also be used to manually
40  restart the Lua interpreter if something is wedged.
41 
42  * @ingroup FawkesInterfaces
43  */
44 
45 
46 
47 /** Constructor */
48 FacerInterface::FacerInterface() : Interface()
49 {
50  data_size = sizeof(FacerInterface_data_t);
51  data_ptr = malloc(data_size);
52  data = (FacerInterface_data_t *)data_ptr;
53  data_ts = (interface_data_ts_t *)data_ptr;
54  memset(data_ptr, 0, data_size);
55  add_fieldinfo(IFT_ENUM, "opmode", 1, &data->opmode);
56  add_fieldinfo(IFT_UINT32, "num_identities", 1, &data->num_identities, "");
57  add_fieldinfo(IFT_UINT32, "recognized_identity", 1, &data->recognized_identity, "");
58  add_fieldinfo(IFT_STRING, "recognized_name", 64, data->recognized_name, "");
59  add_fieldinfo(IFT_UINT32, "num_detections", 1, &data->num_detections, "");
60  add_fieldinfo(IFT_UINT32, "num_recognitions", 1, &data->num_recognitions, "");
61  add_fieldinfo(IFT_UINT32, "most_likely_identity", 1, &data->most_likely_identity, "");
62  add_fieldinfo(IFT_FLOAT, "history_ratio", 1, &data->history_ratio, "");
63  add_fieldinfo(IFT_FLOAT, "sec_since_detection", 1, &data->sec_since_detection, "");
64  add_fieldinfo(IFT_INT32, "visibility_history", 1, &data->visibility_history, "");
65  add_fieldinfo(IFT_BOOL, "learning_in_progress", 1, &data->learning_in_progress, "");
66  add_fieldinfo(IFT_FLOAT, "recording_progress", 1, &data->recording_progress, "");
67  add_fieldinfo(IFT_FLOAT, "bearing", 1, &data->bearing, "");
68  add_fieldinfo(IFT_FLOAT, "slope", 1, &data->slope, "");
69  add_fieldinfo(IFT_UINT32, "requested_index", 1, &data->requested_index, "");
70  add_fieldinfo(IFT_STRING, "requested_name", 64, data->requested_name, "");
71  add_messageinfo("LearnFaceMessage");
72  add_messageinfo("SetOpmodeMessage");
73  add_messageinfo("EnableIdentityMessage");
74  add_messageinfo("SetNameMessage");
75  add_messageinfo("GetNameMessage");
76  unsigned char tmp_hash[] = {0xe1, 0x12, 0xd2, 0x51, 0x1d, 0x24, 0x1b, 0x27, 0x86, 0xce, 0x29, 0x32, 0xd6, 0x5a, 0x5e, 0xb3};
77  set_hash(tmp_hash);
78 }
79 
80 /** Destructor */
81 FacerInterface::~FacerInterface()
82 {
83  free(data_ptr);
84 }
85 /** Convert if_facer_opmode_t constant to string.
86  * @param value value to convert to string
87  * @return constant value as string.
88  */
89 const char *
91 {
92  switch (value) {
93  case OPMODE_DISABLED: return "OPMODE_DISABLED";
94  case OPMODE_DETECTION: return "OPMODE_DETECTION";
95  case OPMODE_RECOGNITION: return "OPMODE_RECOGNITION";
96  case OPMODE_LEARNING: return "OPMODE_LEARNING";
97  default: return "UNKNOWN";
98  }
99 }
100 /* Methods */
101 /** Get opmode value.
102  *
103  Current opmode.
104 
105  * @return opmode value
106  */
109 {
110  return (FacerInterface::if_facer_opmode_t)data->opmode;
111 }
112 
113 /** Get maximum length of opmode value.
114  * @return length of opmode value, can be length of the array or number of
115  * maximum number of characters for a string
116  */
117 size_t
119 {
120  return 1;
121 }
122 
123 /** Set opmode value.
124  *
125  Current opmode.
126 
127  * @param new_opmode new opmode value
128  */
129 void
131 {
132  data->opmode = new_opmode;
133  data_changed = true;
134 }
135 
136 /** Get num_identities value.
137  *
138  The number of identities in the database.
139 
140  * @return num_identities value
141  */
142 uint32_t
144 {
145  return data->num_identities;
146 }
147 
148 /** Get maximum length of num_identities value.
149  * @return length of num_identities value, can be length of the array or number of
150  * maximum number of characters for a string
151  */
152 size_t
154 {
155  return 1;
156 }
157 
158 /** Set num_identities value.
159  *
160  The number of identities in the database.
161 
162  * @param new_num_identities new num_identities value
163  */
164 void
165 FacerInterface::set_num_identities(const uint32_t new_num_identities)
166 {
167  data->num_identities = new_num_identities;
168  data_changed = true;
169 }
170 
171 /** Get recognized_identity value.
172  *
173  The index of the recognized identity.
174 
175  * @return recognized_identity value
176  */
177 uint32_t
179 {
180  return data->recognized_identity;
181 }
182 
183 /** Get maximum length of recognized_identity value.
184  * @return length of recognized_identity value, can be length of the array or number of
185  * maximum number of characters for a string
186  */
187 size_t
189 {
190  return 1;
191 }
192 
193 /** Set recognized_identity value.
194  *
195  The index of the recognized identity.
196 
197  * @param new_recognized_identity new recognized_identity value
198  */
199 void
200 FacerInterface::set_recognized_identity(const uint32_t new_recognized_identity)
201 {
202  data->recognized_identity = new_recognized_identity;
203  data_changed = true;
204 }
205 
206 /** Get recognized_name value.
207  *
208  The name of the recognized identity.
209 
210  * @return recognized_name value
211  */
212 char *
214 {
215  return data->recognized_name;
216 }
217 
218 /** Get maximum length of recognized_name value.
219  * @return length of recognized_name value, can be length of the array or number of
220  * maximum number of characters for a string
221  */
222 size_t
224 {
225  return 64;
226 }
227 
228 /** Set recognized_name value.
229  *
230  The name of the recognized identity.
231 
232  * @param new_recognized_name new recognized_name value
233  */
234 void
235 FacerInterface::set_recognized_name(const char * new_recognized_name)
236 {
237  strncpy(data->recognized_name, new_recognized_name, sizeof(data->recognized_name));
238  data_changed = true;
239 }
240 
241 /** Get num_detections value.
242  *
243  Number of currently detected faces.
244 
245  * @return num_detections value
246  */
247 uint32_t
249 {
250  return data->num_detections;
251 }
252 
253 /** Get maximum length of num_detections value.
254  * @return length of num_detections value, can be length of the array or number of
255  * maximum number of characters for a string
256  */
257 size_t
259 {
260  return 1;
261 }
262 
263 /** Set num_detections value.
264  *
265  Number of currently detected faces.
266 
267  * @param new_num_detections new num_detections value
268  */
269 void
270 FacerInterface::set_num_detections(const uint32_t new_num_detections)
271 {
272  data->num_detections = new_num_detections;
273  data_changed = true;
274 }
275 
276 /** Get num_recognitions value.
277  *
278  Number of recognized faces.
279 
280  * @return num_recognitions value
281  */
282 uint32_t
284 {
285  return data->num_recognitions;
286 }
287 
288 /** Get maximum length of num_recognitions value.
289  * @return length of num_recognitions value, can be length of the array or number of
290  * maximum number of characters for a string
291  */
292 size_t
294 {
295  return 1;
296 }
297 
298 /** Set num_recognitions value.
299  *
300  Number of recognized faces.
301 
302  * @param new_num_recognitions new num_recognitions value
303  */
304 void
305 FacerInterface::set_num_recognitions(const uint32_t new_num_recognitions)
306 {
307  data->num_recognitions = new_num_recognitions;
308  data_changed = true;
309 }
310 
311 /** Get most_likely_identity value.
312  *
313  The identity that was recognized most prevalently.
314 
315  * @return most_likely_identity value
316  */
317 uint32_t
319 {
320  return data->most_likely_identity;
321 }
322 
323 /** Get maximum length of most_likely_identity value.
324  * @return length of most_likely_identity value, can be length of the array or number of
325  * maximum number of characters for a string
326  */
327 size_t
329 {
330  return 1;
331 }
332 
333 /** Set most_likely_identity value.
334  *
335  The identity that was recognized most prevalently.
336 
337  * @param new_most_likely_identity new most_likely_identity value
338  */
339 void
340 FacerInterface::set_most_likely_identity(const uint32_t new_most_likely_identity)
341 {
342  data->most_likely_identity = new_most_likely_identity;
343  data_changed = true;
344 }
345 
346 /** Get history_ratio value.
347  *
348  The ratio of the most likely identity showing up in the history
349  and the length of the history.
350 
351  * @return history_ratio value
352  */
353 float
355 {
356  return data->history_ratio;
357 }
358 
359 /** Get maximum length of history_ratio value.
360  * @return length of history_ratio value, can be length of the array or number of
361  * maximum number of characters for a string
362  */
363 size_t
365 {
366  return 1;
367 }
368 
369 /** Set history_ratio value.
370  *
371  The ratio of the most likely identity showing up in the history
372  and the length of the history.
373 
374  * @param new_history_ratio new history_ratio value
375  */
376 void
377 FacerInterface::set_history_ratio(const float new_history_ratio)
378 {
379  data->history_ratio = new_history_ratio;
380  data_changed = true;
381 }
382 
383 /** Get sec_since_detection value.
384  *
385  Time in seconds since the last successful detection.
386 
387  * @return sec_since_detection value
388  */
389 float
391 {
392  return data->sec_since_detection;
393 }
394 
395 /** Get maximum length of sec_since_detection value.
396  * @return length of sec_since_detection value, can be length of the array or number of
397  * maximum number of characters for a string
398  */
399 size_t
401 {
402  return 1;
403 }
404 
405 /** Set sec_since_detection value.
406  *
407  Time in seconds since the last successful detection.
408 
409  * @param new_sec_since_detection new sec_since_detection value
410  */
411 void
412 FacerInterface::set_sec_since_detection(const float new_sec_since_detection)
413 {
414  data->sec_since_detection = new_sec_since_detection;
415  data_changed = true;
416 }
417 
418 /** Get visibility_history value.
419  *
420  The number of consecutive sighting ( <= 1 ) and non-sightings
421  ( >= -1 ), respectively.
422 
423  * @return visibility_history value
424  */
425 int32_t
427 {
428  return data->visibility_history;
429 }
430 
431 /** Get maximum length of visibility_history value.
432  * @return length of visibility_history value, can be length of the array or number of
433  * maximum number of characters for a string
434  */
435 size_t
437 {
438  return 1;
439 }
440 
441 /** Set visibility_history value.
442  *
443  The number of consecutive sighting ( <= 1 ) and non-sightings
444  ( >= -1 ), respectively.
445 
446  * @param new_visibility_history new visibility_history value
447  */
448 void
449 FacerInterface::set_visibility_history(const int32_t new_visibility_history)
450 {
451  data->visibility_history = new_visibility_history;
452  data_changed = true;
453 }
454 
455 /** Get learning_in_progress value.
456  *
457  Indicates whether a new identity is currently learnt. If
458  learning is in progress only "old" faces can be recognized.
459 
460  * @return learning_in_progress value
461  */
462 bool
464 {
465  return data->learning_in_progress;
466 }
467 
468 /** Get maximum length of learning_in_progress value.
469  * @return length of learning_in_progress value, can be length of the array or number of
470  * maximum number of characters for a string
471  */
472 size_t
474 {
475  return 1;
476 }
477 
478 /** Set learning_in_progress value.
479  *
480  Indicates whether a new identity is currently learnt. If
481  learning is in progress only "old" faces can be recognized.
482 
483  * @param new_learning_in_progress new learning_in_progress value
484  */
485 void
486 FacerInterface::set_learning_in_progress(const bool new_learning_in_progress)
487 {
488  data->learning_in_progress = new_learning_in_progress;
489  data_changed = true;
490 }
491 
492 /** Get recording_progress value.
493  *
494  Indicates the progress of recording images of a new face.
495 
496  * @return recording_progress value
497  */
498 float
500 {
501  return data->recording_progress;
502 }
503 
504 /** Get maximum length of recording_progress value.
505  * @return length of recording_progress value, can be length of the array or number of
506  * maximum number of characters for a string
507  */
508 size_t
510 {
511  return 1;
512 }
513 
514 /** Set recording_progress value.
515  *
516  Indicates the progress of recording images of a new face.
517 
518  * @param new_recording_progress new recording_progress value
519  */
520 void
521 FacerInterface::set_recording_progress(const float new_recording_progress)
522 {
523  data->recording_progress = new_recording_progress;
524  data_changed = true;
525 }
526 
527 /** Get bearing value.
528  *
529  The relative bearing to the recognized face in radians.
530 
531  * @return bearing value
532  */
533 float
535 {
536  return data->bearing;
537 }
538 
539 /** Get maximum length of bearing value.
540  * @return length of bearing value, can be length of the array or number of
541  * maximum number of characters for a string
542  */
543 size_t
545 {
546  return 1;
547 }
548 
549 /** Set bearing value.
550  *
551  The relative bearing to the recognized face in radians.
552 
553  * @param new_bearing new bearing value
554  */
555 void
556 FacerInterface::set_bearing(const float new_bearing)
557 {
558  data->bearing = new_bearing;
559  data_changed = true;
560 }
561 
562 /** Get slope value.
563  *
564  The relative slope to the recognized face in radians.
565 
566  * @return slope value
567  */
568 float
570 {
571  return data->slope;
572 }
573 
574 /** Get maximum length of slope value.
575  * @return length of slope value, can be length of the array or number of
576  * maximum number of characters for a string
577  */
578 size_t
580 {
581  return 1;
582 }
583 
584 /** Set slope value.
585  *
586  The relative slope to the recognized face in radians.
587 
588  * @param new_slope new slope value
589  */
590 void
591 FacerInterface::set_slope(const float new_slope)
592 {
593  data->slope = new_slope;
594  data_changed = true;
595 }
596 
597 /** Get requested_index value.
598  *
599  Index of the identity for which the name was requested.
600 
601  * @return requested_index value
602  */
603 uint32_t
605 {
606  return data->requested_index;
607 }
608 
609 /** Get maximum length of requested_index value.
610  * @return length of requested_index value, can be length of the array or number of
611  * maximum number of characters for a string
612  */
613 size_t
615 {
616  return 1;
617 }
618 
619 /** Set requested_index value.
620  *
621  Index of the identity for which the name was requested.
622 
623  * @param new_requested_index new requested_index value
624  */
625 void
626 FacerInterface::set_requested_index(const uint32_t new_requested_index)
627 {
628  data->requested_index = new_requested_index;
629  data_changed = true;
630 }
631 
632 /** Get requested_name value.
633  *
634  Requested name.
635 
636  * @return requested_name value
637  */
638 char *
640 {
641  return data->requested_name;
642 }
643 
644 /** Get maximum length of requested_name value.
645  * @return length of requested_name value, can be length of the array or number of
646  * maximum number of characters for a string
647  */
648 size_t
650 {
651  return 64;
652 }
653 
654 /** Set requested_name value.
655  *
656  Requested name.
657 
658  * @param new_requested_name new requested_name value
659  */
660 void
661 FacerInterface::set_requested_name(const char * new_requested_name)
662 {
663  strncpy(data->requested_name, new_requested_name, sizeof(data->requested_name));
664  data_changed = true;
665 }
666 
667 /* =========== message create =========== */
668 Message *
670 {
671  if ( strncmp("LearnFaceMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
672  return new LearnFaceMessage();
673  } else if ( strncmp("SetOpmodeMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
674  return new SetOpmodeMessage();
675  } else if ( strncmp("EnableIdentityMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
676  return new EnableIdentityMessage();
677  } else if ( strncmp("SetNameMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
678  return new SetNameMessage();
679  } else if ( strncmp("GetNameMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
680  return new GetNameMessage();
681  } else {
682  throw UnknownTypeException("The given type '%s' does not match any known "
683  "message type for this interface type.", type);
684  }
685 }
686 
687 
688 /** Copy values from other interface.
689  * @param other other interface to copy values from
690  */
691 void
693 {
694  const FacerInterface *oi = dynamic_cast<const FacerInterface *>(other);
695  if (oi == NULL) {
696  throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
697  type(), other->type());
698  }
699  memcpy(data, oi->data, sizeof(FacerInterface_data_t));
700 }
701 
702 const char *
703 FacerInterface::enum_tostring(const char *enumtype, int val) const
704 {
705  if (strcmp(enumtype, "if_facer_opmode_t") == 0) {
706  return tostring_if_facer_opmode_t((if_facer_opmode_t)val);
707  }
708  throw UnknownTypeException("Unknown enum type %s", enumtype);
709 }
710 
711 /* =========== messages =========== */
712 /** @class FacerInterface::LearnFaceMessage <interfaces/FacerInterface.h>
713  * LearnFaceMessage Fawkes BlackBoard Interface Message.
714  *
715 
716  */
717 
718 
719 /** Constructor with initial values.
720  * @param ini_name initial value for name
721  */
722 FacerInterface::LearnFaceMessage::LearnFaceMessage(const char * ini_name) : Message("LearnFaceMessage")
723 {
724  data_size = sizeof(LearnFaceMessage_data_t);
725  data_ptr = malloc(data_size);
726  memset(data_ptr, 0, data_size);
727  data = (LearnFaceMessage_data_t *)data_ptr;
729  strncpy(data->name, ini_name, 64);
730  add_fieldinfo(IFT_STRING, "name", 64, data->name, "");
731 }
732 /** Constructor */
734 {
735  data_size = sizeof(LearnFaceMessage_data_t);
736  data_ptr = malloc(data_size);
737  memset(data_ptr, 0, data_size);
738  data = (LearnFaceMessage_data_t *)data_ptr;
740  add_fieldinfo(IFT_STRING, "name", 64, data->name, "");
741 }
742 
743 /** Destructor */
745 {
746  free(data_ptr);
747 }
748 
749 /** Copy constructor.
750  * @param m message to copy from
751  */
753 {
754  data_size = m->data_size;
755  data_ptr = malloc(data_size);
756  memcpy(data_ptr, m->data_ptr, data_size);
757  data = (LearnFaceMessage_data_t *)data_ptr;
759 }
760 
761 /* Methods */
762 /** Get name value.
763  * The name assigned to the new identity.
764  * @return name value
765  */
766 char *
768 {
769  return data->name;
770 }
771 
772 /** Get maximum length of name value.
773  * @return length of name value, can be length of the array or number of
774  * maximum number of characters for a string
775  */
776 size_t
778 {
779  return 64;
780 }
781 
782 /** Set name value.
783  * The name assigned to the new identity.
784  * @param new_name new name value
785  */
786 void
788 {
789  strncpy(data->name, new_name, sizeof(data->name));
790 }
791 
792 /** Clone this message.
793  * Produces a message of the same type as this message and copies the
794  * data to the new message.
795  * @return clone of this message
796  */
797 Message *
799 {
800  return new FacerInterface::LearnFaceMessage(this);
801 }
802 /** @class FacerInterface::SetOpmodeMessage <interfaces/FacerInterface.h>
803  * SetOpmodeMessage Fawkes BlackBoard Interface Message.
804  *
805 
806  */
807 
808 
809 /** Constructor with initial values.
810  * @param ini_opmode initial value for opmode
811  */
813 {
814  data_size = sizeof(SetOpmodeMessage_data_t);
815  data_ptr = malloc(data_size);
816  memset(data_ptr, 0, data_size);
817  data = (SetOpmodeMessage_data_t *)data_ptr;
819  data->opmode = ini_opmode;
820  add_fieldinfo(IFT_ENUM, "opmode", 1, &data->opmode);
821 }
822 /** Constructor */
824 {
825  data_size = sizeof(SetOpmodeMessage_data_t);
826  data_ptr = malloc(data_size);
827  memset(data_ptr, 0, data_size);
828  data = (SetOpmodeMessage_data_t *)data_ptr;
830  add_fieldinfo(IFT_ENUM, "opmode", 1, &data->opmode);
831 }
832 
833 /** Destructor */
835 {
836  free(data_ptr);
837 }
838 
839 /** Copy constructor.
840  * @param m message to copy from
841  */
843 {
844  data_size = m->data_size;
845  data_ptr = malloc(data_size);
846  memcpy(data_ptr, m->data_ptr, data_size);
847  data = (SetOpmodeMessage_data_t *)data_ptr;
849 }
850 
851 /* Methods */
852 /** Get opmode value.
853  *
854  Current opmode.
855 
856  * @return opmode value
857  */
860 {
861  return (FacerInterface::if_facer_opmode_t)data->opmode;
862 }
863 
864 /** Get maximum length of opmode value.
865  * @return length of opmode value, can be length of the array or number of
866  * maximum number of characters for a string
867  */
868 size_t
870 {
871  return 1;
872 }
873 
874 /** Set opmode value.
875  *
876  Current opmode.
877 
878  * @param new_opmode new opmode value
879  */
880 void
882 {
883  data->opmode = new_opmode;
884 }
885 
886 /** Clone this message.
887  * Produces a message of the same type as this message and copies the
888  * data to the new message.
889  * @return clone of this message
890  */
891 Message *
893 {
894  return new FacerInterface::SetOpmodeMessage(this);
895 }
896 /** @class FacerInterface::EnableIdentityMessage <interfaces/FacerInterface.h>
897  * EnableIdentityMessage Fawkes BlackBoard Interface Message.
898  *
899 
900  */
901 
902 
903 /** Constructor with initial values.
904  * @param ini_index initial value for index
905  * @param ini_enable initial value for enable
906  */
907 FacerInterface::EnableIdentityMessage::EnableIdentityMessage(const uint32_t ini_index, const bool ini_enable) : Message("EnableIdentityMessage")
908 {
909  data_size = sizeof(EnableIdentityMessage_data_t);
910  data_ptr = malloc(data_size);
911  memset(data_ptr, 0, data_size);
912  data = (EnableIdentityMessage_data_t *)data_ptr;
914  data->index = ini_index;
915  data->enable = ini_enable;
916  add_fieldinfo(IFT_UINT32, "index", 1, &data->index, "");
917  add_fieldinfo(IFT_BOOL, "enable", 1, &data->enable, "");
918 }
919 /** Constructor */
921 {
922  data_size = sizeof(EnableIdentityMessage_data_t);
923  data_ptr = malloc(data_size);
924  memset(data_ptr, 0, data_size);
925  data = (EnableIdentityMessage_data_t *)data_ptr;
927  add_fieldinfo(IFT_UINT32, "index", 1, &data->index, "");
928  add_fieldinfo(IFT_BOOL, "enable", 1, &data->enable, "");
929 }
930 
931 /** Destructor */
933 {
934  free(data_ptr);
935 }
936 
937 /** Copy constructor.
938  * @param m message to copy from
939  */
941 {
942  data_size = m->data_size;
943  data_ptr = malloc(data_size);
944  memcpy(data_ptr, m->data_ptr, data_size);
945  data = (EnableIdentityMessage_data_t *)data_ptr;
947 }
948 
949 /* Methods */
950 /** Get index value.
951  * Index of the identity.
952  * @return index value
953  */
954 uint32_t
956 {
957  return data->index;
958 }
959 
960 /** Get maximum length of index value.
961  * @return length of index value, can be length of the array or number of
962  * maximum number of characters for a string
963  */
964 size_t
966 {
967  return 1;
968 }
969 
970 /** Set index value.
971  * Index of the identity.
972  * @param new_index new index value
973  */
974 void
976 {
977  data->index = new_index;
978 }
979 
980 /** Get enable value.
981  * En-/disable flag.
982  * @return enable value
983  */
984 bool
986 {
987  return data->enable;
988 }
989 
990 /** Get maximum length of enable value.
991  * @return length of enable value, can be length of the array or number of
992  * maximum number of characters for a string
993  */
994 size_t
996 {
997  return 1;
998 }
999 
1000 /** Set enable value.
1001  * En-/disable flag.
1002  * @param new_enable new enable value
1003  */
1004 void
1006 {
1007  data->enable = new_enable;
1008 }
1009 
1010 /** Clone this message.
1011  * Produces a message of the same type as this message and copies the
1012  * data to the new message.
1013  * @return clone of this message
1014  */
1015 Message *
1017 {
1018  return new FacerInterface::EnableIdentityMessage(this);
1019 }
1020 /** @class FacerInterface::SetNameMessage <interfaces/FacerInterface.h>
1021  * SetNameMessage Fawkes BlackBoard Interface Message.
1022  *
1023 
1024  */
1025 
1026 
1027 /** Constructor with initial values.
1028  * @param ini_index initial value for index
1029  * @param ini_name initial value for name
1030  */
1031 FacerInterface::SetNameMessage::SetNameMessage(const uint32_t ini_index, const char * ini_name) : Message("SetNameMessage")
1032 {
1033  data_size = sizeof(SetNameMessage_data_t);
1034  data_ptr = malloc(data_size);
1035  memset(data_ptr, 0, data_size);
1036  data = (SetNameMessage_data_t *)data_ptr;
1038  data->index = ini_index;
1039  strncpy(data->name, ini_name, 64);
1040  add_fieldinfo(IFT_UINT32, "index", 1, &data->index, "");
1041  add_fieldinfo(IFT_STRING, "name", 64, data->name, "");
1042 }
1043 /** Constructor */
1045 {
1046  data_size = sizeof(SetNameMessage_data_t);
1047  data_ptr = malloc(data_size);
1048  memset(data_ptr, 0, data_size);
1049  data = (SetNameMessage_data_t *)data_ptr;
1051  add_fieldinfo(IFT_UINT32, "index", 1, &data->index, "");
1052  add_fieldinfo(IFT_STRING, "name", 64, data->name, "");
1053 }
1054 
1055 /** Destructor */
1057 {
1058  free(data_ptr);
1059 }
1060 
1061 /** Copy constructor.
1062  * @param m message to copy from
1063  */
1065 {
1066  data_size = m->data_size;
1067  data_ptr = malloc(data_size);
1068  memcpy(data_ptr, m->data_ptr, data_size);
1069  data = (SetNameMessage_data_t *)data_ptr;
1071 }
1072 
1073 /* Methods */
1074 /** Get index value.
1075  * Index of the identity.
1076  * @return index value
1077  */
1078 uint32_t
1080 {
1081  return data->index;
1082 }
1083 
1084 /** Get maximum length of index value.
1085  * @return length of index value, can be length of the array or number of
1086  * maximum number of characters for a string
1087  */
1088 size_t
1090 {
1091  return 1;
1092 }
1093 
1094 /** Set index value.
1095  * Index of the identity.
1096  * @param new_index new index value
1097  */
1098 void
1100 {
1101  data->index = new_index;
1102 }
1103 
1104 /** Get name value.
1105  * Name of the identity.
1106  * @return name value
1107  */
1108 char *
1110 {
1111  return data->name;
1112 }
1113 
1114 /** Get maximum length of name value.
1115  * @return length of name value, can be length of the array or number of
1116  * maximum number of characters for a string
1117  */
1118 size_t
1120 {
1121  return 64;
1122 }
1123 
1124 /** Set name value.
1125  * Name of the identity.
1126  * @param new_name new name value
1127  */
1128 void
1130 {
1131  strncpy(data->name, new_name, sizeof(data->name));
1132 }
1133 
1134 /** Clone this message.
1135  * Produces a message of the same type as this message and copies the
1136  * data to the new message.
1137  * @return clone of this message
1138  */
1139 Message *
1141 {
1142  return new FacerInterface::SetNameMessage(this);
1143 }
1144 /** @class FacerInterface::GetNameMessage <interfaces/FacerInterface.h>
1145  * GetNameMessage Fawkes BlackBoard Interface Message.
1146  *
1147 
1148  */
1149 
1150 
1151 /** Constructor with initial values.
1152  * @param ini_index initial value for index
1153  */
1154 FacerInterface::GetNameMessage::GetNameMessage(const uint32_t ini_index) : Message("GetNameMessage")
1155 {
1156  data_size = sizeof(GetNameMessage_data_t);
1157  data_ptr = malloc(data_size);
1158  memset(data_ptr, 0, data_size);
1159  data = (GetNameMessage_data_t *)data_ptr;
1161  data->index = ini_index;
1162  add_fieldinfo(IFT_UINT32, "index", 1, &data->index, "");
1163 }
1164 /** Constructor */
1166 {
1167  data_size = sizeof(GetNameMessage_data_t);
1168  data_ptr = malloc(data_size);
1169  memset(data_ptr, 0, data_size);
1170  data = (GetNameMessage_data_t *)data_ptr;
1172  add_fieldinfo(IFT_UINT32, "index", 1, &data->index, "");
1173 }
1174 
1175 /** Destructor */
1177 {
1178  free(data_ptr);
1179 }
1180 
1181 /** Copy constructor.
1182  * @param m message to copy from
1183  */
1185 {
1186  data_size = m->data_size;
1187  data_ptr = malloc(data_size);
1188  memcpy(data_ptr, m->data_ptr, data_size);
1189  data = (GetNameMessage_data_t *)data_ptr;
1191 }
1192 
1193 /* Methods */
1194 /** Get index value.
1195  * Index of the identity.
1196  * @return index value
1197  */
1198 uint32_t
1200 {
1201  return data->index;
1202 }
1203 
1204 /** Get maximum length of index value.
1205  * @return length of index value, can be length of the array or number of
1206  * maximum number of characters for a string
1207  */
1208 size_t
1210 {
1211  return 1;
1212 }
1213 
1214 /** Set index value.
1215  * Index of the identity.
1216  * @param new_index new index value
1217  */
1218 void
1220 {
1221  data->index = new_index;
1222 }
1223 
1224 /** Clone this message.
1225  * Produces a message of the same type as this message and copies the
1226  * data to the new message.
1227  * @return clone of this message
1228  */
1229 Message *
1231 {
1232  return new FacerInterface::GetNameMessage(this);
1233 }
1234 /** Check if message is valid and can be enqueued.
1235  * @param message Message to check
1236  * @return true if the message is valid, false otherwise.
1237  */
1238 bool
1240 {
1241  const LearnFaceMessage *m0 = dynamic_cast<const LearnFaceMessage *>(message);
1242  if ( m0 != NULL ) {
1243  return true;
1244  }
1245  const SetOpmodeMessage *m1 = dynamic_cast<const SetOpmodeMessage *>(message);
1246  if ( m1 != NULL ) {
1247  return true;
1248  }
1249  const EnableIdentityMessage *m2 = dynamic_cast<const EnableIdentityMessage *>(message);
1250  if ( m2 != NULL ) {
1251  return true;
1252  }
1253  const SetNameMessage *m3 = dynamic_cast<const SetNameMessage *>(message);
1254  if ( m3 != NULL ) {
1255  return true;
1256  }
1257  const GetNameMessage *m4 = dynamic_cast<const GetNameMessage *>(message);
1258  if ( m4 != NULL ) {
1259  return true;
1260  }
1261  return false;
1262 }
1263 
1264 /// @cond INTERNALS
1265 EXPORT_INTERFACE(FacerInterface)
1266 /// @endcond
1267 
1268 
1269 } // end namespace fawkes
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.
void * data_ptr
Pointer to memory that contains local data.
Definition: message.h:114
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.
void set_hash(unsigned char *ihash)
Set hash.
Definition: interface.cpp:312
SetNameMessage Fawkes BlackBoard Interface Message.
Fawkes library namespace.
Timestamp data, must be present and first entries for each interface data structs! This leans on time...
Definition: message.h:119
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.
string field
Definition: types.h:45
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.
message_data_ts_t * data_ts
data timestamp aliasing pointer
Definition: message.h:123
void set_visibility_history(const int32_t new_visibility_history)
Set visibility_history value.
unsigned int data_size
Size of memory needed to hold all data.
Definition: message.h:115
size_t maxlenof_requested_index() const
Get maximum length of requested_index value.
void add_messageinfo(const char *name)
Add an entry to the message info list.
Definition: interface.cpp:368
bool data_changed
Indicator if data has changed.
Definition: interface.h:208
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.
void * data_ptr
Pointer to local memory storage.
Definition: interface.h:206
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.
float field
Definition: types.h:43
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.
32 bit integer field
Definition: types.h:39
void set_bearing(const float new_bearing)
Set bearing value.
size_t maxlenof_num_identities() const
Get maximum length of num_identities value.
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.
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0)
Add an entry to the info list.
Definition: message.cpp:435
uint32_t index() const
Get index value.
void set_history_ratio(const float new_history_ratio)
Set history_ratio value.
boolean field
Definition: types.h:34
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.
32 bit unsigned integer field
Definition: types.h:40
field with interface specific enum type
Definition: types.h:47
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.