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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// Copyright (c) 2012-2017 VideoStitch SAS
// Copyright (c) 2018 stitchEm
#pragma once
#include "backend/cpp/core/transformTypes.hpp"
#include "libvideostitch/inputDef.hpp"
#include "libvideostitch/projections.hpp"
namespace VideoStitch {
namespace Core {
class PanoDefinition;
/**
* The geometric params for a transform.
*/
class TransformGeoParams {
public:
/**
* Constructor
* @param im The InputDefinition
* @param geometry the geometryDefinition to use
*/
TransformGeoParams(const InputDefinition& im, const GeometryDefinition& geometry, const double sphereScale);
/**
* Constructor
* @param im The InputDefinition
* @param geometry the geometryDefinition to use
* @param pano the PanoDefinition to use
*/
TransformGeoParams(const InputDefinition& im, const GeometryDefinition& geometry, const PanoDefinition& pano);
/**
* Computes the sphereDist for a pano.
* @param proj output projection
* @param panoWidth pano width
* @param panoHFOVDeg Horizontal field of view
* @returns sphere dist.
*/
static float computePanoScale(const PanoProjection& proj, const int64_t panoWidth, const float panoHFOVDeg);
static double getInverseDemiDiagonalSquared(const InputDefinition& im);
/**
* Computes the input horizontal scale parameter.
* @param im input
* @param fov the fov to use
*/
static float computeHorizontalScale(const InputDefinition& im, double fov);
/**
* Computes the fov from the focal value
* @param im input
* @param focal the focal to use
*/
static double computeFov(const InputDefinition& im, double focal);
/**
* Computes the input vertical scale parameter.
* @param im input
* @param fov the fov to use
*/
static float computeVerticalScale(const InputDefinition& im, double fov);
/**
* Computes the input scale parameter.
*/
static float computeInputScale(InputDefinition::Format imFmt, int64_t imWidth, float imHFOVDeg);
/**
* Computes the fov from the focal value
*/
static double computeFovFromFocal(InputDefinition::Format imFmt, int64_t imWidth, double focal);
/**
Get the pose matrix elements (row major)
*/
const vsfloat3x4& getPose() const { return pose; }
const vsfloat3x4 getPoseScaled(const float scale) const {
vsfloat3x4 poseScaled;
/* rescale rotation values only */
for (int row = 0; row < 3; row++) {
for (int col = 0; col < 3; col++) {
poseScaled.values[row][col] = pose.values[row][col] * scale;
}
poseScaled.values[row][3] = pose.values[row][3];
}
return poseScaled;
}
/**
Get the pose matrix inversed elements (row major)
*/
const vsfloat3x4& getPoseInverse() const { return poseInverse; }
const vsfloat3x4 getPoseInverseScaled(const float scale) const {
vsfloat3x4 poseScaled;
/* rescale rotation values only */
for (int row = 0; row < 3; row++) {
for (int col = 0; col < 3; col++) {
poseScaled.values[row][col] = poseInverse.values[row][col] * scale;
}
poseScaled.values[row][3] = poseInverse.values[row][3];
}
return poseScaled;
}
/**
Get the Radial and Non-Radial distortion elements
*/
const vsDistortion& getDistortion() const { return distortion; }
private:
/**
3D pose matrix
*/
vsfloat3x4 pose;
/**
3D pose matrix
*/
vsfloat3x4 poseInverse;
/**
Coefficients for the distortion
*/
vsDistortion distortion;
};
} // namespace Core
} // namespace VideoStitch