00001 00030 #ifndef _FACEDETECTOR_H 00031 #define _FACEDETECTOR_H 00032 #include <WritableType.H> 00033 #include <Capability.H> 00034 #include <COMObject.H> 00035 #include <queue> 00036 #include <vector> 00037 00038 // $Id: Type.H 66 2007-01-23 20:53:23Z fwph $ 00039 00040 #define FACEDETECTOR "FaceDetector" 00041 // IDNUMBER is used to identify data events . IDNUMBER+1 is the info event. this 00042 // system will probably go away soon... 00043 //#define FACEDETECTORIDNUMBER 6 00044 00045 namespace WURDE { 00046 class Capability; 00047 class CommsManager; 00048 class Logger; 00049 00050 00051 class FaceLocation { 00052 public: int width; 00053 Point origin; 00054 Point centroid; 00055 int height; 00056 }; 00057 00058 00059 class FaceDetectorInfoStruct { 00060 public: std::string source; 00061 std::string target; 00062 Time timestamp; 00063 MessageType mType; 00064 }; 00065 00066 00067 class FaceDetectorDataStruct { 00068 public: std::vector< FaceLocation > foundFaces; 00069 std::string source; 00070 Time timestamp; 00071 }; 00072 00078 class FaceDetector : virtual public Capability { 00079 00080 public: 00086 explicit FaceDetector(const std::string & streamname); 00087 00093 FaceDetector(const ConnectionStrategy & strategy,const std::string & gblName); 00094 00100 FaceDetector(const std::string & streamname,const std::string & gblName); 00101 00102 ~FaceDetector(); 00103 00104 00108 void init(const std::string & streamname,const ConnectionStrategy & strategy, const std::string & gblName); 00109 00110 00115 FaceDetectorDataStruct data; 00116 00120 FaceDetectorInfoStruct info; 00121 00125 FaceDetectorInfoStruct requests; 00126 00127 //RobotObject imps 00128 void runUpdate(); 00129 void setManager(CommsManager *myManager_); 00130 void setCOMObject(COMBase *object){ myCOMObject = dynamic_cast<COMObject<FaceDetectorInfoStruct,FaceDetectorDataStruct> *> (object);} 00131 void disconnect(){if(myCOMObject){myCOMObject->disconnect();}} 00132 void activateSupplier(); 00133 void activateConsumer(); 00134 std::string getInterfaceName(){ return FACEDETECTOR;} 00135 void setStreamName(const std::string & name); 00136 void setGlobalName(const std::string & name); 00137 bool newData(); 00138 bool newInfo(); 00139 void setAutoPing(const bool & val); 00140 void doPing(); 00141 // int getID(){return FACEDETECTORIDNUMBER;} 00142 00146 bool getQueueMode(){return m_queue;}; 00147 00151 void setQueueMode(const bool & val); 00152 00157 FaceDetectorDataStruct getNextData(); 00158 00163 FaceDetectorInfoStruct getNextInfo(); 00164 00168 FaceDetectorInfoStruct getNextRequest(){return getNextInfo();} 00169 00170 void publishData(); 00171 void publishInfo(); 00172 //void publishRequest(); 00173 00174 protected: 00175 COMObject<FaceDetectorInfoStruct, FaceDetectorDataStruct> *myCOMObject; 00176 00177 bool m_queue; 00178 00179 //notes that the object should be initialized as soon as a streamname is received 00180 bool m_initialize; 00181 std::queue<FaceDetectorDataStruct> m_dataVector; 00182 std::queue<FaceDetectorInfoStruct> m_infoVector; 00183 std::queue<FaceDetectorInfoStruct> m_requestVector; 00184 00185 }; 00186 00187 } 00188 00189 00190 #endif