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-2017, 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 "base-precomp.h" // Precompiled headers
11 
14 #include <mrpt/utils/CStream.h>
15 
16 using namespace mrpt::utils;
17 using namespace mrpt::poses;
18 using namespace mrpt::math;
19 using namespace std;
20 
22 
24 /** Save as a config block:
25  */
27  const std::string& section, mrpt::utils::CConfigFileBase& cfg) const
28 {
29  // [<SECTION>_LEFT]
30  // ...
31  // [<SECTION>_RIGHT]
32  // ...
33  // [<SECTION>_LEFT2RIGHT_POSE]
34  // pose_quaternion = [x y z qr qx qy qz]
35 
36  leftCamera.saveToConfigFile(section + string("_LEFT"), cfg);
37  rightCamera.saveToConfigFile(section + string("_RIGHT"), cfg);
38 
39  const CPose3DQuat q =
40  CPose3DQuat(rightCameraPose); // Don't remove this line, it's a safe
41  // against future possible bugs if
42  // rightCameraPose changes!
43  cfg.write(
44  section + string("_LEFT2RIGHT_POSE"), "pose_quaternion", q.asString());
45 }
46 
47 /** Load all the params from a config source, in the format described in
48  * saveToConfigFile()
49  */
51  const std::string& section, const mrpt::utils::CConfigFileBase& cfg)
52 {
53  // [<SECTION>_LEFT]
54  // ...
55  // [<SECTION>_RIGHT]
56  // ...
57  // [<SECTION>_LEFT2RIGHT_POSE]
58  // pose_quaternion = [x y z qr qx qy qz]
59 
60  leftCamera.loadFromConfigFile(section + string("_LEFT"), cfg);
61  rightCamera.loadFromConfigFile(section + string("_RIGHT"), cfg);
62  rightCameraPose.fromString(
63  cfg.read_string(
64  section + string("_LEFT2RIGHT_POSE"), "pose_quaternion", ""));
65 }
66 
67 // WriteToStream
68 void TStereoCamera::writeToStream(CStream& out, int* version) const
69 {
70  if (version)
71  *version = 1;
72  else
73  {
74  out << leftCamera << rightCamera << rightCameraPose;
75  } // end else
76 }
77 
78 // ReadFromStream
80 {
81  switch (version)
82  {
83  case 0:
84  case 1:
85  {
86  if (version == 0)
87  {
88  uint8_t _model;
89  in >> _model; // unused now
90  }
91 
92  in >> leftCamera >> rightCamera >> rightCameraPose;
93  }
94  break;
95  default:
97  }
98 }
99 
101 {
103  saveToConfigFile("", cfg);
104  return cfg.getContent();
105 }
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:44
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:3721
std::string read_string(const std::string &section, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
STL namespace.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
Structure to hold the parameters of a pinhole stereo camera model.
Definition: TStereoCamera.h:25
This class allows loading and storing values and vectors of different types from a configuration text...
unsigned char uint8_t
Definition: rptypes.h:41
This class implements a config file-like interface over a memory-stored string list.
void getContent(std::string &str) const
Return the current contents of the virtual "config file".
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
std::string dumpAsText() const
Dumps all the parameters as a multi-line string, with the same format than saveToConfigFile.
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
Definition: CPose3DQuat.h:48
GLsizei const GLchar ** string
Definition: glext.h:4101
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
void write(const std::string &section, const std::string &name, enum_t value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string())
void loadFromConfigFile(const std::string &section, const mrpt::utils::CConfigFileBase &cfg)
Load all the params from a config source, in the same format that used in saveToConfigFile().
void saveToConfigFile(const std::string &section, mrpt::utils::CConfigFileBase &cfg) const
Save all params to a plain text config file in this format:
GLuint in
Definition: glext.h:7274



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019