Main MRPT website > C++ reference for MRPT 1.9.9
CObservationStereoImagesFeatures.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 "obs-precomp.h" // Precompiled headers
13 #include <fstream>
14 
15 using namespace mrpt::obs;
16 using namespace mrpt::poses;
17 using namespace mrpt::math;
18 using namespace mrpt::img;
19 using namespace std;
20 
21 // This must be added to any CSerializable class implementation file.
24 
26  const TCamera& cLeft, const TCamera& cRight, const CPose3DQuat& rCPose,
27  const CPose3DQuat& cPORobot)
28 {
29  cameraLeft = cLeft;
30  cameraRight = cRight;
31 
32  rightCameraPose = rCPose;
33  cameraPoseOnRobot = cPORobot;
34 }
35 
37  const std::string& filename)
38 {
39  std::ofstream file(filename);
40  ASSERT_(file.is_open());
41 
43  for (it = theFeatures.begin(); it != theFeatures.end(); ++it)
44  file << format(
45  "%u %.2f %.2f %.2f %.2f\n", it->ID, it->pixels.first.x,
46  it->pixels.first.y, it->pixels.second.x, it->pixels.second.y);
47 }
48 
50 {
51  return 0;
52 }
55 {
56  // The data
57  out << cameraLeft;
58  out << cameraRight;
59  out << rightCameraPose << cameraPoseOnRobot;
60  out << (uint32_t)theFeatures.size(); // Write the number of items
61  // within the feature list
62  for (unsigned int i = 0; i < theFeatures.size(); ++i)
63  {
64  out << theFeatures[i].pixels.first.x << theFeatures[i].pixels.first.y;
65  out << theFeatures[i].pixels.second.x << theFeatures[i].pixels.second.y;
66  out << (uint32_t)theFeatures[i].ID;
67  }
68  out << sensorLabel << timestamp;
69 }
70 
73 {
74  switch (version)
75  {
76  case 0:
77  {
78  uint32_t nL, nR;
79  in >> cameraLeft;
80  in >> cameraRight;
81  in >> rightCameraPose >> cameraPoseOnRobot;
82  in >> nL;
83  theFeatures.resize(nL);
84  for (unsigned int i = 0; i < theFeatures.size(); ++i)
85  {
86  in >> theFeatures[i].pixels.first.x >>
87  theFeatures[i].pixels.first.y;
88  in >> theFeatures[i].pixels.second.x >>
89  theFeatures[i].pixels.second.y;
90  in >> nR;
91  theFeatures[i].ID = (unsigned int)nR;
92  }
93  in >> sensorLabel >> timestamp;
94  }
95  break;
96  default:
98  };
99 }
100 
102  std::ostream& o) const
103 {
105 
106  o << "Homogeneous matrix for the sensor's 3D pose, relative to robot "
107  "base:\n";
108  o << cameraPoseOnRobot.getHomogeneousMatrixVal<CMatrixDouble44>()
109  << cameraPoseOnRobot << endl;
110 
111  o << "Homogeneous matrix for the RIGHT camera's 3D pose, relative to LEFT "
112  "camera reference system:\n";
113  o << rightCameraPose.getHomogeneousMatrixVal<CMatrixDouble44>()
114  << rightCameraPose << endl;
115 
116  o << "Intrinsic parameters matrix for the LEFT camera:" << endl;
117  CMatrixDouble33 aux = cameraLeft.intrinsicParams;
118  o << aux.inMatlabFormat() << endl << aux << endl;
119 
120  o << "Distortion parameters vector for the LEFT camera:" << endl << "[ ";
121  for (unsigned int i = 0; i < 5; ++i) o << cameraLeft.dist[i] << " ";
122  o << "]" << endl;
123 
124  o << "Intrinsic parameters matrix for the RIGHT camera:" << endl;
125  aux = cameraRight.intrinsicParams;
126  o << aux.inMatlabFormat() << endl << aux << endl;
127 
128  o << "Distortion parameters vector for the RIGHT camera:" << endl << "[ ";
129  for (unsigned int i = 0; i < 5; ++i) o << cameraRight.dist[i] << " ";
130  o << "]" << endl;
131 
132  o << endl
133  << format(
134  " Image size: %ux%u pixels\n", (unsigned int)cameraLeft.ncols,
135  (unsigned int)cameraLeft.nrows);
136  o << endl
137  << format(
138  " Number of features in images: %u\n",
139  (unsigned int)theFeatures.size());
140 }
mrpt::obs::CObservationStereoImagesFeatures::CObservationStereoImagesFeatures
CObservationStereoImagesFeatures()=default
format
GLenum GLsizei GLenum format
Definition: glext.h:3531
mrpt::obs::CObservationStereoImagesFeatures::serializeFrom
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
Definition: CObservationStereoImagesFeatures.cpp:71
obs-precomp.h
uint8_t
unsigned char uint8_t
Definition: rptypes.h:41
mrpt::poses::CPose3DQuat
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,...
Definition: CPose3DQuat.h:48
ASSERT_
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:113
mrpt::poses
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CHierarchicalMapMHPartition.h:25
mrpt::obs::CObservationStereoImagesFeatures::serializeGetVersion
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
Definition: CObservationStereoImagesFeatures.cpp:49
mrpt::obs
This namespace contains representation of robot actions and observations.
Definition: CParticleFilter.h:17
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
mrpt::img
Definition: CCanvas.h:17
mrpt::obs::CObservation::getDescriptionAsText
virtual void getDescriptionAsText(std::ostream &o) const
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
Definition: CObservation.cpp:44
mrpt::format
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
mrpt::obs::CObservationStereoImagesFeatures
Declares a class derived from "CObservation" that encapsules a pair of cameras and a set of matched i...
Definition: CObservationStereoImagesFeatures.h:39
mrpt::img::TCamera
Structure to hold the parameters of a pinhole camera model.
Definition: TCamera.h:29
CObservationStereoImagesFeatures.h
mrpt::math::CMatrixFixedNumeric
A numeric matrix of compile-time fixed size.
Definition: CMatrixFixedNumeric.h:40
mrpt::obs::CObservationStereoImagesFeatures::getDescriptionAsText
void getDescriptionAsText(std::ostream &o) const override
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
Definition: CObservationStereoImagesFeatures.cpp:101
mrpt::obs::CObservationStereoImagesFeatures::serializeTo
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: CObservationStereoImagesFeatures.cpp:53
mrpt::obs::CObservation
Declares a class that represents any robot's observation.
Definition: CObservation.h:43
mrpt::math
This base provides a set of functions for maths stuff.
Definition: math/include/mrpt/math/bits_math.h:13
IMPLEMENTS_SERIALIZABLE
IMPLEMENTS_SERIALIZABLE(CObservationStereoImagesFeatures, CObservation, mrpt::obs) CObservationStereoImagesFeatures
Definition: CObservationStereoImagesFeatures.cpp:22
in
GLuint in
Definition: glext.h:7274
string
GLsizei const GLchar ** string
Definition: glext.h:4101
iterator
Scalar * iterator
Definition: eigen_plugins.h:26
CArchive.h
mrpt::obs::CObservationStereoImagesFeatures::saveFeaturesToTextFile
void saveFeaturesToTextFile(const std::string &filename)
A method for storing the set of observed features in a text file in the format: ID ul vl ur vr be...
Definition: CObservationStereoImagesFeatures.cpp:36
MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
uint32_t
unsigned __int32 uint32_t
Definition: rptypes.h:47



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