37 "%u %u %f %f %f %f %f %f %f\n", it->this_idx, it->other_idx,
38 it->this_x, it->this_y, it->this_z, it->other_x, it->other_y,
39 it->other_z, it->errorSquareAfterTransformation);
48 FILE* f =
os::fopen(filName.c_str(),
"wt");
50 fprintf(f,
"%% ----------------------------------------------------\n");
51 fprintf(f,
"%% File generated automatically by the MRPT method:\n");
52 fprintf(f,
"%% saveAsMATLABScript \n");
54 f,
"%% Before calling this script, define the color of lines, eg:\n");
55 fprintf(f,
"%% colorLines=[1 1 1]");
56 fprintf(f,
"%% J.L. Blanco (C) 2005-2012 \n");
57 fprintf(f,
"%% ----------------------------------------------------\n\n");
59 fprintf(f,
"axis equal; hold on;\n");
63 f,
"line([%f %f],[%f %f],'Color',colorLines);\n", it->this_x,
64 it->other_x, it->this_y, it->other_y);
67 "set(plot([%f %f],[%f "
68 "%f],'.'),'Color',colorLines,'MarkerSize',15);\n",
69 it->this_x, it->other_x, it->this_y, it->other_y);
81 if (it->other_idx == idx)
return true;
88 if (
a.this_idx ==
b.this_idx)
89 return (
a.this_idx <
b.this_idx);
91 return (
a.other_idx <
b.other_idx);
96 return (
a.this_idx ==
b.this_idx) && (
a.other_idx ==
b.other_idx);
102 if (
a.size() !=
b.size())
return false;
104 it1 !=
a.end(); ++it1, ++it2)
105 if (!((*it1) == (*it2)))
return false;
114 vector<float> errs(
size());
115 squareErrorVector(
q, errs);
123 const CPose2D&
q, vector<float>& xs, vector<float>& ys)
const
125 vector<float> errs(
size());
126 squareErrorVector(
q, errs, xs, ys);
136 if (*corresp ==
p)
return true;
144 const CPose2D&
q, vector<float>& out_sqErrs)
const
146 out_sqErrs.resize(
size());
149 const float ccos = cos(
q.phi());
150 const float csin = sin(
q.phi());
151 const float qx =
q.x();
152 const float qy =
q.y();
156 for (corresp =
begin(), e_i = out_sqErrs.begin(); corresp !=
end();
159 float xx = qx + ccos * corresp->other_x - csin * corresp->other_y;
160 float yy = qy + csin * corresp->other_x + ccos * corresp->other_y;
161 *e_i =
square(corresp->this_x - xx) +
square(corresp->this_y - yy);
169 const CPose2D&
q, vector<float>& out_sqErrs, vector<float>& xs,
170 vector<float>& ys)
const
172 out_sqErrs.resize(
size());
178 const float ccos = cos(
q.phi());
179 const float csin = sin(
q.phi());
180 const float qx =
q.x();
181 const float qy =
q.y();
185 for (corresp =
begin(), e_i = out_sqErrs.begin(), xx = xs.begin(),
187 corresp !=
end(); ++corresp, ++e_i, ++xx, ++yy)
189 *xx = qx + ccos * corresp->other_x - csin * corresp->other_y;
190 *yy = qy + csin * corresp->other_x + ccos * corresp->other_y;
191 *e_i =
square(corresp->this_x - *xx) +
square(corresp->this_y - *yy);
196 const size_t num_elements_this_map,
199 std::vector<TMatchingPairConstPtr> bestMatchForThisMap(
201 out_filtered_list.clear();
205 for (
auto&
c : *
this)
207 if (bestMatchForThisMap[
c.this_idx] ==
nullptr ||
208 c.errorSquareAfterTransformation <
209 bestMatchForThisMap[
c.this_idx]
210 ->errorSquareAfterTransformation
213 bestMatchForThisMap[
c.this_idx] = &
c;
219 for (
auto&
c : *
this)
221 if (bestMatchForThisMap[
c.this_idx] == &
c)
222 out_filtered_list.push_back(
c);
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
This CStream derived class allow using a file as a write-only, binary stream.
bool fileOpenCorrectly()
Returns true if the file was open without errors.
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.
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...
void saveAsMATLABScript(const std::string &filName) const
Saves the correspondences as a MATLAB script which draws them.
bool contains(const TMatchingPair &p) const
Test whether the given pair "p" is within the pairings.
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,...
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,...
float overallSquareError(const mrpt::poses::CPose2D &q) const
Computes the overall square error between the 2D points in the list of correspondences,...
void dumpToFile(const std::string &fileName) const
Saves the correspondences to a text file.
bool indexOtherMapHasCorrespondence(size_t idx) const
Checks if the given index from the "other" map appears in the list.
const Scalar * const_iterator
GLubyte GLubyte GLubyte a
GLsizei const GLchar ** string
GLdouble GLdouble GLdouble GLdouble q
int void fclose(FILE *f)
An OS-independent version of fclose.
FILE * fopen(const char *fileName, const char *mode) noexcept
An OS-independent version of fopen.
int fprintf(FILE *fil, const char *format,...) noexcept MRPT_printf_format_check(2
An OS-independent version of fprintf.
This base provides a set of functions for maths stuff.
CONTAINER::Scalar sum(const CONTAINER &v)
Computes the sum of all the elements.
T square(const T x)
Inline function for the square of a number.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
bool operator==(const mrpt::utils::TCamera &a, const mrpt::utils::TCamera &b)
const_iterator end() const
bool operator<(const TMatchingPair &a, const TMatchingPair &b)
A comparison operator, for sorting lists of TMatchingPair's, first order by this_idx,...
TMatchingPair const * TMatchingPairConstPtr
const_iterator begin() const
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
This file implements several operations that operate element-wise on individual or pairs of container...
A structure for holding correspondences between two sets of points or points-like entities in 2D or 3...