Main MRPT website > C++ reference for MRPT 1.9.9
TStereoCamera.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "img-precomp.h" // Precompiled headers
11 
12 #include <mrpt/img/TStereoCamera.h>
15 
16 using namespace mrpt::img;
17 using namespace mrpt::math;
18 using namespace std;
19 
21 
22 /** Save as a config block:
23  */
24 void TStereoCamera::saveToConfigFile(
25  const std::string& section, mrpt::config::CConfigFileBase& cfg) const
26 {
27  // [<SECTION>_LEFT]
28  // ...
29  // [<SECTION>_RIGHT]
30  // ...
31  // [<SECTION>_LEFT2RIGHT_POSE]
32  // pose_quaternion = [x y z qr qx qy qz]
33 
34  leftCamera.saveToConfigFile(section + string("_LEFT"), cfg);
35  rightCamera.saveToConfigFile(section + string("_RIGHT"), cfg);
36 
37  cfg.write(
38  section + string("_LEFT2RIGHT_POSE"), "pose_quaternion",
39  rightCameraPose.asString());
40 }
41 
42 /** Load all the params from a config source, in the format described in
43  * saveToConfigFile()
44  */
46  const std::string& section, const mrpt::config::CConfigFileBase& cfg)
47 {
48  // [<SECTION>_LEFT]
49  // ...
50  // [<SECTION>_RIGHT]
51  // ...
52  // [<SECTION>_LEFT2RIGHT_POSE]
53  // pose_quaternion = [x y z qr qx qy qz]
54 
55  leftCamera.loadFromConfigFile(section + string("_LEFT"), cfg);
56  rightCamera.loadFromConfigFile(section + string("_RIGHT"), cfg);
57  rightCameraPose.fromString(
58  cfg.read_string(
59  section + string("_LEFT2RIGHT_POSE"), "pose_quaternion", ""));
60 }
61 
64 {
65  // v1->v2: rightCameraPose changed from mrpt::poses::CPose3DQuat to
66  // mrpt::math::TPose3DQuat
67  out << leftCamera << rightCamera << rightCameraPose;
68 }
71 {
72  switch (version)
73  {
74  case 0:
75  case 1:
76  case 2:
77  {
78  if (version == 0)
79  {
80  uint8_t _model;
81  in >> _model; // unused now
82  }
83  if (version == 1)
84  {
85  // Emulate reading a CPose3DQuat object:
87  "backwards compatibility de-serialization not implemented "
88  "yet!");
89  }
90  in >> leftCamera >> rightCamera >> rightCameraPose;
91  }
92  break;
93  default:
95  }
96 }
97 
99 {
101  saveToConfigFile("", cfg);
102  return cfg.getContent();
103 }
CConfigFileMemory.h
TStereoCamera.h
mrpt::img::TStereoCamera::serializeGetVersion
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
Definition: TStereoCamera.cpp:62
mrpt::img::TStereoCamera::serializeFrom
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
Definition: TStereoCamera.cpp:69
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
uint8_t
unsigned char uint8_t
Definition: rptypes.h:41
THROW_EXCEPTION
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:41
mrpt::config::CConfigFileBase::read_string
std::string read_string(const std::string &section, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
Definition: CConfigFileBase.cpp:169
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
mrpt::img
Definition: CCanvas.h:17
mrpt::img::TStereoCamera::loadFromConfigFile
void loadFromConfigFile(const std::string &section, const mrpt::config::CConfigFileBase &cfg)
Load all the params from a config source, in the same format that used in saveToConfigFile().
Definition: TStereoCamera.cpp:45
mrpt::img::TStereoCamera
Structure to hold the parameters of a pinhole stereo camera model.
Definition: TStereoCamera.h:25
mrpt::config::CConfigFileBase
This class allows loading and storing values and vectors of different types from a configuration text...
Definition: config/CConfigFileBase.h:44
img-precomp.h
mrpt::utils::CConfigFileBase
mrpt::config::CConfigFileBase CConfigFileBase
Definition: utils/CConfigFileBase.h:7
mrpt::config::CConfigFileMemory::getContent
void getContent(std::string &str) const
Return the current contents of the virtual "config file".
Definition: CConfigFileMemory.cpp:66
mrpt::img::TStereoCamera::serializeTo
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: TStereoCamera.cpp:63
IMPLEMENTS_SERIALIZABLE
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
Definition: CSerializable.h:114
void
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
mrpt::math
This base provides a set of functions for maths stuff.
Definition: math/include/mrpt/math/bits_math.h:13
in
GLuint in
Definition: glext.h:7274
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::config::CConfigFileMemory
This class implements a config file-like interface over a memory-stored string list.
Definition: config/CConfigFileMemory.h:30
CArchive.h
mrpt::img::TStereoCamera::dumpAsText
std::string dumpAsText() const
Dumps all the parameters as a multi-line string, with the same format than saveToConfigFile.
Definition: TStereoCamera.cpp:98
MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
mrpt::img::TStereoCamera::saveToConfigFile
void saveToConfigFile(const std::string &section, mrpt::config::CConfigFileBase &cfg) const
Save all params to a plain text config file in this format:
Definition: TStereoCamera.cpp:24



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST