MRPT  2.0.4
TStereoCamera.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "img-precomp.h" // Precompiled headers
11 
13 #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(cfg.read_string(
58  section + string("_LEFT2RIGHT_POSE"), "pose_quaternion", ""));
59 }
60 
61 uint8_t TStereoCamera::serializeGetVersion() const { return 2; }
63 {
64  // v1->v2: rightCameraPose changed from mrpt::poses::CPose3DQuat to
65  // mrpt::math::TPose3DQuat
66  out << leftCamera << rightCamera << rightCameraPose;
67 }
69  mrpt::serialization::CArchive& in, uint8_t version)
70 {
71  switch (version)
72  {
73  case 0:
74  case 1:
75  case 2:
76  {
77  if (version == 0)
78  {
79  uint8_t _model;
80  in >> _model; // unused now
81  }
82  if (version == 1)
83  {
84  // Emulate reading a CPose3DQuat object:
86  "backwards compatibility de-serialization not implemented "
87  "yet!");
88  }
89  in >> leftCamera >> rightCamera >> rightCameraPose;
90  }
91  break;
92  default:
94  }
95 }
96 
97 std::string TStereoCamera::dumpAsText() const
98 {
100  saveToConfigFile("", cfg);
101  return cfg.getContent();
102 }
This class implements a config file-like interface over a memory-stored string list.
std::string read_string(const std::string &section, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:67
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
STL namespace.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:97
This class allows loading and storing values and vectors of different types from a configuration text...
This base provides a set of functions for maths stuff.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
mrpt::config::CConfigFileBase CConfigFileBase
std::string dumpAsText() const
Dumps all the parameters as a multi-line string, with the same format than saveToConfigFile.
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().
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
void saveToConfigFile(const std::string &section, mrpt::config::CConfigFileBase &cfg) const
Save all params to a plain text config file in this format:
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:54
mrpt::vision::TStereoCalibResults out
void getContent(std::string &str) const
Return the current contents of the virtual "config file".
Structure to hold the parameters of a pinhole stereo camera model.
Definition: TStereoCamera.h:23



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020