-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMotionParams.h
71 lines (61 loc) · 1.83 KB
/
MotionParams.h
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
/**
* ___ _ _ ___ _ __ __ _ ___
* / __| | | | \ /_\ | \/ | /_\ | _ \
* | (__| |_| | |) / _ \ | |\/| |/ _ \| _/
* \___|\___/|___/_/_\_\_|_|__|_/_/_\_\_|_ ___
* / __| | | | _ \ __| _ \___| _ \ __/ __|
* \__ \ |_| | _/ _|| /___| / _|\__ \
* |___/\___/|_| |___|_|_\ |_|_\___|___/
* 2012
*
* by Jens Wetzl ([email protected])
* and Oliver Taubmann ([email protected])
*
* This work is licensed under a Creative Commons
* Attribution 3.0 Unported License. (CC-BY)
* http://creativecommons.org/licenses/by/3.0/
*
**/
#ifndef MOTION_PARAMS_H
#define MOTION_PARAMS_H
#include <string>
#include <cstdlib>
#include <vector>
#include <fstream>
#include <iostream>
#include <algorithm>
// Stores a homography matrix that transforms a point in the
// low resolution image to its corresponding point in the
// coordinate system of the superresolved image.
struct MotionParams
{
float H[9];
// Loads numImages homography matrices stored in a single file to motionParams
static void loadFromFile(const std::string &filename, size_t numImages, std::vector<MotionParams> &motionParams)
{
std::ifstream file(filename.c_str());
if (!file.good())
{
std::cerr << "Error: Couldn't open '" << filename << "'." << std::endl;
exit(EXIT_FAILURE);
}
motionParams.resize(numImages);
for (size_t i = 0; i < numImages; ++i)
{
MotionParams &mp = motionParams[i];
try
{
file >> mp.H[0] >> mp.H[1] >> mp.H[2] >>
mp.H[3] >> mp.H[4] >> mp.H[5] >>
mp.H[6] >> mp.H[7] >> mp.H[8];
}
catch (...)
{
std::cerr << "Error: Couldn't read " << (numImages * 9) <<
"floats from motion param file." << std::endl;
exit(EXIT_FAILURE);
}
}
}
};
#endif // MOTION_PARAMS_H