g2o
Loading...
Searching...
No Matches
g2o
types
sba
parameter_cameraparameters.cpp
Go to the documentation of this file.
1
// g2o - General Graph Optimization
2
// Copyright (C) 2011 H. Strasdat
3
// All rights reserved.
4
//
5
// Redistribution and use in source and binary forms, with or without
6
// modification, are permitted provided that the following conditions are
7
// met:
8
//
9
// * Redistributions of source code must retain the above copyright notice,
10
// this list of conditions and the following disclaimer.
11
// * Redistributions in binary form must reproduce the above copyright
12
// notice, this list of conditions and the following disclaimer in the
13
// documentation and/or other materials provided with the distribution.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27
#include "
parameter_cameraparameters.h
"
28
29
#include "
g2o/types/slam3d/se3_ops.h
"
30
31
namespace
g2o
{
32
33
CameraParameters::CameraParameters
()
34
: focal_length(1.), principle_point(
Vector2
(0., 0.)), baseline(0.5) {}
35
36
CameraParameters::CameraParameters
(
double
focal_length,
37
const
Vector2
& principle_point,
38
double
baseline)
39
: focal_length(focal_length),
40
principle_point(principle_point),
41
baseline(baseline) {}
42
43
bool
CameraParameters::read
(std::istream& is) {
44
is >>
focal_length
;
45
is >>
principle_point
[0];
46
is >>
principle_point
[1];
47
is >>
baseline
;
48
return
true
;
49
}
50
51
bool
CameraParameters::write
(std::ostream& os)
const
{
52
os <<
focal_length
<<
" "
;
53
os <<
principle_point
.x() <<
" "
;
54
os <<
principle_point
.y() <<
" "
;
55
os <<
baseline
<<
" "
;
56
return
true
;
57
}
58
59
Vector2
CameraParameters::cam_map
(
const
Vector3
& trans_xyz)
const
{
60
Vector2
proj =
project
(trans_xyz);
61
Vector2
res;
62
res[0] = proj[0] *
focal_length
+
principle_point
[0];
63
res[1] = proj[1] *
focal_length
+
principle_point
[1];
64
return
res;
65
}
66
67
Vector3
CameraParameters::stereocam_uvu_map
(
const
Vector3
& trans_xyz)
const
{
68
Vector2
uv_left =
cam_map
(trans_xyz);
69
double
proj_x_right = (trans_xyz[0] -
baseline
) / trans_xyz[2];
70
double
u_right = proj_x_right *
focal_length
+
principle_point
[0];
71
return
Vector3
(uv_left[0], uv_left[1], u_right);
72
}
73
74
}
// namespace g2o
g2o::CameraParameters::CameraParameters
CameraParameters()
Definition
parameter_cameraparameters.cpp:33
g2o::CameraParameters::stereocam_uvu_map
Vector3 stereocam_uvu_map(const Vector3 &trans_xyz) const
Definition
parameter_cameraparameters.cpp:67
g2o::CameraParameters::principle_point
Vector2 principle_point
Definition
parameter_cameraparameters.h:51
g2o::CameraParameters::focal_length
double focal_length
Definition
parameter_cameraparameters.h:50
g2o::CameraParameters::write
bool write(std::ostream &os) const
write the data to a stream
Definition
parameter_cameraparameters.cpp:51
g2o::CameraParameters::baseline
double baseline
Definition
parameter_cameraparameters.h:52
g2o::CameraParameters::cam_map
Vector2 cam_map(const Vector3 &trans_xyz) const
Definition
parameter_cameraparameters.cpp:59
g2o::CameraParameters::read
bool read(std::istream &is)
read the data from a stream
Definition
parameter_cameraparameters.cpp:43
g2o
Definition
dl_wrapper.cpp:55
g2o::Vector3
VectorN< 3 > Vector3
Definition
eigen_types.h:51
g2o::project
G2O_TYPES_SLAM3D_API Vector2 project(const Vector3 &)
g2o::Vector2
VectorN< 2 > Vector2
Definition
eigen_types.h:50
parameter_cameraparameters.h
se3_ops.h
Generated on Tue Nov 11 2025 05:18:45 for g2o by
1.9.8