-
Notifications
You must be signed in to change notification settings - Fork 17
/
benchmark.cpp
69 lines (56 loc) · 2.09 KB
/
benchmark.cpp
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
/*
* benchmark.cpp
*
* Created on: Mar 31, 2015
* Author: Fabian Tschopp
*/
#include "benchmark.hpp"
#include <chrono>
#include <eigen3/Eigen/Dense>
#include <eigen3/Eigen/Core>
#include <eigen3/Eigen/Eigen>
#include "query_loader.hpp"
#include "query_processor.hpp"
#include "import_export.hpp"
namespace pose_estimation {
void Benchmark(QueryLoader &ql, parse_bundler &golden_pb, QueryProcessor *qp) {
std::ofstream out_file;
out_file.open("out/benchmark.txt");
assert(out_file.is_open());
for (int i = 0; i < ql.GetQueryCount(); ++i) {
Query golden = LoadGoldenQuery(golden_pb, i,
"data/Dubrovnik6K/bundle/");
Query query = ql.GetQuery(i, false);
std::chrono::time_point<std::chrono::high_resolution_clock> start, end;
start = std::chrono::high_resolution_clock::now();
qp->Process(query);
end = std::chrono::high_resolution_clock::now();
double elapsed_seconds =
std::chrono::duration<double>(end - start).count();
double position_error = (golden.camera_position()
- query.camera_position()).norm();
double rotation_error = (golden.camera_rotation()
- query.camera_rotation()).norm();
double focal_length_error = (golden.focal_length()
- query.focal_length());
std::cout << "================================================="
<< std::endl;
std::cout << "Index: " << i + 1 << std::endl;
std::cout << "Image size: " << query.image_width() << " x "
<< query.image_height() << std::endl;
std::cout << "Computation time: " << elapsed_seconds << " s"
<< std::endl;
std::cout << "Position error: " << position_error << std::endl;
std::cout << "Rotation error: " << rotation_error << std::endl;
std::cout << "Focal length error: " << focal_length_error << std::endl;
std::cout << "================================================="
<< std::endl;
out_file << (i + 1) << "," << std::setprecision(12) << elapsed_seconds
<< "," << std::setprecision(12) << position_error << ","
<< std::setprecision(12) << rotation_error << ","
<< std::setprecision(12) << focal_length_error << std::endl;
out_file.flush();
}
out_file.close();
}
}