26 #define ISM_DATA "/media/share/data" 30 void drawISM(
string model,
string patternName, map<
string, map<string, unsigned> >graphVizData,
unsigned testsPerformed,
unsigned timeSteps)
32 if (testsPerformed == 0)
37 stringstream filePath;
38 filePath<<std::string(
ISM_DATA)+
"/evaluation/gedeck_evaluation/complexity/"<<patternName<<
"_"<<model<<
"_ISMWithVotes.dot";
39 string filename = filePath.str();
41 vector<pair<string, string> > alreadyTakenCombinations;
42 ios_base::iostate exceptionMask = file.exceptions() | ios::failbit | ios::badbit;
43 file.exceptions(exceptionMask);
48 file<<
"digraph "<<model<<
" {\n";
49 for (
const pair<
string, map<string, unsigned> >& type : graphVizData)
51 for (
const pair<string, unsigned>& voteIt : type.second)
53 file<<voteIt.first<<
"[shape=\"box\"];\n";
57 for (
const pair<
string, map<string, unsigned> >& typeIt : graphVizData)
59 for (
const pair<string, unsigned>& voteIt : typeIt.second)
61 if (find(alreadyTakenCombinations.begin(), alreadyTakenCombinations.end(), make_pair(voteIt.first, typeIt.first)) == alreadyTakenCombinations.end())
64 file<<voteIt.first<<
" -> "<<typeIt.first<<
"[ label=\" ∪" 65 <<(unsigned)((((
double)voteIt.second) / testsPerformed) / timeSteps)<<
"|→" 67 <<(unsigned)(((
double)voteIt.second) / testsPerformed)
69 <<
"\", decorate=\"true\", labelfoat=\"true\", labelfontcolor=\"red\", dir=\"back\"];\n";
70 alreadyTakenCombinations.push_back(make_pair(voteIt.first, typeIt.first));
78 catch (ios_base::failure& e)
87 std::map<ObjectPtr, std::vector<VotedPosePtr> > votingCache = recognizer->getVotingCache();
88 for (
const std::pair<
ObjectPtr, std::vector<VotedPosePtr> >& it : votingCache)
92 ++graphVizData[it.first->type][voteIt->vote->patternName];
100 std::vector<std::pair<std::string, std::string> > modeldbs =
102 std::make_pair(
"best", std::string(
ISM_DATA)+
"/evaluation/gedeck_evaluation/sourcedbs/record.sqlite.combinatorialTrainer_example_1_best"),
103 std::make_pair(
"best_naive", std::string(
ISM_DATA)+
"/evaluation/gedeck_evaluation/sourcedbs/record.sqlite.combinatorialTrainer_example_1_best_naive"),
104 std::make_pair(
"star", std::string(
ISM_DATA)+
"/evaluation/gedeck_evaluation/sourcedbs/record.sqlite.combinatorialTrainer_example_1_star"),
105 std::make_pair(
"fully_meshed", std::string(
ISM_DATA)+
"/evaluation/gedeck_evaluation/sourcedbs/record.sqlite.combinatorialTrainer_example_1_fullyMeshed"),
106 std::make_pair(
"fully_meshed_naive",std::string(
ISM_DATA)+
"/evaluation/gedeck_evaluation/sourcedbs/record.sqlite.combinatorialTrainer_example_1_fullyMeshed_naive")
109 output.open(std::string(
ISM_DATA)+
"/evaluation/gedeck_evaluation/output.csv");
110 output<<
"model, avgTime, falsePositives\n";
111 for (std::pair<std::string, std::string>& model : modeldbs)
113 std::map<std::string, std::map<std::string, unsigned> > vizData;
114 cout<<
"trying to open db file\n";
115 TableHelperPtr validSetsTable(
new TableHelper(std::string(
ISM_DATA)+
"/evaluation/gedeck_evaluation/sourcedbs/record.sqlite.combinatorialTrainer_example_1_validTestSets"));
116 cout<<
"could open valid sets\n";
117 const RecordedPatternPtr validPatterns = validSetsTable->getRecordedPattern(
"combinatorialTrainer_example_1");
118 vector<ObjectSetPtr> validSets;
119 if (validPatterns != 0)
121 validSets = validPatterns->objectSets;
123 struct timeval start, end;
125 TableHelperPtr invalidSetsTable(
new TableHelper(std::string(
ISM_DATA)+
"/evaluation/gedeck_evaluation/sourcedbs/record.sqlite.combinatorialTrainer_example_1_invalidTestSets"));
126 cout<<
"could open invalid sets\n ";
127 const RecordedPatternPtr invalidPatterns = invalidSetsTable->getRecordedPattern(
"combinatorialTrainer_example_1");
128 vector<ObjectSetPtr> invalidSets;
129 if (invalidPatterns != 0)
131 invalidSets = invalidPatterns->objectSets;
133 cout<<invalidSets.size()<<endl;
135 cout<<
"could create recognizer\n";
138 if (model.first ==
"fully_meshed_naive")
142 cout<<
".";cout.flush();
143 gettimeofday(&start, NULL);
144 const std::vector<RecognitionResultPtr> res = recog->recognizePattern(validSet, 0.0, 1);
145 gettimeofday(&end, NULL);
146 time += ((end.tv_sec - start.tv_sec) * 1000) + ((end.tv_usec - start.tv_usec) / 1000);
152 cout<<
".";cout.flush();
153 gettimeofday(&start, NULL);
154 const std::vector<RecognitionResultPtr> res = recog->recognizePattern(invalidSet, 0.0, 1);
155 gettimeofday(&end, NULL);
156 time += ((end.tv_sec - start.tv_sec) * 1000) + ((end.tv_usec - start.tv_usec) / 1000);
158 if (res.size() > 0 && res[0]->confidence == 1 && res[0]->patternName ==
"combinatorialTrainer_example_1")
162 if (model.first ==
"fully_meshed_naive")
168 if (model.first ==
"fully_meshed_naive")
170 drawISM(model.first,
"combinatorialTrainer_example_1", vizData, 1, 112.0);
171 avg = ((double)time) / 1.0;
175 drawISM(model.first,
"combinatorialTrainer_example_1", vizData, validSets.size() + invalidSets.size(), 112.0);
176 avg = ((double)time) / (validSets.size() + invalidSets.size());
179 output<<model.first<<
","<<avg<<
","<<fps<<endl;
boost::shared_ptr< Recognizer > RecognizerPtr
boost::shared_ptr< RecordedPattern > RecordedPatternPtr
boost::shared_ptr< TableHelper > TableHelperPtr
boost::shared_ptr< VotedPose > VotedPosePtr
void addVizData(std::map< std::string, std::map< std::string, unsigned > > &graphVizData, const RecognizerPtr &recognizer)
boost::shared_ptr< ObjectSet > ObjectSetPtr
this namespace contains all generally usable classes.
void drawISM(string model, string patternName, map< string, map< string, unsigned > >graphVizData, unsigned testsPerformed, unsigned timeSteps)
boost::shared_ptr< Object > ObjectPtr