1 #ifndef __MOBILE_OBJECT_H__ 2 #define __MOBILE_OBJECT_H__ 5 #include "calibration.h" 6 #include "parallelpiped.h" 7 #include "ModelInterface.h" 8 #include "MobileObject2D.h" 9 #include "trajectory.h" 15 #define MOBILE_DEBUG_DATA 16 #define MOBILE_DETAILS 17 #define SHOW_BLOB_BUFFER 21 double prevCooling2D, sumCooling2D, prevCooling3D, sumCooling3D;
22 double totalNumClassified;
27 double alphaEstimated, sumRDalpha, sumRDValpha;
29 double wEstimated, sumRDw, sumRDVw, sumPw;
30 double lEstimated, sumRDl, sumRDVl, sumPl;
31 double hEstimated, sumRDh, sumRDVh, sumPh;
33 double sumRDxy, sumRDVxy, sumPxy, sumPVxy, xEstimated, yEstimated;
41 double alpha, RDalpha, RCalpha, Ralpha, SDalpha;
42 double Valpha, RDValpha, RCValpha, RValpha, SDValpha;
44 double w, Pw, Rw, RCw, RDw, SDw;
45 double l, Pl, Rl, RCl, RDl, SDl;
46 double h, Ph, Rh, RCh, RDh, SDh;
48 double Vw, RVw, RCVw, RDVw, SDVw;
49 double Vl, RVl, RCVl, RDVl, SDVl;
50 double Vh, RVh, RCVh, RDVh, SDVh;
57 double x, SDx, Rx, RCx;
58 double y, SDy, Ry, RCy;
62 double Vx, SDVx, RVx, RCVx;
63 double Vy, SDVy, RVy, RCVy;
72 double theta, SDtheta;
79 IncrementalExtraGeneralData iGData;
80 IncrementalExtra3DData i3DData;
81 tracking3DimensionalData t3DDimData;
82 tracking3DSpatialData t3DSpatialData;
85 typedef struct info3D info3D;
91 typedef QSharedPointer<MobileObject> SpMobileObject;
94 bool operator()(SpMobileObject mobile1, SpMobileObject mobile2);
98 bool operator()(SpMobileObject mobile1, SpMobileObject mobile2);
104 static double ONE_OVER_SQRT_2_TIMES_PI;
108 static QImage *m_pSegmentation;
109 static double m_maxSpeed;
110 static double m_maxKnownSpeed;
112 static int m_currentTrackingBlobsNumber;
113 static double m_lambda;
114 static int m_blobsBufferSize;
115 static int m_trajectoryMaxSize;
116 static double m_knownSolutionThreshold;
118 static std::map<ObjectType, bool> rigidModel;
119 static std::map<ObjectType, int> objectModelMap;
120 static std::map<ObjectType, std::map<ObjectSubtype, int> > objectSubModelMap;
121 static SpModelInterface *objectModelsList;
122 static SpModelInterface **objectSubModelsList;
124 static double **objectSubModelMinWidth;
125 static double **objectSubModelMeanWidth;
126 static double **objectSubModelMaxWidth;
127 static double **objectSubModelMinLength;
128 static double **objectSubModelMeanLength;
129 static double **objectSubModelMaxLength;
130 static double **objectSubModelMinHeight;
131 static double **objectSubModelMeanHeight;
132 static double **objectSubModelMaxHeight;
133 static double **objectSubModelMinVelocity;
134 static double **objectSubModelMeanVelocity;
135 static double **objectSubModelMaxVelocity;
137 static double *objectModelMinWidth;
138 static double *objectModelMeanWidth;
139 static double *objectModelMaxWidth;
140 static double *objectModelMinLength;
141 static double *objectModelMeanLength;
142 static double *objectModelMaxLength;
143 static double *objectModelMinHeight;
144 static double *objectModelMeanHeight;
145 static double *objectModelMaxHeight;
146 static double *objectModelMinVelocity;
147 static double *objectModelMeanVelocity;
148 static double *objectModelMaxVelocity;
150 static int m_objectModelsNumber;
151 static bool m_firstFrame;
152 static int m_numberOfPostures;
154 static double m_SpatialCoherenceReliabilityThreshold;
155 static double m_SpatialCoherenceProbabilityThreshold;
156 static double m_DimensionalCoherenceReliabilityThreshold;
157 static double m_DimensionalCoherenceProbabilityThreshold;
158 static double m_MinimalHistoryProbability;
159 static double m_Maximal3DDimensionChangeSpeed;
161 static std::map<ObjectType, ObjectSubtype> lastFoundSubtypeTemplate;
164 static double m_classifThreshold;
165 static double m_maximalAlphaRotationSpeed;
167 static double *secDiffSequence;
168 static double *secDiffToCurrent;
169 static double *coolingValue;
171 static double m_maxFocalDistance;
172 static double m_objectSizeForMaxReliability;
173 static double m_objectDimensionForMaxReliability;
174 static double m_objectDistanceForMaxReliability;
176 static double *g_postureMinw, *g_postureMinl, *g_postureMinh;
177 static double *g_postureMeanw, *g_postureMeanl, *g_postureMeanh;
178 static double *g_postureMaxw, *g_postureMaxl, *g_postureMaxh;
179 static ObjectSubtype *g_posturesList;
181 static double m_probabilityToEnsureMode;
182 static int m_2DLevelFrames;
184 static double *g_secDiffSequence;
185 static double *g_coolingValue;
186 static double *g_secDiffToCurrent;
189 static IncrementalExtraGeneralData *g_iGData;
192 static double *g_newVisualSupport;
193 static DetectionProblemType *g_newDPFlags;
194 static int g_currentBufferSize;
195 static double zeroTolerance;
196 static double m_minimalTolerance;
199 unsigned long mobile_id;
200 unsigned long rmobile_id;
201 ObjectType best_type;
202 ObjectSubtype best_subtype;
215 bool lastUnknown, *lastKnownPerType;
217 int numberOfFramesNotSeen, numberOfFramesSinceFirstTimeSeen;
218 int previousBufferSize;
219 int currentBufferSize;
224 double *visualSupport;
225 DetectionProblemType *dpFlags;
226 DetectionProblemType currentVisualState;
227 bool *classifiedS3ds;
233 int numberOfClassifiedS3ds, numberOfFoundS3ds;
234 double RKnownSolutions, RVKnownSolutions;
235 double RFoundSolutions, RVFoundSolutions;
243 double current_min_w_model;
244 double current_max_w_model;
245 double current_min_l_model;
246 double current_max_l_model;
247 double current_min_h_model;
248 double current_max_h_model;
249 double current_min_velocity_model;
250 double current_max_velocity_model;
253 tracking3DimensionalData t3DDimData;
255 tracking3DSpatialData t3DSpatialData;
258 IncrementalExtraGeneralData iGData;
260 IncrementalExtra3DData i3DData;
274 bool accepted_solution;
275 std::map<ObjectType, ObjectSubtype> lastFoundSubtype;
277 bool classificationAllowed;
286 void initUsedBlobs();
287 void initInvolvedBlobs();
290 void insertNewBlob(
Blob *blob);
291 void insertNewBlob(
Blob *blob,
int lastMilliSecondsDifference);
294 void setMobileId(
unsigned long i_id);
295 void setRMobileId(
unsigned long i_id);
296 void setNewMobileFromBlob(
Blob *blob,
unsigned long mobile_id,
unsigned long rmobile_id);
297 void setNumberOfFramesNotSeen(
int num);
298 void incrementNumberOfFramesNotSeen();
299 void incrementNumberOfFramesSinceFirstTimeSeen();
300 void setGlobalProbability();
301 Blob *determineMostLikelyBlob();
303 unsigned long getMobileId();
304 unsigned long getRMobileId();
305 ObjectType getBestType();
306 ObjectSubtype getBestSubType();
307 int getNumberOfFramesNotSeen();
308 int getNumberOfFramesSinceFirstTimeSeen();
309 double getGlobalProbability();
312 static double NormalizeOrientation(
double);
313 static double minimalAngularDistance(
double alpha1,
double alpha2);
314 static double NormalizeVelocityAngle(
double);
315 static double coolingFunction(
double x);
317 void velocityMagnitudeAccordingToModels(
Shape3DData *s3d);
318 double velocityAngleAccordingToEntranceToScene(
Shape3DData *s3d);
321 void updateMobilePath(
Blob *blob);
322 void updateMobileData();
324 double DimensionalCoherenceReliability(
double sigma_dim,
double min,
double max);
327 friend std::ostream& operator<<(std::ostream&, SpMobileObject);
330 Shape3DData **getS3DBufferToAnalyze(ObjectType type);
331 Shape3DData **getS3DBufferToAnalyzeByIndex(
int index);
332 Shape3DData *getS3DToAnalyze(ObjectType type,
int frame);
333 Shape3DData *getS3DToAnalyzeByIndex(
int index,
int frame);
334 void setS3DToAnalyzeByIndex(
int index,
int frame,
Shape3DData *s3d);
335 void insertS3DToAnalyzeByIndex(
int index,
Shape3DData *s3d);
337 Shape3DData *getRightS3D(std::map<ObjectType, Shape3DData> *list, ObjectType type);
338 Shape3DData *getBestPostureCoherentS3DReclassifying(
Blob *blob, std::map<ObjectType, Shape3DData> *normal,
339 std::map<ObjectType, Shape3DData> *occ, ObjectType type);
341 double dimensional2DReliability(
double distance2D,
double blobW,
double blobH);
342 double position2DReliability(
double distance2D);
344 double get2DDistanceToFocalPoint(
Blob *blob);
346 double get2DDistanceToFocalPoint(
double X,
double Y);
348 bool mobile3DCoherenceIsAcceptable();
349 bool mobile2DCoherenceIsAcceptable();
351 bool mobile3DVelocityCoherenceIsAcceptable();
353 Shape3DData *getMostCoherentDataFromMobileAndBBoxLimit(std::map<ObjectType, Shape3DData> *normal,
354 std::map<ObjectType, Shape3DData> *occ,
Blob *blob);
356 void initPostureLimits(ObjectType type);
358 void freePostureLimits();
361 void updateBestType3DInformation();
362 void incrementalUpdateCooling(
int bufferSize);
363 void incrementalUpdateOrientation(
int bufferSize,
Shape3DData **
data, DetectionProblemType *dpFlags,
double *visualSupport);
364 void incrementalUpdate3DDimensions(
int bufferSize,
Shape3DData **data, DetectionProblemType *dpFlags,
double *visualSupport);
365 void incrementalUpdate3DPosition(
int bufferSize,
Shape3DData **data, DetectionProblemType *dpFlags,
double *visualSupport);
366 void incrementalUpdate2DPosition(
int bufferSize,
Rectangle<int> *bboxesToAnalyze, DetectionProblemType *dpFlags,
double *visualSupport,
double maxDistanceFactor);
367 void incrementalUpdate2DDimensions(
int bufferSize,
Rectangle<int> *bboxesToAnalyze, DetectionProblemType *dpFlags,
double *visualSupport,
double maxDistanceFactor);
370 void getCurrentBoundingBoxForMobileKeepingSize(
Rectangle<int> *bbox);
373 void generateS3DFrom3DInformation(
Shape3DData *outS3D);
375 bool mobileOutOfScene();
376 void generateFirstClassifiedSequence();
377 void setBestS3DSequence(std::deque<SpBlob>::iterator first_blob_it,
int frame_index,
int newBufferSize);
378 void generateMostCoherentS3DSequence(std::deque<SpBlob>::iterator first_blob_it,
Shape3DData *firstClassified,
int newBufferSize,
int frame_index, ObjectType current_type,
int current_index);
380 double probabilisticCoherenceReliability(
double data,
double mean,
double sigma,
double acuity);
382 double initialSDEstimateFor2DHorizontalAttribute();
383 double initialSDEstimateFor2DVerticalAttribute();
387 void setInitialNormalList(
Blob *current_blob);
389 bool coherentWithRespectOfCurrent3DInformation(
Shape3DData *s3d);
391 void repositionS3D(
Shape3DData *s3d,
double x,
double y);
399 void getMobile3DTolerances(
double *Wtol,
double *Htol);
Definition: MobileObject.h:56
Definition: MobileObject.h:78
Definition: MobileObject.h:93
Definition: MobileObject2D.h:36
Definition: calibration.h:51
Definition: MobileObject.h:40
Definition: ReliabilityClassification.h:37
Definition: MobileObject.h:97
Definition: MobileObject2D.h:46
Definition: trajectory.h:20
Definition: BackgroundRecLigth.h:20
Definition: MobileObject.h:101