SurfaceMap.hpp
1.12 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
#pragma once
#include "data/ResourceLocator.hpp"
#include "data/hdf5/CVMatLoader.hpp"
class SurfaceMap {
public:
explicit SurfaceMap(const cv::Size &size) : surface(buildSurface(size)) {}
cv::Point3f at(int column, int row) const {
return surface.at<cv::Point3f>(row, column);
}
cv::Point3f at(const cv::Point &point) const {
return at(point.x, point.y);
}
std::vector<cv::Point3f> at(const std::vector<cv::Point> &points) const {
std::vector<cv::Point3f> surfacePoints(points.size());
std::transform(points.begin(), points.end(), surfacePoints.begin(),
[&](const cv::Point &point) { return at(point); });
return surfacePoints;
}
private:
const cv::Mat surface;
static cv::Mat buildSurface(const cv::Size &size) {
cv::Mat result(size, CV_32FC3);
const CVMatLoader loader(
ResourceLocator::getPathProvider().path("20171114.053_AEF20.h5"));
const std::vector<cv::Mat> coordinates = {
loader.asMat("/scene_model/x", CV_32F),
loader.asMat("/scene_model/y", CV_32F),
loader.asMat("/scene_model/z", CV_32F),
};
cv::merge(coordinates, result);
return result;
}
};