-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark_perf_vs_num_snaps.cc
79 lines (66 loc) · 1.86 KB
/
benchmark_perf_vs_num_snaps.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "common.h"
// BoB robotics includes
#include "navigation/perfect_memory.h"
#include "navigation/infomax.h"
using namespace BoBRobotics;
template<class Algo>
void
runTest(Algo &algo, std::vector<cv::Mat> &trainImages,
std::vector<cv::Mat> &testImages, cv::FileStorage &fs)
{
constexpr size_t imageStepMax = 50;
for (size_t i = 1; i <= imageStepMax; i++) {
std::cout << "Step: " << i << "\n";
fs << "{"
<< "step" << (int) i;
algo.clearMemory();
for (size_t j = 0; j < trainImages.size(); j += i) {
algo.train(trainImages[j]);
}
doTest(algo, testImages, fs);
fs << "}";
}
}
int
bobMain(int, char **)
{
std::string ofName = Path::getProgramPath().str() + ".json";
cv::FileStorage fs{ ofName, cv::FileStorage::WRITE };
fs << "data"
<< "{"
<< "bob_robotics_git_commit" << BOB_ROBOTICS_GIT_COMMIT
<< "bob_project_git_commit" << BOB_PROJECT_GIT_COMMIT
<< "image_size" << ImageSize;
std::vector<cv::Mat> trainImages, testImages;
for (const auto &route : TrainRoutes) {
loadDatabaseImages(trainImages, route);
}
fs << "experiments" << "["
<< "training"
<< "{"
<< "routes" << TrainRoutes
<< "}";
loadDatabaseImages(testImages, TestRoutes[0]);
BOB_ASSERT(TestRoutes.size() == 1);
fs << "testing"
<< "{"
<< "routes" << TestRoutes;
{
fs << "perfect_memory"
<< "[";
Navigation::PerfectMemoryRotater<> pm{ ImageSize };
runTest(pm, trainImages, testImages, fs);
fs << "]";
}
{
fs << "infomax"
<< "[";
Navigation::InfoMaxRotater<> infomax{ ImageSize };
runTest(infomax, trainImages, testImages, fs);
fs << "]";
}
fs << "}"
<< "]"
<< "}";
return EXIT_SUCCESS;
}