VAT  3.0
Video Analysis Tool
LearningAttributesSpecification.h
1 #ifndef LEARNING_ATTRIBUTES_SPECIFICATION_H
2 #define LEARNING_ATTRIBUTES_SPECIFICATION_H
3 
4 #include "RMMT/RMMMobileObject.h" //Class representing a tracked mobile object
5 typedef SpRMMMobileObject SpMObject;
6 
7 class Datapool;
8 
9 #include <map>
10 #include <set>
11 #include <deque>
12 #include <string>
13 
14 namespace miles {
15 
16 //File for defining new attributes for event learning: Search for the word Step for Knowing what to include... :D
17 //ATTENTION!! The Steps must be properly accomplished for a correct consideration of the attribute.
18 
19 //Prototype function pointers
20 typedef double (*fp_getDouble)(SpMObject, Datapool&);
21 typedef std::string (*fp_getString)(SpMObject, Datapool&);
22 typedef std::set<std::string> *(*fp_setSymValues)();
23 
24 //Step 1. First define a new entry in the enum list of attribute ids, regardless if type is numerical or symbolic
25 enum attribute_id {
26  LA_X,
27  LA_Y,
28  LA_VX,
29  LA_VY,
30  LA_V2D,
31  LA_W,
32  LA_H,
33  LA_VW,
34  LA_VH,
35  LA_DKITCHEN, //Distance of the object to the context object "kitchen"
36  LA_DTABLE, //Distance of the object to the context object "table"
37  LA_DSOFA, //Distance of the object to the context object "sofa"
38  LA_SKITCHEN, //Symbolic distance of the object to the context object "kitchen"
39  LA_STABLE, //Symbolic distance of the object to the context object "table"
40  LA_SSOFA, //Symbolic distance of the object to the context object "sofa"
41  LA_HX, //Homography X position
42  LA_HY, //Homography Y position
43  LA_DEGU_CORNER, //Symbolic position of DEGU in corners.
44 };
45 
46 
47 //Predefine every class to avoid cyclic reference problems
48 class LearningContextualisedObject;
49 class XMLTreeGenerator;
50 class LearningAttributes;
51 class LearningStateConcept;
52 class LearningEventConcept;
53 class LearningContext;
54 class HierarchyTree;
55 class LevelData;
56 class ContextualisedNumericalData;
57 class ContextualisedSymbolicData;
58 class NumericalAttributeValuePair;
59 class SymbolicAttributeValuePair;
60 
61 typedef QSharedPointer<LearningContextualisedObject> SpLearningContextualisedObject;
62 typedef QSharedPointer<XMLTreeGenerator> SpXMLTreeGenerator;
63 typedef QSharedPointer<LearningAttributes> SpLearningAttributes;
64 typedef QSharedPointer<LearningStateConcept> SpLearningStateConcept;
65 typedef QSharedPointer<LearningEventConcept> SpLearningEventConcept;
66 typedef QSharedPointer<LearningContext> SpLearningContext;
67 typedef QSharedPointer<HierarchyTree> SpHierarchyTree;
68 typedef QSharedPointer<LevelData> SpLevelData;
69 typedef QSharedPointer<ContextualisedNumericalData> SpContextualisedNumericalData;
70 typedef QSharedPointer<ContextualisedSymbolicData> SpContextualisedSymbolicData;
71 typedef QSharedPointer<NumericalAttributeValuePair> SpNumericalAttributeValuePair;
72 typedef QSharedPointer<SymbolicAttributeValuePair> SpSymbolicAttributeValuePair;
73 
74 
75 
76 // Step 2: Define the class interface specification for the attribute (follow examples).
77 // Make only prototypes, the implementation goes in file: CLearningAttributesSpecification.cpp
78 
79 //Specification for numerical attributes:
80 
81 //2D Spatial Attributes
82 class HX {
83 public:
84  static double getValue(SpMObject mobile, Datapool& datapool);
85  static double getReliability(SpMObject mobile, Datapool& datapool);
86 };
87 
88 class HY {
89 public:
90  static double getValue(SpMObject mobile, Datapool& datapool);
91  static double getReliability(SpMObject mobile, Datapool& datapool);
92 };
93 
94 
95  //2D Spatial Attributes
96  class X {
97  public:
98  static double getValue(SpMObject mobile, Datapool& datapool);
99  static double getReliability(SpMObject mobile, Datapool& datapool);
100  };
101 
102  class Y {
103  public:
104  static double getValue(SpMObject mobile, Datapool& datapool);
105  static double getReliability(SpMObject mobile, Datapool& datapool);
106  };
107 
108  class VX {
109  public:
110  static double getValue(SpMObject mobile, Datapool& datapool);
111  static double getReliability(SpMObject mobile, Datapool& datapool);
112  };
113 
114  class VY {
115  public:
116  static double getValue(SpMObject mobile, Datapool& datapool);
117  static double getReliability(SpMObject mobile, Datapool& datapool);
118  };
119 
120  class V2D {
121  public:
122  static double getValue(SpMObject mobile, Datapool& datapool);
123  static double getReliability(SpMObject mobile, Datapool& datapool);
124  };
125 
126  //2D Dimensional Attributes
127  class W {
128  public:
129  static double getValue(SpMObject mobile, Datapool& datapool);
130  static double getReliability(SpMObject mobile, Datapool& datapool);
131  };
132 
133  class H {
134  public:
135  static double getValue(SpMObject mobile, Datapool& datapool);
136  static double getReliability(SpMObject mobile, Datapool& datapool);
137  };
138 
139  class VW {
140  public:
141  static double getValue(SpMObject mobile, Datapool& datapool);
142  static double getReliability(SpMObject mobile, Datapool& datapool);
143  };
144 
145  class VH {
146  public:
147  static double getValue(SpMObject mobile, Datapool& datapool);
148  static double getReliability(SpMObject mobile, Datapool& datapool);
149  };
150 
151 
152 
153  class DKITCHEN { //Distance of the object to the context object "kitchen"
154  public:
155  static double getValue(SpMObject mobile, Datapool& datapool);
156  static double getReliability(SpMObject mobile, Datapool& datapool);
157  };
158 
159  class DTABLE { //Distance of the object to the context object "table"
160  public:
161  static double getValue(SpMObject mobile, Datapool& datapool);
162  static double getReliability(SpMObject mobile, Datapool& datapool);
163  };
164 
165  class DSOFA { //Distance of the object to the context object "sofa"
166  public:
167  static double getValue(SpMObject mobile, Datapool& datapool);
168  static double getReliability(SpMObject mobile, Datapool& datapool);
169  };
170 
171  //Specification for symbolic attributes:
172  class DEGU_CORNER { //Symbolic distance of the object to the context object "kitchen"
173  public:
174  static std::set<std::string> values;
175  static bool checked, valid;
176  static std::map< std::string, QSharedPointer<world::ZoneH> > zones;
177  static std::string getValue(SpMObject mobile, Datapool& datapool);
178  static double getReliability(SpMObject mobile, Datapool& datapool);
179  static std::set<std::string> *setAllowedValues();
180  };
181 
182 
183  class SKITCHEN { //Symbolic distance of the object to the context object "kitchen"
184  public:
185  static std::set<std::string> values;
186  static std::string getValue(SpMObject mobile, Datapool& datapool);
187  static double getReliability(SpMObject mobile, Datapool& datapool);
188  static std::set<std::string> *setAllowedValues();
189  };
190 
191  class STABLE { //Symbolic distance of the object to the context object "table"
192  public:
193  static std::set<std::string> values;
194  static std::string getValue(SpMObject mobile, Datapool& datapool);
195  static double getReliability(SpMObject mobile, Datapool& datapool);
196  static std::set<std::string> *setAllowedValues();
197  };
198 
199  class SSOFA { //Symbolic distance of the object to the context object "sofa"
200  public:
201  static std::set<std::string> values;
202  static std::string getValue(SpMObject mobile, Datapool& datapool);
203  static double getReliability(SpMObject mobile, Datapool& datapool);
204  static std::set<std::string> *setAllowedValues();
205  };
206 
207 
208  //Class summarising all the attribute specifications
210  public:
212  ~LearningAttributes(){}
213  //General lists of data extraction functions
214  std::map<attribute_id, std::string> nameFromId;
215  std::map<std::string, attribute_id> idFromName;
216 
217  std::set<std::string> availableNumerical;
218  std::set<std::string> availableSymbolic;
219 
220  std::map<attribute_id, fp_getDouble> getValueNumeric;
221  std::map<attribute_id, fp_getDouble> getReliability;
222  std::map<attribute_id, fp_getString> getValueSymbolic;
223  std::map<attribute_id, std::set<std::string>*> symbolicValuesList;
224 
225  void setNumericalAttribute(attribute_id i_id, std::string i_name, fp_getDouble getValueFunction, fp_getDouble getReliabilityFunction) {
226  availableNumerical.insert(i_name);
227  nameFromId[i_id] = i_name;
228  idFromName[i_name] = i_id;
229  getValueNumeric[i_id] = getValueFunction;
230  getReliability[i_id] = getReliabilityFunction;
231  }
232 
233  void setSymbolicAttribute(attribute_id i_id, std::string i_name, fp_getString getValueFunction, fp_getDouble getReliabilityFunction, fp_setSymValues setSymbolicValues) {
234  availableSymbolic.insert(i_name);
235  nameFromId[i_id] = i_name;
236  idFromName[i_name] = i_id;
237  getValueSymbolic[i_id] = getValueFunction;
238  getReliability[i_id] = getReliabilityFunction;
239  symbolicValuesList[i_id] = (*setSymbolicValues)();
240  }
241 
242  //Step 3. Insert the specification of the attribute.
243 
244  // In this function, define the numerical attributes:
245  // the id defined in Step 1, the name to link with predefined learning contexts,
246  // the function for getting the attribute value from data,
247  // and the function for getting the attribute's reliability from data,
248  void setNumericalAttributes() {
249  setNumericalAttribute(LA_X, "X", &X::getValue, &X::getReliability);
250  setNumericalAttribute(LA_Y, "Y", &Y::getValue, &Y::getReliability);
251  setNumericalAttribute(LA_HX, "HX", &HX::getValue, &HX::getReliability);
252  setNumericalAttribute(LA_HY, "HY", &HY::getValue, &HY::getReliability);
253  setNumericalAttribute(LA_VX, "VX", &VX::getValue, &VX::getReliability);
254  setNumericalAttribute(LA_VY, "VY", &VY::getValue, &VY::getReliability);
255  setNumericalAttribute(LA_V2D,"V2D",&V2D::getValue, &V2D::getReliability);
256  setNumericalAttribute(LA_W, "W", &W::getValue, &W::getReliability);
257  setNumericalAttribute(LA_H, "H", &H::getValue, &H::getReliability);
258  setNumericalAttribute(LA_VW, "VW", &VW::getValue, &VW::getReliability);
259  setNumericalAttribute(LA_VH, "VH", &VH::getValue, &VH::getReliability);
260  setNumericalAttribute(LA_DKITCHEN, "DKITCHEN", &DKITCHEN::getValue, &DKITCHEN::getReliability);
261  setNumericalAttribute(LA_DTABLE, "DTABLE", &DTABLE::getValue, &DTABLE::getReliability);
262  setNumericalAttribute(LA_DSOFA, "DSOFA", &DSOFA::getValue, &DSOFA::getReliability);
263  }
264 
265  // In this function, define the symbolic attributes:
266  // the id defined in Step 1, the name to link with predefined learning contexts,
267  // the function for getting the attribute value from data,
268  // the function for getting the attribute's reliability from data,
269  // and the function setting and returning the list of valid symbolic attribute values
270  void setSymbolicAttributes() {
271  setSymbolicAttribute(LA_SKITCHEN, "SKITCHEN", &SKITCHEN::getValue, &SKITCHEN::getReliability, &SKITCHEN::setAllowedValues);
272  setSymbolicAttribute(LA_STABLE, "STABLE", &STABLE::getValue, &STABLE::getReliability, &STABLE::setAllowedValues);
273  setSymbolicAttribute(LA_SSOFA, "SSOFA", &SSOFA::getValue, &SSOFA::getReliability, &SSOFA::setAllowedValues);
274  setSymbolicAttribute(LA_DEGU_CORNER, "DEGU_CORNER",&DEGU_CORNER::getValue, &DEGU_CORNER::getReliability, &DEGU_CORNER::setAllowedValues);
275  }
276  };
277 
278  typedef QSharedPointer<LearningAttributes> SpLearningAttributes;
279 
280 } // end namespace
281 
282 #endif
Definition: LearningAttributesSpecification.h:120
Definition: LearningAttributesSpecification.h:145
Definition: LearningAttributesSpecification.h:102
Definition: LearningAttributesSpecification.h:209
Definition: LearningAttributesSpecification.h:199
Definition: LearningAttributesSpecification.h:165
Definition: LearningAttributesSpecification.h:133
Definition: LearningAttributesSpecification.h:172
Definition: LearningAttributesSpecification.h:114
Definition: LearningAttributesSpecification.h:88
Definition: LearningAttributesSpecification.h:108
Definition: LearningAttributesSpecification.h:82
Definition: LearningAttributesSpecification.h:127
An object of this class is instantiated at main code, and this object is used by every class to push ...
Definition: Datapool.h:39
Definition: LearningAttributesSpecification.h:191
Definition: LearningAttributesSpecification.h:139
Definition: LearningAttributesSpecification.h:159
Definition: LearningAttributesSpecification.h:153
Definition: LearningAttributesSpecification.h:96
Definition: LearningAttributesSpecification.h:183
Definition: HierarchyTree.cpp:12