36 f.
printf(
"%u %u %f %f %f %f %f %f %f\n",
45 it->errorSquareAfterTransformation);
54 FILE *f =
os::fopen(filName.c_str(),
"wt");
56 fprintf(f,
"%% ----------------------------------------------------\n");
57 fprintf(f,
"%% File generated automatically by the MRPT method:\n");
58 fprintf(f,
"%% saveAsMATLABScript \n");
59 fprintf(f,
"%% Before calling this script, define the color of lines, eg:\n");
60 fprintf(f,
"%% colorLines=[1 1 1]");
61 fprintf(f,
"%% J.L. Blanco (C) 2005-2012 \n");
62 fprintf(f,
"%% ----------------------------------------------------\n\n");
64 fprintf(f,
"axis equal; hold on;\n");
67 fprintf(f,
"line([%f %f],[%f %f],'Color',colorLines);\n",
72 fprintf(f,
"set(plot([%f %f],[%f %f],'.'),'Color',colorLines,'MarkerSize',15);\n",
87 if (it->other_idx == idx)
95 if (
a.this_idx==
b.this_idx)
96 return (
a.this_idx<
b.this_idx);
97 else return (
a.other_idx<
b.other_idx);
103 return (
a.this_idx==
b.this_idx) && (
a.other_idx==
b.other_idx);
108 if (
a.size()!=
b.size())
111 if (! ( (*it1)==(*it2)))
122 vector<float> errs(
size() );
123 squareErrorVector(
q,errs);
133 vector<float> &ys )
const 135 vector<float> errs(
size() );
136 squareErrorVector(
q,errs,xs,ys);
156 out_sqErrs.resize(
size() );
159 const float ccos = cos(
q.phi());
160 const float csin = sin(
q.phi());
161 const float qx =
q.x();
162 const float qy =
q.y();
166 for (corresp=
begin(), e_i = out_sqErrs.begin();corresp!=
end();++corresp, ++e_i)
168 float xx = qx + ccos * corresp->other_x - csin * corresp->other_y;
169 float yy = qy + csin * corresp->other_x + ccos * corresp->other_y;
170 *e_i =
square( corresp->this_x - xx ) +
square( corresp->this_y - yy );
179 vector<float> &out_sqErrs,
181 vector<float> &ys )
const 183 out_sqErrs.resize(
size() );
189 const float ccos = cos(
q.phi());
190 const float csin = sin(
q.phi());
191 const float qx =
q.x();
192 const float qy =
q.y();
196 for (corresp=
begin(), e_i = out_sqErrs.begin(), xx = xs.begin(), yy = ys.begin();corresp!=
end();++corresp, ++e_i, ++xx,++yy)
198 *xx = qx + ccos * corresp->other_x - csin * corresp->other_y;
199 *yy = qy + csin * corresp->other_x + ccos * corresp->other_y;
200 *e_i =
square( corresp->this_x - *xx ) +
square( corresp->this_y - *yy );
206 std::vector<TMatchingPairConstPtr> bestMatchForThisMap(num_elements_this_map,
TMatchingPairConstPtr(
nullptr));
207 out_filtered_list.clear();
211 for (
auto &
c : *
this)
213 if (bestMatchForThisMap[
c.this_idx] ==
nullptr ||
214 c.errorSquareAfterTransformation < bestMatchForThisMap[
c.this_idx]->errorSquareAfterTransformation
217 bestMatchForThisMap[
c.this_idx] = &
c;
223 for (
auto &
c : *
this) {
224 if (bestMatchForThisMap[
c.this_idx] == &
c)
225 out_filtered_list.push_back(
c);
bool fileOpenCorrectly()
Returns true if the file was open without errors.
const_iterator end() const
FILE BASE_IMPEXP * fopen(const char *fileName, const char *mode) MRPT_NO_THROWS
An OS-independent version of fopen.
float overallSquareError(const mrpt::poses::CPose2D &q) const
Computes the overall square error between the 2D points in the list of correspondences, given the 2D transformation "q" Where are the elements of the square error vector as computed by computeSquareErrorVector.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
float overallSquareErrorAndPoints(const mrpt::poses::CPose2D &q, std::vector< float > &xs, std::vector< float > &ys) const
Computes the overall square error between the 2D points in the list of correspondences, given the 2D transformation "q", and return the transformed points as well.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
int BASE_IMPEXP void BASE_IMPEXP fclose(FILE *f)
An OS-independent version of fclose.
GLdouble GLdouble GLdouble GLdouble q
const_iterator begin() const
This file implements several operations that operate element-wise on individual or pairs of container...
bool contains(const TMatchingPair &p) const
Test whether the given pair "p" is within the pairings.
int BASE_IMPEXP fprintf(FILE *fil, const char *format,...) MRPT_NO_THROWS MRPT_printf_format_check(2
An OS-independent version of fprintf.
const Scalar * const_iterator
T square(const T x)
Inline function for the square of a number.
This base provides a set of functions for maths stuff.
bool operator<(const CArray< T, N > &x, const CArray< T, N > &y)
This CStream derived class allow using a file as a write-only, binary stream.
void dumpToFile(const std::string &fileName) const
Saves the correspondences to a text file.
CONTAINER::Scalar sum(const CONTAINER &v)
Computes the sum of all the elements.
void saveAsMATLABScript(const std::string &filName) const
Saves the correspondences as a MATLAB script which draws them.
GLsizei const GLchar ** string
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
TMatchingPair const * TMatchingPairConstPtr
void squareErrorVector(const mrpt::poses::CPose2D &q, std::vector< float > &out_sqErrs) const
Returns a vector with the square error between each pair of correspondences in the list...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
void filterUniqueRobustPairs(const size_t num_elements_this_map, TMatchingPairList &out_filtered_list) const
Creates a filtered list of pairings with those ones which have a single correspondence which coincide...
bool operator==(const CArray< T, N > &x, const CArray< T, N > &y)
GLubyte GLubyte GLubyte a
bool indexOtherMapHasCorrespondence(size_t idx) const
Checks if the given index from the "other" map appears in the list.
A structure for holding correspondences between two sets of points or points-like entities in 2D or 3...
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.