44 useOriFilter = cfg.read_bool(section,
"useOriFilter",
true,
false);
45 oriThreshold = cfg.read_double(section,
"oriThreshold", 0.2,
false);
46 lastSeenThreshold = cfg.read_int(section,
"lastSeenThreshold", 10,
false);
47 timesSeenThreshold = cfg.read_int(section,
"timesSeenThreshold", 5,
false);
48 minFeaturesToFind = cfg.read_int(section,
"minFeaturesToFind", 5,
false);
50 cfg.read_int(section,
"minFeaturesToBeLost", 5,
false);
52 useDepthFilter = cfg.read_bool(section,
"useDepthFilter",
true,
false);
55 cfg.read_double(section,
"matchingThreshold", 1e4,
false);
56 matchingRatioThreshold =
57 cfg.read_double(section,
"matchingRatioThreshold", 0.5,
false);
59 lowScl1 = cfg.read_int(section,
"lowScl1", 0,
false);
60 lowScl2 = cfg.read_int(section,
"lowScl1", 0,
false);
61 highScl1 = cfg.read_int(section,
"highScl1", 6,
false);
62 highScl2 = cfg.read_int(section,
"highScl2", 6,
false);
64 searchAreaSize = cfg.read_uint64_t(section,
"searchAreaSize", 20,
false);
75 cfg.
write(section,
"useOriFilter",
"true");
76 cfg.
write(section,
"oriThreshold", oriThreshold);
79 cfg.
write(section,
"useOriFilter",
"false");
82 cfg.
write(section,
"useDepthFilter",
"true");
84 cfg.
write(section,
"useDepthFilter",
"false");
86 cfg.
write(section,
"matchingThreshold", matchingThreshold);
87 cfg.
write(section,
"matchingRatioThreshold", matchingRatioThreshold);
88 cfg.
write(section,
"lowScl1", lowScl1);
89 cfg.
write(section,
"lowScl2", lowScl2);
90 cfg.
write(section,
"highScl1", highScl1);
91 cfg.
write(section,
"highScl2", highScl2);
93 cfg.
write(section,
"searchAreaSize", searchAreaSize);
94 cfg.
write(section,
"lastSeenThreshold", lastSeenThreshold);
95 cfg.
write(section,
"timesSeenThreshold", timesSeenThreshold);
96 cfg.
write(section,
"minFeaturesToFind", minFeaturesToFind);
97 cfg.
write(section,
"minFeaturesToBeLost", minFeaturesToBeLost);
105 out <<
"\n----------- [vision::TMultiResDescMatchOptions] ------------ \n";
106 out <<
"Use orientation filter?: ";
111 "ยท Orientation threshold: %.1f deg\n",
116 out <<
"Use depth filter?: ";
128 "#frames last seen threshold: %d\n", lastSeenThreshold);
130 "#frames to be stable threshold: %d\n", timesSeenThreshold);
132 "min. # features in system: %d\n", minFeaturesToFind);
134 "min. # features to be lost: %d\n", minFeaturesToBeLost);
136 "Matching threshold: %.2f\n", matchingThreshold);
138 "Matching ratio threshold: %.2f\n", matchingRatioThreshold);
140 "Size of the search window: %d px\n", searchAreaSize);
141 out <<
"-------------------------------------------------------- \n";
153 basePSize = cfg.
read_uint64_t(section,
"basePSize", 23,
false);
154 comLScl = cfg.
read_int(section,
"comLScl", 0,
false);
155 comHScl = cfg.
read_int(section,
"comHScl", 6,
false);
159 computeDepth = cfg.
read_bool(section,
"computeDepth",
true,
false);
160 blurImage = cfg.
read_bool(section,
"blurImage",
true,
false);
164 baseline = cfg.
read_double(section,
"baseline", 0.0,
false);
166 cfg.
read_bool(section,
"computeHashCoeffs",
false,
false);
168 cfg.
read_vector(section,
"scales", vector<double>(), scales,
false);
169 if (scales.size() < 1)
188 cfg.
write(section,
"basePSize", basePSize);
189 cfg.
write(section,
"comLScl", comLScl);
190 cfg.
write(section,
"comHScl", comHScl);
191 cfg.
write(section,
"sg1", sg1);
192 cfg.
write(section,
"sg2", sg2);
193 cfg.
write(section,
"sg3", sg3);
195 cfg.
write(section,
"computeDepth", computeDepth ?
"true" :
"false");
196 cfg.
write(section,
"blurImage", blurImage ?
"true" :
"false");
197 cfg.
write(section,
"fx", fx);
198 cfg.
write(section,
"cx", cx);
199 cfg.
write(section,
"cy", cy);
200 cfg.
write(section,
"baseline", baseline);
202 section,
"computeHashCoeffs", computeHashCoeffs ?
"true" :
"false");
205 for (
double scale : scales)
207 cfg.
write(section,
"scales", buf);
215 out <<
"\n----------- [vision::TMultiResDescOptions] ------------ \n";
222 out <<
"Compute depth: ";
230 "Baseline: %.2f m\n", baseline);
235 out <<
"Compute Hash Coeffs: ";
236 if (computeHashCoeffs)
241 out <<
"Blur image previously: ";
250 out <<
"-------------------------------------------------------- \n";
255 out <<
"\n----------- [vision::CFeature] ------------ \n";
257 "Feature ID: %d\n", (
int)keypoint.ID);
259 "Coordinates: (%.2f,%.2f) px\n", keypoint.pt.x,
263 out << mrpt::typemeta::TEnumType<decltype(type)>::value2name(type) <<
"\n";
265 switch (track_status)
271 out <<
"[KLT] Out of bounds [KLT]\n";
274 out <<
"[KLT] Tracked\n";
277 out <<
"[KLT] Lost\n";
284 "Initial Depth: %.2f m\n", initialDepth);
287 "3D point: (%.2f,%.2f,%.2f) m\n", p3D.x, p3D.y,
289 out <<
"Is point feature?: ";
290 isPointFeature() ?
out <<
"Yes\n" :
out <<
"No\n";
292 out <<
"Has SIFT descriptor?: ";
293 descriptors.hasDescriptorSIFT() ?
out <<
"Yes\n" :
out <<
"No\n";
294 out <<
"Has SURF descriptor?: ";
295 descriptors.hasDescriptorSURF() ?
out <<
"Yes\n" :
out <<
"No\n";
296 out <<
"Has Spin image descriptor?: ";
297 descriptors.hasDescriptorSpinImg() ?
out <<
"Yes\n" :
out <<
"No\n";
298 out <<
"Has Polar descriptor?: ";
299 descriptors.hasDescriptorPolarImg() ?
out <<
"Yes\n" :
out <<
"No\n";
300 out <<
"Has Log Polar descriptor?: ";
301 descriptors.hasDescriptorLogPolarImg() ?
out <<
"Yes\n" :
out <<
"No\n";
302 out <<
"Has ORB descriptor?: ";
303 descriptors.hasDescriptorORB() ?
out <<
"Yes\n" :
out <<
"No\n";
305 out <<
"Has BLD descriptor?: ";
306 descriptors.hasDescriptorBLD() ?
out <<
"Yes\n" :
out <<
"No\n";
307 out <<
"Has LATCH descriptor?: ";
308 descriptors.hasDescriptorLATCH() ?
out <<
"Yes\n" :
out <<
"No\n";
317 out << keypoint.pt.x << keypoint.pt.y << keypoint.ID << patch << patchSize
318 << (uint32_t)type << (uint32_t)keypoint.track_status
319 << keypoint.response << orientation << keypoint.octave << user_flags
320 << depth << initialDepth << p3D << descriptors.SIFT << descriptors.SURF
321 << descriptors.SpinImg << descriptors.SpinImg_range_rows
322 << descriptors.PolarImg << descriptors.LogPolarImg
323 << descriptors.polarImgsNoRotation << descriptors.ORB << descriptors.BLD
324 << descriptors.LATCH;
336 uint32_t aux_type, aux_KLTS;
337 in >> keypoint.pt.x >> keypoint.pt.y >> keypoint.ID >> patch >>
338 patchSize >> aux_type >> aux_KLTS >> keypoint.response >>
339 orientation >> keypoint.octave >> user_flags;
342 in >> depth >> initialDepth >> p3D;
344 in >> descriptors.SIFT >> descriptors.SURF >> descriptors.SpinImg >>
345 descriptors.SpinImg_range_rows >> descriptors.PolarImg >>
346 descriptors.LogPolarImg >> descriptors.polarImgsNoRotation >>
347 descriptors.BLD >> descriptors.LATCH;
348 if (version > 1) in >> descriptors.ORB;
377 ASSERT_(patch->getWidth() == oFeature.
patch->getWidth());
378 ASSERT_(patch->getHeight() == oFeature.
patch->getHeight());
379 ASSERT_(patch->getHeight() > 0 && patch->getWidth() > 0);
383 *patch, *oFeature.
patch, x_max, y_max, max_val);
386 return d2f(0.5 - 0.5 * max_val);
396 bool normalize_distances)
const 401 if (descriptorToUse ==
descAny)
403 if (descriptors.hasDescriptorSIFT())
405 else if (descriptors.hasDescriptorSURF())
407 else if (descriptors.hasDescriptorSpinImg())
409 else if (descriptors.hasDescriptorPolarImg())
411 else if (descriptors.hasDescriptorLogPolarImg())
413 else if (descriptors.hasDescriptorORB())
416 else if (descriptors.hasDescriptorBLD())
418 else if (descriptors.hasDescriptorLATCH())
422 "Feature has no descriptors and descriptorToUse=descAny");
425 switch (descriptorToUse)
428 return descriptorSIFTDistanceTo(oFeature, normalize_distances);
430 return descriptorSURFDistanceTo(oFeature, normalize_distances);
432 return descriptorSpinImgDistanceTo(oFeature, normalize_distances);
436 return descriptorPolarImgDistanceTo(
437 oFeature, minAng, normalize_distances);
442 return descriptorLogPolarImgDistanceTo(
443 oFeature, minAng, normalize_distances);
446 return float(descriptorORBDistanceTo(oFeature));
449 return (descriptorBLDDistanceTo(oFeature));
451 return (descriptorLATCHDistanceTo(oFeature));
454 "Unknown value for 'descriptorToUse'=%u",
455 (
unsigned)descriptorToUse);
465 const CFeature& oFeature,
bool normalize_distances)
const 471 descriptors.hasDescriptorSIFT() &&
475 std::vector<unsigned char>::const_iterator itDesc1, itDesc2;
476 for (itDesc1 = descriptors.SIFT->begin(),
478 itDesc1 != descriptors.SIFT->end(); itDesc1++, itDesc2++)
480 dist +=
square(*itDesc1 - *itDesc2);
482 if (normalize_distances) dist /= descriptors.SIFT->size();
484 if (normalize_distances) dist /= 64.0f;
492 const CFeature& oFeature,
bool normalize_distances)
const 497 descriptors.hasDescriptorSURF() &&
501 std::vector<float>::const_iterator itDesc1, itDesc2;
502 for (itDesc1 = descriptors.SURF->begin(),
504 itDesc1 != descriptors.SURF->end(); itDesc1++, itDesc2++)
506 dist +=
square(*itDesc1 - *itDesc2);
508 if (normalize_distances) dist /= descriptors.SURF->size();
510 if (normalize_distances)
520 const CFeature& oFeature,
bool normalize_by_vector_length)
const 527 descriptors.hasDescriptorSpinImg() &&
529 ASSERT_(!descriptors.SpinImg->empty());
531 std::vector<float>::const_iterator itDesc1, itDesc2;
532 for (itDesc1 = descriptors.SpinImg->begin(),
534 itDesc1 != descriptors.SpinImg->end(); itDesc1++, itDesc2++)
536 dist +=
square(*itDesc1 - *itDesc2);
539 if (normalize_by_vector_length) dist /= 0.25f * descriptors.SpinImg->size();
549 bool normalize_distances,
bool dont_shift_angle)
554 unsigned int delta, i, j, ii, height = desc1.
rows(), width = desc1.
cols();
555 float dist, minDist = 0;
559 #define LM_CORR_METHOD_EUCLID 563 #if defined(LM_CORR_BIAS_MEAN) || defined(LM_CORR_METHOD_CORRELATION) 564 const float desc1_mean = desc1.
sum() /
d2f(width * height);
565 const float desc2_mean = desc2.
sum() /
d2f(width * height);
570 for (delta = 0; delta < height; delta++)
572 #if defined(LM_CORR_METHOD_CORRELATION) 579 for (i = 0; i < height; i++)
581 ii = (i + delta) % height;
582 for (j = 0; j < width; j++)
584 #ifdef LM_CORR_METHOD_EUCLID 585 #ifdef LM_CORR_BIAS_MEAN 587 desc1(i, j) - desc1_mean - desc2(ii, j) + desc2_mean);
589 dist +=
square(desc1(i, j) - desc2(ii, j));
591 #elif defined(LM_CORR_METHOD_MANHATTAN) 592 #ifdef LM_CORR_BIAS_MEAN 594 desc1(i, j) - desc1_mean - desc2(ii, j) + desc2_mean);
596 dist += std::abs(desc1(i, j) - desc2(ii, j));
598 #elif defined(LM_CORR_METHOD_CORRELATION) 599 float d1 = desc1(i, j) - desc1_mean;
600 float d2 = desc2(ii, j) - desc2_mean;
605 #error A LM_CORR_METHOD_XXX method must be selected! 611 if (normalize_distances) dist /=
d2f(width * height);
613 #ifdef LM_CORR_METHOD_EUCLID 617 #if defined(LM_CORR_METHOD_CORRELATION) 618 dist = 1 - (s12 / sqrt(s11 * s22));
621 distances[delta] = dist;
622 if (!delta && dont_shift_angle)
630 minDist = distances.
minCoeff(minDistIdx);
632 double dist_mean, dist_std;
637 cout <<
"min dist: " << minDist << endl;
640 win.plot(distances,
"b.4");
642 win.image(img1,0,-0.5,0.4*width,0.5,
"img1");
645 win.image(img2,0.6*width,-0.5,0.4*width,0.5,
"img2");
653 minDistAngle = minDistIdx *
d2f(
M_2PI / width);
663 const CFeature& oFeature,
float& minDistAngle,
664 bool normalize_distances)
const 674 descriptors.hasDescriptorPolarImg() &&
680 return internal_distanceBetweenPolarImages(
682 normalize_distances, descriptors.polarImgsNoRotation);
691 const CFeature& oFeature,
float& minDistAngle,
692 bool normalize_distances)
const 696 ASSERT_(descriptors.LogPolarImg);
698 descriptors.LogPolarImg->rows() ==
701 descriptors.LogPolarImg->cols() ==
704 descriptors.hasDescriptorLogPolarImg() &&
707 descriptors.LogPolarImg->rows() > 1 &&
708 descriptors.LogPolarImg->cols() > 1);
711 return internal_distanceBetweenPolarImages(
713 minDistAngle, normalize_distances, descriptors.polarImgsNoRotation);
724 descriptors.hasDescriptorORB() &&
727 const std::vector<uint8_t>& t_desc = *descriptors.ORB;
732 for (uint8_t k = 0; k < t_desc.size(); ++k)
737 uint8_t x_or = t_desc[k] ^ o_desc[k];
739 for (count = 0; x_or; count++)
752 const CFeature& oFeature,
bool normalize_distances)
const 756 descriptors.hasDescriptorBLD() &&
760 std::vector<unsigned char>::const_iterator itDesc1, itDesc2;
761 for (itDesc1 = descriptors.BLD->begin(),
763 itDesc1 != descriptors.BLD->end(); itDesc1++, itDesc2++)
765 dist +=
square(*itDesc1 - *itDesc2);
767 if (normalize_distances) dist /= descriptors.BLD->size();
769 if (normalize_distances) dist /= 64.0f;
777 const CFeature& oFeature,
bool normalize_distances)
const 781 descriptors.hasDescriptorLATCH() &&
785 std::vector<unsigned char>::const_iterator itDesc1, itDesc2;
786 for (itDesc1 = descriptors.LATCH->begin(),
788 itDesc1 != descriptors.LATCH->end(); itDesc1++, itDesc2++)
790 dist +=
square(*itDesc1 - *itDesc2);
792 if (normalize_distances) dist /= descriptors.LATCH->size();
794 if (normalize_distances) dist /= 64.0f;
821 if (!f.open(filename, APPEND))
823 "[CFeature::saveToTextFile] ERROR: File could not be open for " 827 "%5u %2d %7.3f %7.3f %6.2f %2d %2d %6.3f ", (
unsigned int)keypoint.ID,
828 (
int)get_type(), keypoint.pt.x, keypoint.pt.y, orientation,
829 keypoint.octave, (
int)keypoint.track_status, keypoint.response);
831 f.printf(
"%2d ",
int(descriptors.hasDescriptorSIFT() ? 1 : 0));
832 if (descriptors.hasDescriptorSIFT())
834 f.printf(
"%4d ",
int(descriptors.SIFT->size()));
835 for (
unsigned char k : *descriptors.SIFT) f.printf(
"%4d ", k);
838 f.printf(
"%2d ",
int(descriptors.hasDescriptorSURF() ? 1 : 0));
839 if (descriptors.hasDescriptorSURF())
841 f.printf(
"%4d ",
int(descriptors.SURF->size()));
842 for (
float k : *descriptors.SURF) f.printf(
"%8.5f ", k);
845 f.printf(
"%2d ",
int(descriptors.hasDescriptorORB() ? 1 : 0));
846 if (descriptors.hasDescriptorORB())
847 for (
unsigned char k : *descriptors.ORB) f.printf(
"%d ", k);
850 f.printf(
"%2d ",
int(descriptors.hasDescriptorBLD() ? 1 : 0));
851 if (descriptors.hasDescriptorBLD())
853 f.printf(
"%4d ",
int(descriptors.BLD->size()));
854 for (
unsigned char k : *descriptors.BLD) f.printf(
"%4d ", k);
857 f.printf(
"%2d ",
int(descriptors.hasDescriptorLATCH() ? 1 : 0));
858 if (descriptors.hasDescriptorLATCH())
860 f.printf(
"%4d ",
int(descriptors.LATCH->size()));
861 for (
unsigned char k : *descriptors.LATCH) f.printf(
"%4d ", k);
887 if (!f.open(filename, APPEND))
889 "[CFeatureList::saveToTextFile] ERROR: File could not be open for " 893 "%% Dump of mrpt::vision::CFeatureList. Each line format is:\n" 894 "%% ID TYPE X Y ORIENTATION SCALE TRACK_STATUS RESPONSE HAS_SIFT " 895 "[SIFT] HAS_SURF [SURF]\n" 896 "%% \\---------------------- feature ------------------/ \\--------- " 897 "descriptors -------/\n" 899 "%% TYPE : The used detector: 0:KLT, 1: Harris, 2: BCD, 3: SIFT, 4: " 900 "SURF, 5: Beacon, 6: FAST\n" 901 "%% HAS_* : 1 if a descriptor of that type is associated to the " 903 "%% SIFT : Present if HAS_SIFT=1: N DESC_0 ... DESC_N-1 \n" 904 "%% SURF : Present if HAS_SURF=1: N DESC_0 ... DESC_N-1 \n" 905 "%%--------------------------------------------------------------------" 906 "-----------------------\n");
908 for (
auto& feat : *
this)
911 "%5u %2d %7.3f %7.3f %6.2f %2d %2d %6.3f ",
912 (
unsigned int)feat.keypoint.ID, (
int)feat.get_type(),
913 feat.keypoint.pt.x, feat.keypoint.pt.y, feat.orientation,
914 feat.keypoint.octave, (int)feat.track_status, feat.response);
916 f.printf(
"%2d ",
int(feat.descriptors.hasDescriptorSIFT() ? 1 : 0));
917 if (feat.descriptors.hasDescriptorSIFT())
919 f.printf(
"%4d ",
int(feat.descriptors.SIFT->size()));
920 for (
unsigned int k = 0; k < feat.descriptors.SIFT->size(); k++)
921 f.printf(
"%4d ", (*feat.descriptors.SIFT)[k]);
924 f.printf(
"%2d ",
int(feat.descriptors.hasDescriptorSURF() ? 1 : 0));
925 if (feat.descriptors.hasDescriptorSURF())
927 f.printf(
"%4d ",
int(feat.descriptors.SURF->size()));
928 for (
unsigned int k = 0; k < feat.descriptors.SURF->size(); k++)
929 f.printf(
"%8.5f ", (*feat.descriptors.SURF)[k]);
932 f.printf(
"%2d ",
int(feat.descriptors.hasDescriptorBLD() ? 1 : 0));
933 if (feat.descriptors.hasDescriptorBLD())
935 f.printf(
"%4d ",
int(feat.descriptors.BLD->size()));
936 for (
unsigned int k = 0; k < feat.descriptors.BLD->size(); k++)
937 f.printf(
"%4d ", (*feat.descriptors.BLD)[k]);
940 f.printf(
"%2d ",
int(feat.descriptors.hasDescriptorLATCH() ? 1 : 0));
941 if (feat.descriptors.hasDescriptorLATCH())
943 f.printf(
"%4d ",
int(feat.descriptors.LATCH->size()));
944 for (
unsigned int k = 0; k < feat.descriptors.LATCH->size(); k++)
945 f.printf(
"%4d ", (*feat.descriptors.LATCH)[k]);
964 std::istringstream line;
966 while (parser.getNextLine(line))
973 if (!(line >> _ID))
throw std::string(
"ID");
977 if (!(line >> _type))
throw std::string(
"type");
981 throw std::string(
"x,y");
982 if (!(line >> feat.
orientation))
throw std::string(
"orientation");
986 if (!(line >> _track_st))
throw std::string(
"track_status");
989 if (!(line >> feat.
response))
throw std::string(
"response");
992 if (!(line >> hasSIFT))
throw std::string(
"hasSIFT");
996 if (!(line >> N))
throw std::string(
"SIFT-len");
998 for (
size_t i = 0; i < N; i++)
1007 if (!line)
throw std::string(
"SIFT-data");
1012 if (!(line >> hasBLD))
throw std::string(
"hasBLD");
1016 if (!(line >> N))
throw std::string(
"BLD-len");
1018 for (
size_t i = 0; i < N; i++)
1025 if (!line)
throw std::string(
"BLD-data");
1029 if (!(line >> hasLATCH))
throw std::string(
"hasLATCH");
1033 if (!(line >> N))
throw std::string(
"LATCH-len");
1035 for (
size_t i = 0; i < N; i++)
1042 if (!line)
throw std::string(
"LATCH-data");
1046 if (!(line >> hasSURF))
throw std::string(
"hasSURF");
1050 if (!(line >> N))
throw std::string(
"SURF-len");
1052 for (
size_t i = 0; i < N; i++)
1054 if (!line)
throw std::string(
"SURF-data");
1057 emplace_back(std::move(feat));
1059 catch (std::string& msg)
1062 "%s:%d: Error parsing features text file (%s).",
1063 filename.c_str(), (int)parser.getCurrentLineNumber(),
1079 for (it1 = otherList.
begin(), it2 =
begin(); it1 != otherList.
end();
1088 for (
const auto& f : *
this)
1089 if (f.keypoint.ID == ID)
return &f;
1097 for (
auto it =
begin(); it !=
end(); ++it, ++k)
1098 if (it->keypoint.ID == ID)
1111 const float x,
const float y,
double& dist_prev)
const 1113 if (
empty())
return nullptr;
1115 float closest_x, closest_y;
1116 float closest_sqDist;
1119 const size_t closest_idx =
1120 kdTreeClosestPoint2D(x, y, closest_x, closest_y, closest_sqDist);
1121 float closest_dist = std::sqrt(closest_sqDist);
1123 if (closest_dist <= dist_prev)
1125 dist_prev = closest_dist;
1126 return &m_feats[closest_idx];
1140 for (
const auto& f : *
this)
mrpt::keep_max(maxID, f.keypoint.ID);
1153 FILE* f =
os::fopen(filename.c_str(),
"wt");
1156 for (
const auto& p : *
this)
1159 f,
"%d %.3f %.3f %d %.3f %.3f\n",
1160 (
unsigned int)(p.first.keypoint.ID), p.first.keypoint.pt.x,
1161 p.first.keypoint.pt.y, (
unsigned int)(p.second.keypoint.ID),
1162 p.second.keypoint.pt.x, p.second.keypoint.pt.y);
1174 CMatchedFeatureList::iterator it;
1175 for (it =
begin(); it !=
end(); ++it)
1177 const auto& feat = (idx ==
firstList) ? it->first : it->second;
1178 if (feat.keypoint.ID == ID)
return &feat;
1191 for (
auto itList =
begin(); itList !=
end(); itList++)
1212 if (m_leftMaxID == 0) updateMaxID(
firstList);
1214 if (m_rightMaxID == 0) updateMaxID(
secondList);
1215 firstListID = m_leftMaxID;
1216 secondListID = m_rightMaxID;
1230 for (
auto it =
begin(); it !=
end(); ++it, ++k)
1232 list1[k] = it->first;
1233 list2[k] = it->second;
1243 if (descriptors.hasDescriptorSIFT())
1245 desc.
setSize(1, descriptors.SIFT->size());
1246 for (
size_t i = 0; i < descriptors.SIFT->size(); i++)
1247 desc(0, i) = (*descriptors.SIFT)[i];
1250 else if (descriptors.hasDescriptorBLD())
1252 desc.
setSize(1, descriptors.BLD->size());
1253 for (
size_t i = 0; i < descriptors.BLD->size(); i++)
1254 desc(0, i) = (*descriptors.BLD)[i];
1257 else if (descriptors.hasDescriptorLATCH())
1259 desc.
setSize(1, descriptors.LATCH->size());
1260 for (
size_t i = 0; i < descriptors.LATCH->size(); i++)
1261 desc(0, i) = (*descriptors.LATCH)[i];
1264 else if (descriptors.hasDescriptorSURF())
1266 desc.
setSize(1, descriptors.SURF->size());
1267 for (
size_t i = 0; i < descriptors.SURF->size(); i++)
1268 desc(0, i) = (*descriptors.SURF)[i];
1271 else if (descriptors.hasDescriptorSpinImg())
1273 const size_t nR = descriptors.SpinImg_range_rows;
1275 descriptors.SpinImg->
size() / descriptors.SpinImg_range_rows;
1277 auto itD = descriptors.SpinImg->begin();
1278 for (
size_t r = 0; r < nR; r++)
1279 for (
size_t c = 0; c < nC; c++) desc.
coeffRef(r, c) = *itD++;
1282 else if (descriptors.hasDescriptorPolarImg())
1284 desc = *descriptors.PolarImg;
1287 else if (descriptors.hasDescriptorLogPolarImg())
1289 desc = *descriptors.LogPolarImg;
void updateMaxID(const TListIdx &idx)
Updates the value of the maximum ID of the features in the matched list, i.e.
float descriptorDistanceTo(const CFeature &oFeature, TDescriptorType descriptorToUse=descAny, bool normalize_distances=true) const
Computes the Euclidean Distance between this feature's and other feature's descriptors, using the given descriptor or the first present one.
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
uint8_t descriptorORBDistanceTo(const CFeature &oFeature) const
Computes the Hamming distance "this" and the "other" descriptor ORB descriptor.
uint64_t TFeatureID
Definition of a feature ID.
float descriptorSpinImgDistanceTo(const CFeature &oFeature, bool normalize_distances=true) const
Computes the Euclidean Distance between "this" and the "other" descriptors.
bool hasDescriptorBLD() const
void resize(size_t row, size_t col)
TInternalFeatList::iterator iterator
std::optional< std::vector< uint8_t > > ORB
ORB feature descriptor.
void loadFromTextFile(const std::string &fileName)
Save feature list to a text file.
Template for column vectors of dynamic size, compatible with Eigen.
#define THROW_EXCEPTION(msg)
Create a GUI window and display plots with MATLAB-like interfaces and commands.
std::string std::string format(std::string_view fmt, ARGS &&... args)
size_t size(const MATRIXLIKE &m, const int dim)
std::optional< std::vector< uint8_t > > BLD
BLD feature descriptor.
int void fclose(FILE *f)
An OS-independent version of fclose.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
bool hasDescriptorLogPolarImg() const
TKeyPointMethod type
Keypoint method used to detect this feature.
TFeatureTrackStatus track_status
Status of the feature tracking process.
Intensity-domain spin image descriptors.
bool hasDescriptorSpinImg() const
void dumpToConsole() const
float descriptorSIFTDistanceTo(const CFeature &oFeature, bool normalize_distances=true) const
Computes the Euclidean Distance between "this" and the "other" descriptors.
float descriptorSURFDistanceTo(const CFeature &oFeature, bool normalize_distances=true) const
Computes the Euclidean Distance between "this" and the "other" descriptors.
Bit-based feature descriptor.
A class for parsing text files, returning each non-empty and non-comment line, along its line number...
bool hasDescriptorSIFT() const
Scale Invariant Feature Transform [LOWE'04].
TFeatureID ID
ID of the feature.
void saveToConfigFile(mrpt::config::CConfigFileBase &cfg, const std::string §ion) const override
This method saves the options to a ".ini"-like file or memory-stored string list. ...
Used in some methods to mean "any of the present descriptors".
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
#define ASSERT_(f)
Defines an assertion mechanism.
float d2f(const double d)
shortcut for static_cast<float>(double)
void dumpToTextStream(std::ostream &out) const
Dump feature information into a text stream.
void getBothFeatureLists(CFeatureList &list1, CFeatureList &list2)
Returns the matching features as two separate CFeatureLists.
void saveToTextFile(const std::string &filename, bool APPEND=false)
Save the feature to a text file in this format: "%% Dump of mrpt::vision::CFeatureList. Each line format is:\n" "%% ID TYPE X Y ORIENTATION SCALE TRACK_STATUS RESPONSE HAS_SIFT [SIFT] HAS_SURF [SURF] HAS_MULTI [MULTI_i] HAS_ORB [ORB]" "%% |---------------------- feature ------------------| |---------------------- descriptors ------------------------|" "%% with:\n" "%% TYPE : The used detector: 0:KLT, 1: Harris, 2: BCD, 3: SIFT, 4: SURF, 5: Beacon, 6: FAST, 7: ORB\n" "%% HAS_* : 1 if a descriptor of that type is associated to the feature.
This class allows loading and storing values and vectors of different types from a configuration text...
This base provides a set of functions for maths stuff.
std::optional< mrpt::img::CImage > patch
A patch of the image surrounding the feature.
void getMaxID(const TListIdx &idx, TFeatureID &firstListID, TFeatureID &secondListID)
Returns the maximum ID of the features in the list.
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
mrpt::config::CConfigFileBase CConfigFileBase
TKeyPointMethod
Types of key point detectors.
TDescriptorType
The bitwise OR combination of values of TDescriptorType are used in CFeatureExtraction::computeDescri...
uint64_t read_uint64_t(const std::string §ion, const std::string &name, uint64_t defaultValue, bool failIfNotFound=false) const
Classes for computer vision, detectors, features, etc.
A generic 2D feature from an image, extracted with CFeatureExtraction Each feature may have one or mo...
double read_double(const std::string §ion, const std::string &name, double defaultValue, bool failIfNotFound=false) const
float descriptorLATCHDistanceTo(const CFeature &oFeature, bool normalize_distances=true) const
Computes the Euclidean Distance between "this" and the "other" descriptors.
static float internal_distanceBetweenPolarImages(const mrpt::math::CMatrixF &desc1, const mrpt::math::CMatrixF &desc2, float &minDistAngle, bool normalize_distances, bool dont_shift_angle)
Internal function used by "descriptorLogPolarImgDistanceTo" and "descriptorPolarImgDistanceTo".
Speeded Up Robust Feature [BAY'06].
This CStream derived class allow using a file as a write-only, binary stream.
bool hasDescriptorORB() const
mrpt::gui::CDisplayWindow3D::Ptr win
void saveToTextFile(const std::string &fileName)
Save list of matched features to a text file.
size_type rows() const
Number of rows in the matrix.
const CFeature * getByID(const TFeatureID &ID) const
Get a reference to a Feature from its ID.
A list of visual features, to be used as output by detectors, as input/output by trackers, etc.
size_type cols() const
Number of columns in the matrix.
const CFeature * nearest(const float x, const float y, double &max_dist) const
Get a reference to the nearest feature to the a given 2D point (version returning distance to closest...
void write(const std::string §ion, 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())
TInternalFeatList::const_iterator const_iterator
void keep_max(T &var, const K test_val)
If the second argument is above the first one, set the first argument to this higher value...
int fprintf(FILE *fil, const char *format,...) noexcept MRPT_printf_format_check(2
An OS-independent version of fprintf.
void dumpToTextStream(std::ostream &out) const override
This method should clearly display all the contents of the structure in textual form, sending it to a std::ostream.
std::optional< mrpt::math::CMatrixF > PolarImg
A polar image centered at the interest point.
return_t square(const num_t x)
Inline function for the square of a number.
bool hasDescriptorLATCH() const
void saveToTextFile(const std::string &fileName, bool APPEND=false)
Save feature list to a text file.
float response
A measure of the "goodness" of the feature.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
bool getFirstDescriptorAsMatrix(mrpt::math::CMatrixFloat &desc) const
Return the first found descriptor, as a matrix.
virtual ~CFeatureList()
Virtual destructor.
const_iterator end() const
This class is a "CSerializable" wrapper for "CMatrixFloat".
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void saveToConfigFile(mrpt::config::CConfigFileBase &cfg, const std::string §ion) const override
This method saves the options to a ".ini"-like file or memory-stored string list. ...
const_iterator begin() const
Virtual base class for "archives": classes abstracting I/O streams.
void meanAndStd(const VECTORLIKE &v, double &out_mean, double &out_std, bool unbiased=true)
Computes the standard deviation of a vector (or all elements of a matrix)
std::optional< std::vector< uint8_t > > SIFT
SIFT feature descriptor.
void dumpToTextStream(std::ostream &out) const override
This method should clearly display all the contents of the structure in textual form, sending it to a std::ostream.
Scalar sum() const
Sum of all elements in matrix/vector.
void loadFromConfigFile(const mrpt::config::CConfigFileBase &source, const std::string §ion) override
Load all the params from a config source, in the format described in saveToConfigFile() ...
mrpt::vision::TStereoCalibResults out
bool read_bool(const std::string §ion, const std::string &name, bool defaultValue, bool failIfNotFound=false) const
const CFeature * getByID(const TFeatureID &ID, const TListIdx &idx)
Returns a smart pointer to the feature with the provided ID or a empty one if not found...
float descriptorPolarImgDistanceTo(const CFeature &oFeature, float &minDistAngle, bool normalize_distances=true) const
Returns the minimum Euclidean Distance between "this" and the "other" polar image descriptor...
matrix_size_t size() const
Get a 2-vector with [NROWS NCOLS] (as in MATLAB command size(x))
std::optional< std::vector< float > > SURF
SURF feature descriptor.
constexpr double RAD2DEG(const double x)
Radians to degrees.
#define ASSERT_ABOVE_(__A, __B)
void setSize(size_t row, size_t col, bool zeroNewElements=false)
Changes the size of matrix, maintaining the previous contents.
uint8_t octave
The image octave the image was found in: 0=original image, 1=1/2 image, 2=1/4 image, etc.
float patchCorrelationTo(const CFeature &oFeature) const
Computes the normalized cross-correlation between the patches of this and another feature (normalized...
TFeatureID getMaxID() const
Get the maximum ID into the list.
Struct containing the options when matching multi-resolution SIFT-like descriptors.
Scalar minCoeff() const
Minimum value in the matrix/vector.
FILE * fopen(const char *fileName, const char *mode) noexcept
An OS-independent version of fopen.
bool hasDescriptorPolarImg() const
Log-Polar image descriptor.
float orientation
Main orientation of the feature.
void resize(std::size_t N, bool zeroNewElements=false)
void openCV_cross_correlation(const mrpt::img::CImage &img, const mrpt::img::CImage &patch_img, size_t &x_max, size_t &y_max, double &max_val, int x_search_ini=-1, int y_search_ini=-1, int x_search_size=-1, int y_search_size=-1)
Computes the correlation between this image and another one, encapsulating the openCV function cvMatc...
float descriptorLogPolarImgDistanceTo(const CFeature &oFeature, float &minDistAngle, bool normalize_distances=true) const
Returns the minimum Euclidean Distance between "this" and the "other" log-polar image descriptor...
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
This template class provides the basic functionality for a general 2D any-size, resizable container o...
float descriptorBLDDistanceTo(const CFeature &oFeature, bool normalize_distances=true) const
Computes the Euclidean Distance between "this" and the "other" descriptors.
double distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
std::optional< std::vector< float > > SpinImg
The 2D histogram as a single row.
std::optional< mrpt::math::CMatrixF > LogPolarImg
A log-polar image centered at the interest point.
int sprintf(char *buf, size_t bufSize, const char *format,...) noexcept MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
pixel_coords_t pt
Coordinates in the image.
void copyListFrom(const CFeatureList &otherList)
Copies the content of another CFeatureList inside this one.
void read_vector(const std::string §ion, const std::string &name, const VECTOR_TYPE &defaultValue, VECTOR_TYPE &outValues, bool failIfNotFound=false) const
Reads a configuration parameter of type vector, stored in the file as a string: "[v1 v2 v3 ...
A class for storing images as grayscale or RGB bitmaps.
bool isPointFeature() const
Return false only for Blob detectors (SIFT, SURF)
Scalar & coeffRef(int r, int c)
bool hasDescriptorSURF() const
std::optional< std::vector< uint8_t > > LATCH
LATCH feature descriptor.