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 }
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:41
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
STL namespace.
unsigned char uint8_t
Definition: rptypes.h:41
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
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().
GLsizei const GLchar ** string
Definition: glext.h:4101
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:52
void getContent(std::string &str) const
Return the current contents of the virtual "config file".
GLuint in
Definition: glext.h:7274
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
Structure to hold the parameters of a pinhole stereo camera model.
Definition: TStereoCamera.h:23



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020