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 }
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...
Scalar * iterator
Definition: eigen_plugins.h:26
Declares a class derived from "CObservation" that encapsules a pair of cameras and a set of matched i...
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
IMPLEMENTS_SERIALIZABLE(CObservationStereoImagesFeatures, CObservation, mrpt::obs) CObservationStereoImagesFeatures
STL namespace.
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
unsigned char uint8_t
Definition: rptypes.h:41
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:113
A numeric matrix of compile-time fixed size.
This base provides a set of functions for maths stuff.
This namespace contains representation of robot actions and observations.
Structure to hold the parameters of a pinhole camera model.
Definition: TCamera.h:27
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
Definition: CPose3DQuat.h:46
GLsizei const GLchar ** string
Definition: glext.h:4101
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
void getDescriptionAsText(std::ostream &o) const override
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:52
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:43
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
GLuint in
Definition: glext.h:7274
GLenum GLsizei GLenum format
Definition: glext.h:3531
unsigned __int32 uint32_t
Definition: rptypes.h:47
virtual void getDescriptionAsText(std::ostream &o) const
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...



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