-
Notifications
You must be signed in to change notification settings - Fork 88
/
input_data.hpp
64 lines (55 loc) · 1.67 KB
/
input_data.hpp
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
#ifndef INPUTDATA_H
#define INPUTDATA_H
#include <iostream>
#include <string>
#include <fstream>
#include <unordered_map>
#include <opencv2/calib3d.hpp>
#include <torch/torch.h>
enum CameraType { Perspective };
struct Camera{
int id = -1;
int width = 0;
int height = 0;
float fx = 0;
float fy = 0;
float cx = 0;
float cy = 0;
float k1 = 0;
float k2 = 0;
float k3 = 0;
float p1 = 0;
float p2 = 0;
torch::Tensor camToWorld;
std::string filePath = "";
CameraType cameraType = CameraType::Perspective;
Camera(){};
Camera(int width, int height, float fx, float fy, float cx, float cy,
float k1, float k2, float k3, float p1, float p2,
const torch::Tensor &camToWorld, const std::string &filePath) :
width(width), height(height), fx(fx), fy(fy), cx(cx), cy(cy),
k1(k1), k2(k2), k3(k3), p1(p1), p2(p2),
camToWorld(camToWorld), filePath(filePath) {}
torch::Tensor getIntrinsicsMatrix();
bool hasDistortionParameters();
std::vector<float> undistortionParameters();
torch::Tensor getImage(int downscaleFactor);
void loadImage(float downscaleFactor);
torch::Tensor K;
torch::Tensor image;
std::unordered_map<int, torch::Tensor> imagePyramids;
};
struct Points{
torch::Tensor xyz;
torch::Tensor rgb;
};
struct InputData{
std::vector<Camera> cameras;
float scale;
torch::Tensor translation;
Points points;
std::tuple<std::vector<Camera>, Camera *> getCameras(bool validate, const std::string &valImage = "random");
void saveCameras(const std::string &filename, bool keepCrs);
};
InputData inputDataFromX(const std::string &projectRoot);
#endif