00001
00033 #ifndef __STATS_H__
00034 #define __STATS_H__
00035
00036 #include <DAG.h>
00037 #include <DAGDatabase.h>
00038 #include <Debug.h>
00039
00040
00041 #define NOT_SET -100
00042
00043 #define MAXPOS 10000
00044 #define MAXVIEW 128
00045
00046 class STATINFO
00047 {
00048 public:
00049 bool bCompViewStats;
00050 leda_array<MatchInfo> matchList;
00051 int nParamsToSet;
00052
00053 class INFOVAR
00054 {
00055 int nDAGId;
00056 double dSimilarity;
00057
00058 int nBestRankingPosition;
00059 int nWorstRankingPosition;
00060
00061 int nBestIdxPos;
00062 int nWorstIdxPos;
00063
00064 public:
00065 INFOVAR() { Clear(); }
00066 void Clear();
00067 int GetDAGId() const { return nDAGId; }
00068
00069 void SetRankPos(int currentRankPos, const leda_array<MatchInfo>& rankList);
00070 void SetRankPos(int currentRankPos, const leda_array<MatchInfo>& rankList, const INFOVAR& queryPos);
00071 void SetIdxPos(int currentIdxPos, const leda_array<MatchInfo>& idxRankList);
00072 void SetIdxPos(int currentIdxPos, const leda_array<MatchInfo>& idxRankList, const INFOVAR& queryPos);
00073
00074 bool IsNotSet() const;
00075
00076 static int GetBestPos(int i, const leda_array<MatchInfo>& matches);
00077 static int GetWorstPos(int i, const leda_array<MatchInfo>& matches);
00078
00079 friend ostream& operator<<(ostream &os, const INFOVAR& v);
00080 };
00081
00082 INFOVAR queryObj;
00083 INFOVAR rightClass;
00084 INFOVAR wrongClass;
00085 INFOVAR neigType1;
00086 INFOVAR neigType2;
00087 INFOVAR topRanked;
00088
00089 STATINFO() { bCompViewStats = false; }
00090 void InitStats();
00091
00095 int GetParamCount() const { return nParamsToSet; }
00096
00097 void ComputeStats(const DAG* pQueryDag);
00098 void ComputeCrossRankingIdxStats(const STATINFO& matStats);
00099 int FindDAGPos(int nDAGId) const;
00100
00101 static void WriteHeader(ostream& os, int nFileIdx, int nIdxKBest, double dMaxOcclusionRate);
00102 static void Write(ostream& os, int i, int nViewNum, const STATINFO& idxSt, const STATINFO& matSt,
00103 double dCompTime, double dOcclusionRate);
00104 static void WriteTailer(ostream& os);
00105
00106 friend ostream& operator<<(ostream& os, const STATINFO& v);
00107 };
00108
00109 bool GetClosestViews(int i, int res, int& a, int &b, int &c);
00110 bool GetClosestViews2(int i, int res, SmartArray<int>& neigs, bool bIncludeFirstLevel);
00111 SmartArray<int> GetClosestViewsByRange(int i, int res, const double& range);
00112 SmartArray<int> GetSymmetricViewMap();
00113
00114 #endif //__STATS_H__