VAT  3.0
Video Analysis Tool
ReliabilityClassification.h
1 #ifndef __RELIABILITY_CLASSIFICATION__
2 #define __RELIABILITY_CLASSIFICATION__
3 
4 //#include <values.h> values.h? //never heard of it before
5 #include "Classification.h"
6 #include "intervals.h"
7 #include "world_def.h"
8 #include "MobileObject.h"
9 #include "Datapool.h"
10 
11 #define RC_INFINITY DBL_MAX
12 
13 //Class created to manage information concerning the influence of walls of context objects limiting points of the 2D bounding box.
14 //Used to determine the limit of possible growth of a limit of the 2D bounding box (LEFT, RIGHT, TOP or BOTTOM).
15 class inWall {
16  private:
17  world::Wall2D *wall;
18  double enters;
19  double leaves;
20  int entering_type;
21  int leaving_type;
22 
23  public:
24  inWall();
25  inWall(world::Wall2D *i_wall, double i_enters, int i_enter_type, double i_leaves, int i_leave_type);
26  ~inWall();
27  world::Wall2D *getWall();
28  double getEntering();
29  double getLeaving();
30  int getEnteringType();
31  int getLeavingType();
32  //To store entering information as leaving, and viceversa.
33  void reverseOrder();
34  inWall& operator=(const inWall& inwall);
35 };
36 
38  public:
39  //Variables for the user defined static parameters:
40 
41  //Variables for sub-parameters of ordering by pixels.
42  static int RC_MAX_PIXELS; //Maximal number of pixels to be analyzed
43  static int RC_MIN_PIXELS; //Minimal number of pixels to be analyzed
44  static double m_pixelDensity; //Desired rate of pixels to analyze in blob.
45 
46  bool initialized;
47  bool imageWorkingAreaNotComputed;
48 
49 
50  double ALPHA_STEP; //Step to advance in the search of parallelpiped orientation alpha (radians).
51  double H_STEP_CM; //Step to advance in the search of parallelpiped height h (centimeters. Ex: for "5" centimeters, "5" if context defined in centimeters, "0.05" if context defined in meters).
52  int DIM2D_STEP; //pixels step for exploration of new solutions in case of detection problem.
53 
54  bool m_orderByDensity; //Flag that activates ordering of best solutions by maximal number of (TP + TN)/Num_Analyzed_Blob_Pixels. TP (true positives) is the number of moving pixels inside the
55  //contour of the parallelpiped. TN (true negatives) is the number of non-moving pixels outside the contour of the parallelpiped.
56  bool m_treatBorderOcclusion; //Flag that activates the treatment of possible occlusions in the image borders.
57  bool m_treatContextObjectOcclusion; //Flag that activates the treatment of possible occlusions with context objects.
58  bool m_treatWallCoherence; //Flag that activates the verification of walls near to the generated parallelpiped, to check if parallelpiped base is not crossing any wall.
59 
60  int m_rcntop; //Top solutions list length.
61 
62  //Selection criteria for fitting 3d model to a class (intra) and to select the best between clases (inter)
63  //Available:
64  // RC_PROBABILITY: Multiplication of probabilities for parallelpiped dimensions.
65  // RC_RELIABILITY_PROBABILITY: Sum of the reliability times probability for each dimension, all divided by the sumation of reliabilities.
66  // RC_RELIABILITY: Mean reliability of dimensions
67  // RC_DIMENSIONAL: Sum of the length times probability for each dimension, all divided by the sumation of length of dimensions.
68  classificationCriteria m_rcIntraCriteria;
69  classificationCriteria m_rcInterCriteria;
70 
71  //Variables for sub-parameters of wall coherency checking:
72  double m_cuttingAreaRate; //Maximal rate of area the parallelpiped base allowed to be cutted by a limiting wall.
73  double m_wallInsideLengthRate; //Maximal cutting length rate of the wall to be inside the parallelpiped base.
74 
75  int RC_PROXIMITY_PIXELS; //Variable for sub-parameter of context object occlusion. It represents the limit to consider is a blob is near a context object.
76 
77  double m_maxRoofAndBaseIntersectionRatio, m_maxBaseAndBaseIntersectionRatio;
78 
79  double m_minPixelCoverageRatio;
80 
81  //Variables:
82  //Datapool
83  Datapool *m_data;
84 
85  //Scene model
86  SceneModel *m_context;
87  //Pointer to current foreground result
88  QImage *m_foreground;
89 
90  //currentRealDimensionsOfBlobBBox
91  Rectangle<int> realBBox;
92 
93  //Classification Threshold for intra criteria
94  double m_classifThres;
95  //Classification Threshold for inter criteria
96  double m_classifThresInter;
97 
98  //Flag for knowing if parameters setting has been already performed
99  bool m_parametersSet;
100 
101  //Set pertinent walls for each image limit, to be used when determining the maximal possible growth of 2D bounding box limits, in the case of possible border occlusion.
102  std::multimap<DetectionProblemType, world::Wall2D *> m_pertinent_walls;
103 
104  //container of the models found in the context file
105  std::map<ObjectType, SpModelInterface> m_mapModels;
106  std::map<ObjectType, bool> sizeOkForAnalysis;
107  std::map<ObjectType, std::map<ObjectSubtype, bool> > subSizeOkForAnalysis;
108  //classification map by pure probability
109  std::map<int, std::map<ObjectType, double> > m_mapClassif;
110 
111  //For Rigid Object Models
112  //Maps to store the best solutions with and without occlusion.
113  std::map<ObjectType, std::deque<Shape3DData *> > m_top;
114  std::map<ObjectType, std::deque<Shape3DData *> > m_topocc;
115  std::map<ObjectType, int> m_ntop;
116  std::map<ObjectType, int> m_ntopocc;
117 
118  //Best solution without considering min and max limits, for each possible blob type
119  std::map<ObjectType, s3ddata_t> best_valid;
120  std::map<ObjectType, bool> there_is_best_valid;
121  s3ddata_t best_considering_alpha;
122  s3ddata_t best_considering_h;
123  bool best_by_alpha_found, best_by_h_found;
124  double bestAlphaDistance, bestDimDistance;
125  double currentDimDistance;
126  //For Postural Object Models
127  bool currentRigid;
128  //Maps to store the best solutions with and without occlusion.
129  std::map<ObjectType, std::map<ObjectSubtype, std::deque<Shape3DData *> > > m_sub_top;
130  std::map<ObjectType, std::map<ObjectSubtype, std::deque<Shape3DData *> > > m_sub_topocc;
131  std::map<ObjectType, std::map<ObjectSubtype, int> > m_sub_ntop;
132  std::map<ObjectType, std::map<ObjectSubtype, int> > m_sub_ntopocc;
133  //Best solution without considering min and max limits, for each possible blob type
134  std::map<ObjectType, std::map<ObjectSubtype, s3ddata_t> > sub_best_valid;
135  std::map<ObjectType, std::map<ObjectSubtype, bool> > sub_there_is_best_valid;
136 
137  //Current Object Model information
138  SpModelInterface m_currentModel;
139  ObjectType m_modelId;
140  ObjectSubtype m_subModelId;
141 
142  //Variables used for Tracking
143  double *g_postureMinw, *g_postureMinl, *g_postureMinh;
144  double *g_postureMaxw, *g_postureMaxl, *g_postureMaxh;
145  int Winitial, Hinitial;
146  double alphaInit, alphaMobile, alphaChange, alphaVar, hInit, dChange, hVar, hMin, hMax, hMobile, wMobile, lMobile;
147 
148  Interval interval_hmobile;
149 
150  //VARIABLES FOR CONTEXT OBJECTS OCCLUSION
151  //List of not virtual walls of context objects
152  std::deque<world::Wall2D *> real_walls;
153  //List of objects near to blob
154  std::deque<world::ContextObject *> near_objects;
155  //List of objects far from blob
156  std::deque<world::ContextObject *> not_near_objects;
157  //Map of objects and the type of possible occlusion they produce
158  std::map<world::ContextObject *, DetectionProblemType> object_occlusion_type;
159  //When blob size is extended new objects can be near.
160  std::deque<world::ContextObject *> near_objects_extended;
161  //Maps between objects and a map of the analyzed points of the blob with a list of the walls that can limit the growth of a blob.
162  //Four maps defined, one for each object occlusion type.
163 
164  std::map<world::ContextObject *, std::map<int, std::deque<inWall> > > enteredWallsForPointLeft;
165  std::map<world::ContextObject *, std::map<int, std::deque<inWall> > > enteredWallsForPointRight;
166  std::map<world::ContextObject *, std::map<int, std::deque<inWall> > > enteredWallsForPointTop;
167  std::map<world::ContextObject *, std::map<int, std::deque<inWall> > > enteredWallsForPointBottom;
168 
169  //Maps between objects and a map of the analyzed points of the blob with its corresponding value.
170  //Two maps are defined. One for the X 2D coordinates and the other for the Y 2D coordinates.
171  std::map<world::ContextObject *, std::map<int, double> > analyzedPointsForObjectX;
172  std::map<world::ContextObject *, std::map<int, double> > analyzedPointsForObjectY;
173 
174 
175  //Used in Coherency checking, this map stores the potentially conflicting walls with parallelpiped base.
176  std::deque<world::WallSegment *> annoyingWallSegments;
177 
178  double m_HToleranceCoeff, m_VToleranceCoeff; //Tolerance to determine the limits for considering an object out of the FOV.
179  double imgCamx, imgCamy; //Projection of the camera 3D position in the floor of the scene, in image coordinates.
180  double camx, camy, camz; //3D position of the focal point of the camera.
181  int m_XMinWA, m_XMaxWA, m_YMinWA, m_YMaxWA; //Real image limits, according to the tolerance values.
182  double H, W; //2D Dimensions of the blob.
183  double Hmax, Wmax; //Maximal possible blob dimensions, when occlusion occurs.
184  double borderMinLeft, borderMaxRight, borderMinTop, borderMaxBottom; //Limits imposed by border occlusion analysis to the value for each 2D occlusion direction.
185  double objectMinLeft, objectMaxRight, objectMinTop, objectMaxBottom; //Limits imposed by context object occlusion analysis to the value for each 2D occlusion direction.
186  double OcclusionMinLeft, OcclusionMaxRight, OcclusionMinTop, OcclusionMaxBottom; //Global limits to the value for each 2D occlusion direction.
187  bool possible_occlusion; //Flag to signal if any occlusion can happen.
188  double model_hmin, model_hmax, model_hmean, //Currently analyzed expected object model limits and mean for each of its dimensions.
189  model_lmin, model_lmax, model_lmean,
190  model_wmin, model_wmax, model_wmean;
191 
192  Interval interval_modelw, interval_modelh, interval_modell; //Intervalar representation of expected object model dimension limits.
193 
194  double alpha, sina, cosa, beta; //Variables associated to parallelpiped orientation.
195  int beta_direction; //Direction of plane xy of the 3D referential of the scene. (Right or inverted coordinate system)
196  //Counters for display and to detect certain cases where it is not necessary to continue the search of solutions in the case of occlusion.
197  int with_sol_counter, models_calculated_counter, global_models_calculated_counter, valid_models_counter, models_accepted_after_walls_checking;
198 
199 
200  //Values for determining the case of a 3D bounding box. Case 0 is the normal one, and Cases 1 to 4 are special cases.
201  // Case 0: Normal case. Four verteces of the parallelpiped touching a 2D bounding box limit Each of them touch a different 2D limit.
202  // Case 1, 2, 3: A parallelpiped vertex in a corner of the bounding box (touching two 2D limits), and two other touching the remaining two 2D limits. The position of the other verteces touching
203  // the 2D limits with respect to the vertex that touches two limits, defines the Case, between 1, 2, or 3.
204  // Case 4: Two verteces touching two 2D limits each.
205  // a, b, c, d represent the bounding limits of 3D points in the special cases. sp_var stores the position of the first variable
206  // involved in a doble limit (point in a corner of 2D blob).
207  int Case, a, b, c, d, sp_var;
208 
209  //Values for boosting 3D parallelpiped model search.
210  //blob level values, calculated using blob 2D dimensions and information associated to the relative position of the blob with respect to the camera.
211  double V[4][4];
212  double
213  p00, p01, p02, p03,
214  p10, p11, p12, p13,
215  p20, p21, p22, p23;
216  double
217  k1, k2, k3, k4, k5, k6, k7, k8, k9, k10,
218  k11, k12, k13, k14, k15, k16, k17, k18, k19, k20,
219  k21, k22, k23, k24, k25, k26, k27, k28, k29, k30,
220  k31, k32, k33, k34;
221  double Vl0, Vl1, Vl2, Vb0, Vb1, Vb2, Vr0, Vr1, Vr2, Vt0, Vt1, Vt2;
222  double ml0, ml1, mb0, mb1, mr0, mr1, mt0, mt1;
223 
224  //For new simpler classification
225  double
226  KK1, KK2, KK3, KK4,
227  KK5, KK6, KK7, KK8,
228  KK9, KK10, KK11, KK12,
229  KK13, KK14, KK15, KK16;
230  double
231  LL1, LL2, LL3, LL4,
232  LL5, LL6, LL7, LL8,
233  LL9, LL10, LL11, LL12,
234  LL13, LL14, LL15;
235 
236  double DD, MM1, MM2, MM3, MM4, MM5, MM6;
237 
238  //alpha angle level values:
239  double K[22], L[5], C[16];
240 
241  //Equation constants for calculating w and l in terms of h, and viceversa
242  double d1, d2, d3, d4, d5, d6, d7, d8;
243  double wa, wb, wc, la, lb, lc;
244 
245  int
246  position, //Position relative to 2D image projection of camera focal point projected in the xy plane of the world referential of the scene.
247  limits[4][4], // limits[3DBB_POINT][2D_LIMIT] value is 1 if the parallelpiped 3DBB_POINT is bounded by the 2D_LIMIT.
248  //2D_LIMIT = { 0=left, 1=bottom, 2=right, 3= top}
249  //3DBB_POINT = {0, 1, 2, 3}
250  nlimits[4], // nlimits[2D_LIMIT] value correspond to the number of 3DBB_POINTs bounded by 2D_LIMIT. One value different from one correspond to a
251  // special case in 3D bounding box calculation (normally one 3D point bounded by one 2D limit)
252  in_height[4], // in_height[2D_LIMIT] value is 1 if 3DBB_POINT(s) bounded by 2D_LIMIT are bounded in the highest point (h), else 0 (if bounded in their base point (height=0)).
253  BlobLimits[4],// value for each limit in blob in 2D image coordinates (2D_LIMIT = { 0=left, 1=bottom, 2=right, 3= top} );
254  varlimrel[4]; // varlimrel[2D_LIMIT] = 3DBB_POINT indicating the 3DBB_POINT index bounded by the 2D_LIMIT.
255 
256  int eq_relations[4][4]; //Given the existence of two types of equations to relate two variables
257  //this matrix stablishes the types of relations between variables.
258  //0: no relation, 1:equation type 1, 2:equation type 2.
259  bool normalised90;
260  bool normalised180;
261  protected:
262  //Flag for defining if the occlusion list will be created for a blob
263  bool someOcclusionSolutionInserted, someNormalSolutionInserted, aoi_in;
264  //Set object type, occlussion type and 3D bounding box for all blobs
265  void constructClassifMap(std::vector<Blob>&, QImage *);
266 
267  public:
268 
270 
272 
273  double convertAlpha(double original_alpha);
274 
275  double NormalizeAngle(double alpha);
276 
277  //Set pertinent analysis window of the image
278  void computeImageWorkingArea(QImage *i_segm);
279 
280  void initBlob3DData();
281 
282  //Decide for the right limits for all possible growths of a blob, according to all types of occlusion detected and to physical limits imposed by current
283  //analyzed expected object model.
284  void adjustBlobLimitsByOcclusion(Blob *blob);
285 
286  //Determine if there is border occlusion and return the border occlusion type, according to analysis window of the image.
287  DetectionProblemType isBlobOnImageBorder(Blob *blob);
288 
289  //Set object type, occlussion type and 3D bounding box for a blob
290  void setBlob3DFacts(Blob *blob, QImage *i_segm);
291 
292  //Set in blob the data concerning the last 3D parallelpiped analysis performed.
293  void setLastBlobData(double h, double l, double w, double alpha, Blob *blob, bool _90_rotated);
294 
295  //Returns the obtained measured probability value for a possible solution to the parallelpiped determination problem and stores the solution in the list of top
296  //solutions if the new solution is good enough in terms of the probabilistic measure.
297  double set_possible_solution(double w, double l, double h, Blob *blob, bool rotated, bool normal);
298 
299  //Search for parellelepiped solution for different sizes of a blob, according to the detected types of possible occlusions.
300  void fillOcclusionList(Blob *blob);
301 
302  //Search for parallelpiped solutions, changing orientation alpha, for the occlusion case.
303  double static_occlusion_search_alpha(Blob *);
304 
305  //Considering a fixed angle alpha and fixed blob dimensions, search in the space of possible heights h, the best solution, which
306  //accomplish with the limits imposed by the expected object model and the objects in the scene.
307  double search_solution_by_height(Blob *, interval_t, interval_t, bool);
308 
309  //Search for parallelpiped solutions, changing orientation alpha, for the occlusion case.
310  double static_occlusion_search_alpha(Blob *, std::map<ObjectType, SpModelInterface>::iterator);
311 
312  //Considering a fixed angle alpha and fixed blob dimensions, search in the space of possible heights h, the best solution, which
313  //accomplish with the limits imposed by the expected object model and the objects in the scene.
314  double search_solution_by_height(Blob *, std::map<ObjectType, SpModelInterface>::iterator, interval_t, interval_t, bool);
315 
316  //add a class model in the set of all models which have to be classified
317  void addModel(ObjectType, SpModelInterface);
318 
319  //update of classification map
320  void removeBlob(Blob *);
321 
322  //get map of classification
323  inline const std::map<int, std::map<ObjectType, double> >& getClassifMap() const {return m_mapClassif;}
324 
325  //get map of models
326  inline const std::map<ObjectType, SpModelInterface>& getModelsMap() const {return m_mapModels;}
327 
328  SpModelInterface getModelFromType(ObjectType);
329 
330  //Search for the best occluding or not occluding parallelpiped solutions, searching the optimal for different parallelpiped orientation angles and heights, and
331  //different 2D blob dimensions in the case of possible occlusion.
332  void top_probabilities_and_reliabilities(Blob *blob);
333 
334  //Init data structures on Module Load level
335  virtual void init_data();
336 
337  //Top classification map management
338  void top_init();
339 
340  //Eliminates the elements presents in the top lists.
341  void reset_top();
342 
343  //Frees the top lists
344  void free_top();
345 
346 
347  //Check if the quality of a solution allows it to enter to the top list.
348  bool can_be_inserted_top (Blob *blob, bool normalList);
349 
350  //Insert a solution in a top list.
351  s3ddata_t insert_top(Blob *blob, bool normalList);
352 
353  //Function to display the content of a top list.
354  void top_output();
355 
356  void computeGeometricFacts(Blob *blob);
357 
358  virtual ~ReliabilityClassification();
359 
360  virtual void updateScoreForType(Blob *i_blob1, ObjectType i_blobType, double i_score);
361 
362  //Set final object type and detection problem type for a blob
363  void buildClassifTable(Blob *blob);
364 
365  //Set all pertinent calculations that won't change for the given blob 2D dimensions
366  void RC_set_3D_bbox_blob_level_data(Blob *blob);
367 
368  //Set the information considering parallelpiped orientation alpha and blob 2D dimensions as constants.
369  void RC_set_3D_bbox_initial_alpha_level_data(double alpha);
370 
371  //Set the information considering parallelpiped orientation alpha and blob 2D dimensions as constants knowing the type (Case) of parallelpiped
372  //solutions that can be obtained. Normally a parallelpiped has one vertex point on each blob dimension, but there are some degenerate cases
373  //with some vertexes in more than one blob dimension.
374  void RC_set_3D_bbox_alpha_level_data();
375 
376  //Calculate the parallelpiped 3D points according to height and pre-calculated constants.
377  int RC_compute_blob_3Dbbox(Blob *blob, double h);
378 
379  //Set vertical and horizontal advancement in pixel analysis in term of number of pixels, using parameters pre-defined by the end-user.
380  static void setPixelRates(int bwidth, int bheight, double *horRate, double *verRate);
381 
382  //Used after 3D bounding box construction, to store the number of moving or not moving pixels inside or outside the generated parallelpiped.
383  void setPixelAnalysis(Blob *blob, ddata_t ddata, parallelpiped_t _3Dbbox);
384 
385  //Used to store moving pixel blob information, for utilisation in later frames.
386  void setExtraPixelInfo(Blob *blob, ddata_t ddata, QImage *i_segm);
387 
388  //Generate the polygon representing the silhouette of a parallelpiped.
389  static polygon2D<double> *set_polygon_from_3Dbb(parallelpiped_t _3Dbbox, int position);
390 
391  //Gets the index of the nearest base point to a blob 2D limit, between the base points lying between the nearest and the farest base points (middle points).
392  static int get_nearest_from_middle_points(parallelpiped_t _3Dbbox, int limit);
393 
394  //This function orders the top solutions lists in terms of the number of pixels inside the generated parallelpiped.
395  void putBestByPixels(bool occlusion);
396 
397  //Calculates the criteria of comparison between solutions. It corresponds to True positives (moving points inside the parallelpiped) + True negatives (not moving
398  //points out of the parallelpiped), divided by the total number of analyzed pixels.
399  double densityDistance(ddata_t ddata);
400 
401  double check_walls(Blob *blob, DetectionProblemType octype);
402 
403  //Checks if an object is close enough of a context object. If it is the case, it searches to determine the correct context object occlusion type
404  //It also sets the annoying walls of the object, for coherency between 3D parallelpiped base and these walls
405  DetectionProblemType isBlobOccludedByStaticObject(Blob *blob);
406 
407  //Stores the best solution regardless if the solution does not accomplishes with dimensional limits imposed by the currently analyzed expected object model.
408  //This result is used as an starting point by the occlusion treatement part if no real solution have been found.
409  double set_best_without_model_limits(Blob *blob, double w, double l, double h, double alpha);
410 
411  //Returns the probability value for certain parallelpiped dimensions.
412  double getProbability(double h, double l, double w);
413 
414  //Classify the context walls according to their position with respect to blob.
415  void init_pertinent_occlusion_walls();
416 
417  //Set the pertinent maximal vertical blob limits (LEFT and RIGHT), according to limiting context walls
418  void check_walls_ver(Blob *, DetectionProblemType);
419 
420  //Set the pertinent maximal horizontal blob limits (TOP and BOTTOM), according to limiting context walls
421  void check_walls_hor(Blob *, DetectionProblemType);
422 
423  //Checks if the base of a calculated parallelpiped does not collide with a wall in the scene. Pertinent context walls and walls of context objects are analyzed.
424  bool parallelpiped_base_inside_pertinent_walls(Blob *, double, double);
425 
426  //Returns the maximal limit (Wmax or Hmax) for the size of a blob, according to the maximal limits
427  //of dimensions of the expected object in the scen currently processed.
428  double limits_by_max_possible_blob(Blob *, DetectionProblemType);
429 
430  //Obtain the k distant 3D point from other point, according to the slope, the intercept of the line where the new point must be and the direction with respect to
431  //the initial point.
432  void get_xy_k_distant_from_init_point(double *, double *, double, double, double, double, double, double);
433 
434  //Compute 3D height h possible values, given the 3D width w and pre-calculated constants.
435  void RC_compute_h_from_w(double, double *, double *);
436 
437  //Compute 3D height h possible values, given the 3D length l and pre-calculated constants.
438  void RC_compute_h_from_l(double, double *, double *);
439 
440  //Compute 3D width w, given the 3D height h and pre-calculated constants.
441  int RC_compute_w_from_h(double, double *);
442 
443  //Compute 3D length l, given the 3D height h and pre-calculated constants.
444  int RC_compute_l_from_h(double, double *);
445 
446  //Get 3D height h, given the 3D width w and pre-calculated constants, if there is a valid solution.
447  void RC_get_h_from_w(double, double *, double);
448 
449  //Get 3D height h, given the 3D length l and pre-calculated constants, if there is a valid solution.
450  void RC_get_h_from_l(double, double *, double);
451 
452  //Determine which Case of parallelpiped solution is, according to the position of parallelpiped vertexes in the 2D blob limits.
453  int RC_set_3Dbbox_case_and_variable_indexes();
454 
455  //Calculate the four classificationCriteriaals where there can be geometrically valid parallelpipeds to be generated.
456  int calculate_hintervals(interval_t, interval_t);
457  int calculate_hintervals_old(interval_t, interval_t);
458 
459  //Checks if exists vertical or horizontal intersection between two pairs of intervals
460  bool thereIsIntersection(interval_t, interval_t, interval_t, interval_t);
461 
462  //Perform the analysis of nine points in the blob to determine the correct blob occlusion type and the wall segments which will limit the possible growth
463  //of blob dimensions in the case of context object detection problems
464  DetectionProblemType improveObjectAnalysis(world::ContextObject *, DetectionProblemType, Blob *, interval_t, interval_t);
465 
466  //Checks if all possible base points analyzed are inside a context object
467  bool all_possible_base_inside(bool [][3], int);
468 
469  //This function returns the number of points inside a context object. Nine points are analyzed, for three coordinates of x2D and three of y2D.
470  int determine_points_inside_context_object(world::ContextObject *, double *, double *, bool [][3]);
471 
472  //Clear the lists of walls of analyzed blob points which limit the growth of the 2D bounding box in the case of context object occlusion.
473  void clearWallsInPoint();
474 
475  //Set the wall segments that can limit the vertical growth of the blob in case of context object occlusion, for each analyzed point of the blob.
476  void checkPointsInWallVer(world::ContextObject *, double[], double[], DetectionProblemType, world::Wall2D *);
477 
478  //Set the wall segments that can limit the horizontal growth of the blob in case of context object occlusion, for each analyzed point of the blob.
479  void checkPointsInWallHor(world::ContextObject *, double[], double[], DetectionProblemType, world::Wall2D *);
480 
481  //Set the segments intersecting the analyzed points in the different directions of possible growth of the blob in case of context object occlusion.
482  void checkPointsInRoof(world::ContextObject *, double[], double[], QSharedPointer< polygon2D<double> >, DetectionProblemType);
483 
484  //Function to check if intersection between a 2D image coordinates vertical or horizontal line and a 2D segment exists. It also stores the pertinent intersection point
485  //of the free coordinate (if line is vertical the free coordinate is y2d, else the free corrdinate is y2d).
486  bool getIntersectionWithSegment(double, double, double, world::WallSegment *, bool, double&);
487 
488  //Use the information obtained from the limiting walls for analyzed points, to determine if the blob has a real possible of being occluded.
489  DetectionProblemType correctBlobDetectionProblemType(world::ContextObject *, double[], double[], DetectionProblemType);
490 
491  //Calculates the limiting blob growth bounds for all pertinent context object occlusion cases
492  void setObjectOcclusionLimit(Blob *, DetectionProblemType, bool);
493 
494  //Set the potencially colliding context object walls for certain blob 2D dimension, for checking when parallelpiped base is obtained.
495  void setAnnoyingWallsForContextObject(Blob *, world::ContextObject *, bool);
496 
497  //Set the potencially colliding context walls for certain blob 2D dimension, for checking when parallelpiped base is obtained.
498  void setAnnoyingWallsForContextWalls(Blob *, bool);
499 
500  //Checks if an object is close enough of a context object and store it in lists of near or not near objects.
501  void setNearObjects(Blob *);
502 
503  //Add the information of context objects near to the maximized version of the blob, according to calculated dimension growth limits,
504  //when occlusion situations occur.
505  void setMaxBlobNearObjects();
506 
507  //Checks if a blob is inside a visible context wall.
508  bool blobOverContextWalls(Blob *);
509 
510  //Get the projection in a height (the 3D maximal expected object model) for the farest point of the intersection between a segment and a vertical
511  //segment in y2D image coordinates. This projection imposes the softer limit over an analyzed point x2D in image coordinates. Used in the case of
512  //horizontal context object occlusion.
513  double getX2DInHeight(std::map<int, double>, world::Wall2D *, double, bool);
514 
515  //Get the projection in a height (the 3D maximal expected object model) for the farest point of the intersection between a segment and a horizontal
516  //segment in x2D image coordinates. This projection imposes the softer limit over an analyzed point y2D in image coordinates. Used in the case of
517  //vertical context object occlusion.
518  double getY2DInHeight(std::map<int, double>, world::Wall2D *, double, bool);
519 
520  //Returns true if we have found solutions but all of them have collided with a wall.
521  bool noWallsValidatedSolution();
522 
523  void checkBlobSize(Blob *blob);
524  //Version for Reliability Tracking
525  bool checkBlobSize(int &reduced, int &excesive, s3ddata_t s3d, ObjectType type, int position, DetectionProblemType occtype);
526 
527  void checkSubModelsSize( int &reduced, int &excesive, SpModelInterface objectModel, ObjectType modelType, Blob *blob);
528  //Version for Reliability Tracking
529  void checkSubModelsSize( int &reduced, int &excesive, SpModelInterface objectModel, ObjectType modelType, s3ddata_t s3d, int position, DetectionProblemType occtype);
530 
531  int checkIfBlobIsReducedSize(Blob *blob, double hmin, double lmin, double wmin);
532  //Version for Reliability Tracking
533  int checkIfBlobIsReducedSize(s3ddata_t s3d, double hmin, double lmin, double wmin, int position);
534 
535  int checkIfBlobIsExcesiveSize(Blob *blob, double hmax, double lmax, double wmax);
536  //Version for Reliability Tracking
537  int checkIfBlobIsExcesiveSize(s3ddata_t s3d, double hmax, double lmax, double wmax, int position);
538 
539  //Quicksort
540  static void orderBlobsAscending(double *values, Blob **blobs, int top, int bottom);
541 
542  static int getMiddle(double *values, Blob **blobs, int top, int bottom);
543 
544  //Functions used by tracking and pre-tracking modules
545  Shape3DData *getMostCoherentDataFromMobileAndBBoxLimit(MobileObject *mobile, std::map<ObjectType, Shape3DData> *&normal,
546  std::map<ObjectType, Shape3DData> *&occ, Blob *blob);
547  void getMostCoherentDataFromMobile(s3ddata_t bests3d, MobileObject *mobile, DetectionProblemType occtype, Blob *blob);
548 
549  void setPostureLimits(ObjectType type);
550 
551  bool reliability_tracking_search_alpha(Blob *blob);
552 
553  double search_solution_by_height_for_tracking(Blob *blob, interval_t interval_h, double previous_best);
554 
555  double set_possible_solution_for_tracking(double w, double l, double h, Blob *blob, double current_best);
556 
557  int calculate_hintervals_for_tracking(interval_t interval_h_0);
558  int calculate_hintervals_for_tracking_old(interval_t interval_h_0);
559 
560  bool set_best_valid_alpha_for_tracking();
561 
562  void limits_by_mean_model_values(double *mean_limits, double *starting_angles, Blob *blob, DetectionProblemType octype);
563 
564  void fillOcclusionListWithStartingPoints(Blob *blob);
565 
566  void static_occlusion_search_2D(double *mean_limits, double *starting_angles, Blob *blob, DetectionProblemType occtype, double dim_limit);
567 
568  double static_occlusion_search_alpha_with_starting_point(Blob *blob, double& starting_alpha);
569 
570  void limits_by_mean_model_values_bottom_occlusion(double *mean_limits, double *mean_left_limits, double *mean_right_limits,
571  double *starting_angles, Blob *blob, bool with_left_occlusion,
572  Rectangle<int> *mean_bboxes, parallelpiped_t meanparallelpipeds);
573 
574  void fillOcclusionListWithStartingPoints2(Blob *blob);
575 
576  int RC_set_3Dbbox_case_and_variable_indexes_simpler(Blob *blob);
577  int RC_compute_blob_3Dbbox_get_case(Blob *blob);
578 
579  void RC_set_3D_bbox_alpha_level_data_get_case();
580 
581  void RC_set_3D_bbox_alpha_level_data_simpler();
582 
583  int calculate_hintervals_simpler(interval_t interval_h_0, interval_t interval_h_90);
584 
585  int RC_compute_blob_3Dbbox_simpler(Blob *blob, double h);
586 
587  void static_occlusion_bottom_search_2D_in_corner(double *mean_limits, double *mean_left_limits, double *mean_right_limits,
588  double *starting_angles, Blob *blob, DetectionProblemType ver_occtype,
589  DetectionProblemType hor_occtype, double ver_dim_limit, double hor_dim_limit);
590 
591  bool not_over_an_object(parallelpiped_t par, bool not_occluded);
592 
593  bool covering_bbox(Blob *blob);
594 
595  bool covering_bbox(int blob_position, Blob *blob, ddata_t ddata, parallelpiped_t _3Dbbox);
596 
597  void setPixelAnalysis(int blob_position, Blob *blob, ddata_t ddata, parallelpiped_t _3Dbbox);
598 
599  void prepareBlobForRClassification(Blob *blob, QImage *i_segm);
600 
601  void setDPForBlob(Blob *blob, QImage *i_segm);
602 
603  s3ddata_t getMostLikelyDataFromMobile(Blob *blob, ObjectType type);
604 
605  s3ddata_t getMostLikelyDataForType(Blob *blob);
606 
607  s3ddata_t generateS3DListsForBlob(Blob *blob, ObjectType analyzed_type);
608 
609  s3ddata_t addBestDataForType(bool normal, Blob *blob, ObjectType analyzed_type, std::map<ObjectType, Shape3DData> *s3d_list, s3ddata_t data);
610 
611  std::map<ObjectType, Shape3DData> *getBestOnesList(bool normal, Shape3DData **best_s3d, double *best, bool *exists3d, Blob *i_blob);
612 
613  void setExtraPixelInfo(Blob *blob, QImage *i_segm);
614 
615  bool positiveAngleDirection(double beta, double angle);
616 
617  bool allowed_base_dimensions(double w, double l);
618 
619  bool setParameters(QDomNode& config);
620 
621  bool defaultParameters();
622 
623  void classify(std::vector<Blob>& i_blobs, QImage *i_segm);
624 
625  bool parallelpipedBaseOnAOIGround(Parallelpiped *par, SceneModel *context);
626 
627  bool blobOnAOIGround(Blob *i_blob, SceneModel *context);
628 
629  void assignTypeToBlob(Blob *i_blob);
630 
631  bool prepareRun();
632 
633  bool init();
634 
635  bool checkIfBetter(double *best, Shape3DData *s3d);
636 
637  bool changeBlobTypeToUnknown(Blob *i_blob);
638 
639 };
640 
641 typedef QSharedPointer<ReliabilityClassification> SpReliabilityClassification;
642 
643 #endif
644 
645 
Definition: world_def.h:197
Definition: ReliabilityClassification.h:15
Definition: intervals.h:8
Definition: parallelpiped.h:8
Definition: blob.h:34
Definition: calibration.h:51
Definition: ReliabilityClassification.h:37
Definition: world_def.h:275
Definition: world_def.h:240
Definition: blob.h:19
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: blob.h:79
Definition: geometric.h:224
Definition: BackgroundRecLigth.h:20
Definition: MobileObject.h:101