-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGroundTruthComparator.cpp
More file actions
87 lines (70 loc) · 3.24 KB
/
Copy pathGroundTruthComparator.cpp
File metadata and controls
87 lines (70 loc) · 3.24 KB
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
80
81
82
83
84
85
86
87
#include "GroundTruthComparator.h"
#include "ConfigProvider.h"
#include "TiffPipeline.h"
#include "DataStructures.h"
#include <utility>
#include "iostream"
GroundTruthComparator::GroundTruthComparator(std::vector<std::string> configPaths) {
GroundTruthComparator::configPaths = std::move(configPaths);
configProvider = new ConfigProvider();
pipelines.reserve(GroundTruthComparator::configPaths.size());
auto pipeline = configProvider->providePipeline(GroundTruthComparator::configPaths.at(1));
pipelines.emplace_back(new TiffPipeline(GroundTruthComparator::configPaths.at(0), pipeline->getGLHandler()->getShaderDir()));
destinationPaths.emplace_back(configProvider->getDestinationPath());
pipelines.emplace_back(pipeline);
destinationPaths.emplace_back(configProvider->getDestinationPath());
for (auto i = 0ul; i < pipelines.size(); i++){
betterCompression.emplace_back(configProvider->getBetterCompression());
}
GroundTruthComparator::glHandler = pipelines.at(0)->getGLHandler();
compareShaderPath = "compareSquareError.glsl";
}
GroundTruthComparator::~GroundTruthComparator() {
delete configProvider;
for (auto pipeline : pipelines) delete pipeline;
configProvider = nullptr;
}
/**
* Reads all the point-clouds in the pipelines in pipelines and adds a shared min and max value, so the point-clouds will be scaled and rasterized koherently.
* @return a Vector containing all the read point-clouds
*/
std::vector<rawPointCloud *> GroundTruthComparator::setupPointClouds() {
std::vector<rawPointCloud *> readerReturns(pipelines.size());
heightMap * map = pipelines.at(0)->execute();
readerReturns.at(0) = emptyPointCloudFromHeightMap(map);
for (auto i = 1ul; i < pipelines.size(); i++) {
readerReturns.at(i) = pipelines.at(i)->getCloudReader()->apply(true);
}
std::vector<doublePoint> mins, maxs;
for (auto pointCloud : readerReturns) {
mins.emplace_back(pointCloud->min);
maxs.emplace_back(pointCloud->max);
}
auto absoluteMin = mergeDoublePoints(mins).first,
absoluteMax = mergeDoublePoints(maxs).second;
for (auto pointCloud : readerReturns) {
pointCloud->min = absoluteMin;
pointCloud->max = absoluteMax;
}
pipelines.at(1)->getCloudSorter()->setResolution(map->resolutionX, map->resolutionY);
return readerReturns;
}
/**
* Writes the pixelwise comparisons to a Geotiff-File. And the Mean-Squre-Error to the console.
* @param comparisons a vector of pixelwise comparisons to be writen as Geotiff-Files.
*/
void GroundTruthComparator::writeComparisons(std::vector<heightMap *> comparisons) {
std::vector<double> meanSquareErrors(comparisons.size());
for (auto i = 0ul; i < comparisons.size(); i++) {
double averageError = 0;
auto amount = comparisons.at(i)->resolutionX * comparisons.at(i)->resolutionY;
for (auto j = 0ul; j < amount; j++) {
averageError += double(comparisons.at(i)->heights.at(j)) / double(amount);
}
meanSquareErrors.at(i) = sqrt(averageError);
}
for (auto i = 0ul; i < comparisons.size(); i++) {
std::cout << "Mean-Square-Error: " << meanSquareErrors.at(i) << "\n";
}
IComparator::writeComparisons(comparisons);
}