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_double(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);
106 "\n----------- [vision::TMultiResDescMatchOptions] ------------ \n");
112 "ยท Orientation threshold: %.1f deg\n",
123 out <<
mrpt::format(
"Lowest scale in list1: %d\n", lowScl1);
124 out <<
mrpt::format(
"Highest scale in list1: %d\n", highScl1);
125 out <<
mrpt::format(
"Lowest scale in list2: %d\n", lowScl2);
126 out <<
mrpt::format(
"Highest scale in list2: %d\n", highScl2);
129 "#frames last seen threshold: %d\n", lastSeenThreshold);
131 "#frames to be stable threshold: %d\n", timesSeenThreshold);
133 "min. # features in system: %d\n", minFeaturesToFind);
135 "min. # features to be lost: %d\n", minFeaturesToBeLost);
137 "Matching threshold: %.2f\n", matchingThreshold);
139 "Matching ratio threshold: %.2f\n", matchingRatioThreshold);
141 "Size of the search window: %d px\n", searchAreaSize);
143 "-------------------------------------------------------- \n");
155 basePSize = cfg.
read_double(section,
"basePSize", 23,
false);
156 comLScl = cfg.
read_int(section,
"comLScl", 0,
false);
157 comHScl = cfg.
read_int(section,
"comHScl", 6,
false);
161 computeDepth = cfg.
read_bool(section,
"computeDepth",
true,
false);
162 blurImage = cfg.
read_bool(section,
"blurImage",
true,
false);
166 baseline = cfg.
read_double(section,
"baseline", 0.0,
false);
168 cfg.
read_bool(section,
"computeHashCoeffs",
false,
false);
170 cfg.
read_vector(section,
"scales", vector<double>(), scales,
false);
171 if (scales.size() < 1)
190 cfg.
write(section,
"basePSize", basePSize);
191 cfg.
write(section,
"comLScl", comLScl);
192 cfg.
write(section,
"comHScl", comHScl);
193 cfg.
write(section,
"sg1", sg1);
194 cfg.
write(section,
"sg2", sg2);
195 cfg.
write(section,
"sg3", sg3);
197 cfg.
write(section,
"computeDepth", computeDepth ?
"true" :
"false");
198 cfg.
write(section,
"blurImage", blurImage ?
"true" :
"false");
199 cfg.
write(section,
"fx", fx);
200 cfg.
write(section,
"cx", cx);
201 cfg.
write(section,
"cy", cy);
202 cfg.
write(section,
"baseline", baseline);
204 section,
"computeHashCoeffs", computeHashCoeffs ?
"true" :
"false");
207 for (
double scale : scales)
209 cfg.
write(section,
"scales", buf);
218 "\n----------- [vision::TMultiResDescOptions] ------------ \n");
219 out <<
mrpt::format(
"Base patch size: %d px\n", basePSize);
220 out <<
mrpt::format(
"Lowest scale to compute: %d\n", comLScl);
221 out <<
mrpt::format(
"Highest scale to compute: %d\n", comHScl);
222 out <<
mrpt::format(
"Image smoothing sigma: %.2f px\n", sg1);
223 out <<
mrpt::format(
"Orientation histogram sigma: %.2f\n", sg2);
224 out <<
mrpt::format(
"Descriptor histogram sigma: %.2f\n", sg3);
230 out <<
mrpt::format(
"Principal point (cx): %.2f px\n", cx);
231 out <<
mrpt::format(
"Principal point (cy): %.2f px\n", cy);
233 "Baseline: %.2f m\n", baseline);
239 if (computeHashCoeffs)
254 "-------------------------------------------------------- \n");
259 out <<
mrpt::format(
"\n----------- [vision::CFeature] ------------ \n");
261 "Feature ID: %d\n", (
int)keypoint.ID);
263 "Coordinates: (%.2f,%.2f) px\n", keypoint.pt.x,
267 out << mrpt::typemeta::TEnumType<decltype(type)>::value2name(
type) <<
"\n";
269 switch (track_status)
286 out <<
mrpt::format(
"Main orientation: %.2f\n", orientation);
288 "Initial Depth: %.2f m\n", initialDepth);
291 "3D point: (%.2f,%.2f,%.2f) m\n", p3D.x, p3D.y,
298 descriptors.hasDescriptorSIFT() ? out <<
mrpt::format(
"Yes\n")
301 descriptors.hasDescriptorSURF() ? out <<
mrpt::format(
"Yes\n")
304 descriptors.hasDescriptorSpinImg() ? out <<
mrpt::format(
"Yes\n")
307 descriptors.hasDescriptorPolarImg() ? out <<
mrpt::format(
"Yes\n")
310 descriptors.hasDescriptorLogPolarImg() ? out <<
mrpt::format(
"Yes\n")
313 descriptors.hasDescriptorORB() ? out <<
mrpt::format(
"Yes\n")
317 descriptors.hasDescriptorBLD() ? out <<
mrpt::format(
"Yes\n")
320 descriptors.hasDescriptorLATCH() ? out <<
mrpt::format(
"Yes\n")
330 out << keypoint.pt.x << keypoint.pt.y << keypoint.ID << patch << patchSize
332 << keypoint.response << orientation << keypoint.octave << user_flags
333 <<
depth << initialDepth << p3D << descriptors.SIFT << descriptors.SURF
334 << descriptors.SpinImg << descriptors.SpinImg_range_rows
335 << descriptors.PolarImg << descriptors.LogPolarImg
336 << descriptors.polarImgsNoRotation << descriptors.ORB << descriptors.BLD
337 << descriptors.LATCH;
350 in >> keypoint.pt.x >> keypoint.pt.y >> keypoint.ID >> patch >>
351 patchSize >> aux_type >> aux_KLTS >> keypoint.response >>
352 orientation >> keypoint.octave >> user_flags;
355 in >>
depth >> initialDepth >> p3D;
357 in >> descriptors.SIFT >> descriptors.SURF >> descriptors.SpinImg >>
358 descriptors.SpinImg_range_rows >> descriptors.PolarImg >>
359 descriptors.LogPolarImg >> descriptors.polarImgsNoRotation >>
360 descriptors.BLD >> descriptors.LATCH;
361 if (version > 1)
in >> descriptors.ORB;
390 ASSERT_(patch->getWidth() == oFeature.
patch->getWidth());
391 ASSERT_(patch->getHeight() == oFeature.
patch->getHeight());
392 ASSERT_(patch->getHeight() > 0 && patch->getWidth() > 0);
396 *patch, *oFeature.
patch, x_max, y_max, max_val);
409 bool normalize_distances)
const 414 if (descriptorToUse ==
descAny)
416 if (descriptors.hasDescriptorSIFT())
418 else if (descriptors.hasDescriptorSURF())
420 else if (descriptors.hasDescriptorSpinImg())
422 else if (descriptors.hasDescriptorPolarImg())
424 else if (descriptors.hasDescriptorLogPolarImg())
426 else if (descriptors.hasDescriptorORB())
429 else if (descriptors.hasDescriptorBLD())
431 else if (descriptors.hasDescriptorLATCH())
435 "Feature has no descriptors and descriptorToUse=descAny");
438 switch (descriptorToUse)
441 return descriptorSIFTDistanceTo(oFeature, normalize_distances);
443 return descriptorSURFDistanceTo(oFeature, normalize_distances);
445 return descriptorSpinImgDistanceTo(oFeature, normalize_distances);
449 return descriptorPolarImgDistanceTo(
450 oFeature, minAng, normalize_distances);
455 return descriptorLogPolarImgDistanceTo(
456 oFeature, minAng, normalize_distances);
459 return float(descriptorORBDistanceTo(oFeature));
462 return (descriptorBLDDistanceTo(oFeature));
464 return (descriptorLATCHDistanceTo(oFeature));
467 "Unknown value for 'descriptorToUse'=%u",
468 (
unsigned)descriptorToUse);
478 const CFeature& oFeature,
bool normalize_distances)
const 484 descriptors.hasDescriptorSIFT() &&
488 std::vector<unsigned char>::const_iterator itDesc1, itDesc2;
489 for (itDesc1 = descriptors.SIFT->begin(),
491 itDesc1 != descriptors.SIFT->end(); itDesc1++, itDesc2++)
493 dist +=
square(*itDesc1 - *itDesc2);
495 if (normalize_distances) dist /= descriptors.SIFT->size();
497 if (normalize_distances) dist /= 64.0f;
505 const CFeature& oFeature,
bool normalize_distances)
const 510 descriptors.hasDescriptorSURF() &&
514 std::vector<float>::const_iterator itDesc1, itDesc2;
515 for (itDesc1 = descriptors.SURF->begin(),
517 itDesc1 != descriptors.SURF->end(); itDesc1++, itDesc2++)
519 dist +=
square(*itDesc1 - *itDesc2);
521 if (normalize_distances) dist /= descriptors.SURF->size();
523 if (normalize_distances)
533 const CFeature& oFeature,
bool normalize_by_vector_length)
const 540 descriptors.hasDescriptorSpinImg() &&
542 ASSERT_(!descriptors.SpinImg->empty());
544 std::vector<float>::const_iterator itDesc1, itDesc2;
545 for (itDesc1 = descriptors.SpinImg->begin(),
547 itDesc1 != descriptors.SpinImg->end(); itDesc1++, itDesc2++)
549 dist +=
square(*itDesc1 - *itDesc2);
552 if (normalize_by_vector_length) dist /= 0.25 * descriptors.SpinImg->size();
562 bool normalize_distances,
bool dont_shift_angle)
568 float dist, minDist = 0;
572 #define LM_CORR_METHOD_EUCLID 576 #if defined(LM_CORR_BIAS_MEAN) || defined(LM_CORR_METHOD_CORRELATION) 577 const float desc1_mean = desc1.
sum() /
static_cast<float>(
width *
height);
578 const float desc2_mean = desc2.
sum() /
static_cast<float>(
width *
height);
583 for (delta = 0; delta <
height; delta++)
585 #if defined(LM_CORR_METHOD_CORRELATION) 592 for (i = 0; i <
height; i++)
594 ii = (i + delta) %
height;
595 for (j = 0; j <
width; j++)
597 #ifdef LM_CORR_METHOD_EUCLID 598 #ifdef LM_CORR_BIAS_MEAN 600 desc1(i, j) - desc1_mean - desc2(ii, j) + desc2_mean);
602 dist +=
square(desc1(i, j) - desc2(ii, j));
604 #elif defined(LM_CORR_METHOD_MANHATTAN) 605 #ifdef LM_CORR_BIAS_MEAN 607 abs(desc1(i, j) - desc1_mean - desc2(ii, j) + desc2_mean);
609 dist += abs(desc1(i, j) - desc2(ii, j));
611 #elif defined(LM_CORR_METHOD_CORRELATION) 612 float d1 = desc1(i, j) - desc1_mean;
613 float d2 = desc2(ii, j) - desc2_mean;
618 #error A LM_CORR_METHOD_XXX method must be selected! 624 if (normalize_distances) dist /=
static_cast<float>(
width *
height);
626 #ifdef LM_CORR_METHOD_EUCLID 630 #if defined(LM_CORR_METHOD_CORRELATION) 631 dist = 1 - (s12 / sqrt(s11 * s22));
634 distances[delta] = dist;
635 if (!delta && dont_shift_angle)
643 minDist = distances.
minCoeff(minDistIdx);
645 double dist_mean, dist_std;
650 cout <<
"min dist: " << minDist << endl;
653 win.plot(distances,
"b.4");
655 win.image(img1,0,-0.5,0.4*
width,0.5,
"img1");
666 minDistAngle = minDistIdx *
M_2PI /
static_cast<float>(
width);
676 const CFeature& oFeature,
float& minDistAngle,
677 bool normalize_distances)
const 687 descriptors.hasDescriptorPolarImg() &&
690 descriptors.PolarImg->rows() > 1 && descriptors.PolarImg->cols() > 1);
693 return internal_distanceBetweenPolarImages(
695 normalize_distances, descriptors.polarImgsNoRotation);
704 const CFeature& oFeature,
float& minDistAngle,
705 bool normalize_distances)
const 709 ASSERT_(descriptors.LogPolarImg);
711 descriptors.LogPolarImg->rows() ==
714 descriptors.LogPolarImg->cols() ==
717 descriptors.hasDescriptorLogPolarImg() &&
720 descriptors.LogPolarImg->rows() > 1 &&
721 descriptors.LogPolarImg->cols() > 1);
724 return internal_distanceBetweenPolarImages(
726 minDistAngle, normalize_distances, descriptors.polarImgsNoRotation);
737 descriptors.hasDescriptorORB() &&
740 const std::vector<uint8_t>& t_desc = *descriptors.ORB;
745 for (
uint8_t k = 0; k < t_desc.size(); ++k)
750 uint8_t x_or = t_desc[k] ^ o_desc[k];
765 const CFeature& oFeature,
bool normalize_distances)
const 769 descriptors.hasDescriptorBLD() &&
773 std::vector<unsigned char>::const_iterator itDesc1, itDesc2;
774 for (itDesc1 = descriptors.BLD->begin(),
776 itDesc1 != descriptors.BLD->end(); itDesc1++, itDesc2++)
778 dist +=
square(*itDesc1 - *itDesc2);
780 if (normalize_distances) dist /= descriptors.BLD->size();
782 if (normalize_distances) dist /= 64.0f;
790 const CFeature& oFeature,
bool normalize_distances)
const 794 descriptors.hasDescriptorLATCH() &&
798 std::vector<unsigned char>::const_iterator itDesc1, itDesc2;
799 for (itDesc1 = descriptors.LATCH->begin(),
801 itDesc1 != descriptors.LATCH->end(); itDesc1++, itDesc2++)
803 dist +=
square(*itDesc1 - *itDesc2);
805 if (normalize_distances) dist /= descriptors.LATCH->size();
807 if (normalize_distances) dist /= 64.0f;
834 if (!f.open(filename, APPEND))
836 "[CFeature::saveToTextFile] ERROR: File could not be open for " 840 "%5u %2d %7.3f %7.3f %6.2f %2d %2d %6.3f ", (
unsigned int)keypoint.ID,
841 (
int)get_type(), keypoint.pt.x, keypoint.pt.y, orientation,
842 keypoint.octave, (
int)keypoint.track_status, keypoint.response);
844 f.printf(
"%2d ",
int(descriptors.hasDescriptorSIFT() ? 1 : 0));
845 if (descriptors.hasDescriptorSIFT())
847 f.printf(
"%4d ",
int(descriptors.SIFT->size()));
848 for (
unsigned char k : *descriptors.SIFT) f.printf(
"%4d ", k);
851 f.printf(
"%2d ",
int(descriptors.hasDescriptorSURF() ? 1 : 0));
852 if (descriptors.hasDescriptorSURF())
854 f.printf(
"%4d ",
int(descriptors.SURF->size()));
855 for (
float k : *descriptors.SURF) f.printf(
"%8.5f ", k);
858 f.printf(
"%2d ",
int(descriptors.hasDescriptorORB() ? 1 : 0));
859 if (descriptors.hasDescriptorORB())
860 for (
unsigned char k : *descriptors.ORB) f.printf(
"%d ", k);
863 f.printf(
"%2d ",
int(descriptors.hasDescriptorBLD() ? 1 : 0));
864 if (descriptors.hasDescriptorBLD())
866 f.printf(
"%4d ",
int(descriptors.BLD->size()));
867 for (
unsigned char k : *descriptors.BLD) f.printf(
"%4d ", k);
870 f.printf(
"%2d ",
int(descriptors.hasDescriptorLATCH() ? 1 : 0));
871 if (descriptors.hasDescriptorLATCH())
873 f.printf(
"%4d ",
int(descriptors.LATCH->size()));
874 for (
unsigned char k : *descriptors.LATCH) f.printf(
"%4d ", k);
900 if (!f.open(filename, APPEND))
902 "[CFeatureList::saveToTextFile] ERROR: File could not be open for " 906 "%% Dump of mrpt::vision::CFeatureList. Each line format is:\n" 907 "%% ID TYPE X Y ORIENTATION SCALE TRACK_STATUS RESPONSE HAS_SIFT " 908 "[SIFT] HAS_SURF [SURF]\n" 909 "%% \\---------------------- feature ------------------/ \\--------- " 910 "descriptors -------/\n" 912 "%% TYPE : The used detector: 0:KLT, 1: Harris, 2: BCD, 3: SIFT, 4: " 913 "SURF, 5: Beacon, 6: FAST\n" 914 "%% HAS_* : 1 if a descriptor of that type is associated to the " 916 "%% SIFT : Present if HAS_SIFT=1: N DESC_0 ... DESC_N-1 \n" 917 "%% SURF : Present if HAS_SURF=1: N DESC_0 ... DESC_N-1 \n" 918 "%%--------------------------------------------------------------------" 919 "-----------------------\n");
921 for (
auto& feat : *
this)
924 "%5u %2d %7.3f %7.3f %6.2f %2d %2d %6.3f ",
925 (
unsigned int)feat.keypoint.ID, (
int)feat.get_type(),
926 feat.keypoint.pt.x, feat.keypoint.pt.y, feat.orientation,
927 feat.keypoint.octave, (int)feat.track_status, feat.response);
929 f.printf(
"%2d ",
int(feat.descriptors.hasDescriptorSIFT() ? 1 : 0));
930 if (feat.descriptors.hasDescriptorSIFT())
932 f.printf(
"%4d ",
int(feat.descriptors.SIFT->size()));
933 for (
unsigned int k = 0; k < feat.descriptors.SIFT->size(); k++)
934 f.printf(
"%4d ", (*feat.descriptors.SIFT)[k]);
937 f.printf(
"%2d ",
int(feat.descriptors.hasDescriptorSURF() ? 1 : 0));
938 if (feat.descriptors.hasDescriptorSURF())
940 f.printf(
"%4d ",
int(feat.descriptors.SURF->size()));
941 for (
unsigned int k = 0; k < feat.descriptors.SURF->size(); k++)
942 f.printf(
"%8.5f ", (*feat.descriptors.SURF)[k]);
945 f.printf(
"%2d ",
int(feat.descriptors.hasDescriptorBLD() ? 1 : 0));
946 if (feat.descriptors.hasDescriptorBLD())
948 f.printf(
"%4d ",
int(feat.descriptors.BLD->size()));
949 for (
unsigned int k = 0; k < feat.descriptors.BLD->size(); k++)
950 f.printf(
"%4d ", (*feat.descriptors.BLD)[k]);
953 f.printf(
"%2d ",
int(feat.descriptors.hasDescriptorLATCH() ? 1 : 0));
954 if (feat.descriptors.hasDescriptorLATCH())
956 f.printf(
"%4d ",
int(feat.descriptors.LATCH->size()));
957 for (
unsigned int k = 0; k < feat.descriptors.LATCH->size(); k++)
958 f.printf(
"%4d ", (*feat.descriptors.LATCH)[k]);
977 std::istringstream line;
979 while (parser.getNextLine(line))
999 if (!(line >> _track_st))
throw std::string(
"track_status");
1005 if (!(line >> hasSIFT))
throw std::string(
"hasSIFT");
1011 for (
size_t i = 0; i < N; i++)
1025 if (!(line >> hasBLD))
throw std::string(
"hasBLD");
1031 for (
size_t i = 0; i < N; i++)
1042 if (!(line >> hasLATCH))
throw std::string(
"hasLATCH");
1048 for (
size_t i = 0; i < N; i++)
1059 if (!(line >> hasSURF))
throw std::string(
"hasSURF");
1065 for (
size_t i = 0; i < N; i++)
1070 emplace_back(std::move(feat));
1075 "%s:%d: Error parsing features text file (%s).",
1076 filename.c_str(), (int)parser.getCurrentLineNumber(),
1089 resize(otherList.
size());
1092 for (it1 = otherList.
begin(), it2 =
begin(); it1 != otherList.
end();
1101 for (
const auto& f : *
this)
1102 if (f.keypoint.ID == ID)
return &f;
1110 for (
auto it =
begin(); it !=
end(); ++it, ++k)
1111 if (it->keypoint.ID == ID)
1124 const float x,
const float y,
double& dist_prev)
const 1126 if (
empty())
return nullptr;
1128 float closest_x, closest_y;
1129 float closest_sqDist;
1132 const size_t closest_idx =
1133 kdTreeClosestPoint2D(
x,
y, closest_x, closest_y, closest_sqDist);
1134 float closest_dist = std::sqrt(closest_sqDist);
1136 if (closest_dist <= dist_prev)
1138 dist_prev = closest_dist;
1139 return &m_feats[closest_idx];
1153 for (
const auto& f : *
this)
mrpt::keep_max(maxID, f.keypoint.ID);
1166 FILE* f =
os::fopen(filename.c_str(),
"wt");
1169 for (
const auto&
p : *
this)
1172 f,
"%d %.3f %.3f %d %.3f %.3f\n",
1173 (
unsigned int)(
p.first.keypoint.ID),
p.first.keypoint.pt.x,
1174 p.first.keypoint.pt.y, (
unsigned int)(
p.second.keypoint.ID),
1175 p.second.keypoint.pt.x,
p.second.keypoint.pt.y);
1187 CMatchedFeatureList::iterator it;
1188 for (it =
begin(); it !=
end(); ++it)
1190 const auto& feat = (idx ==
firstList) ? it->first : it->second;
1191 if (feat.keypoint.ID == ID)
return &feat;
1204 for (
auto itList =
begin(); itList !=
end(); itList++)
1225 if (m_leftMaxID == 0) updateMaxID(
firstList);
1227 if (m_rightMaxID == 0) updateMaxID(
secondList);
1228 firstListID = m_leftMaxID;
1229 secondListID = m_rightMaxID;
1243 for (
auto it =
begin(); it !=
end(); ++it, ++k)
1245 list1[k] = it->first;
1246 list2[k] = it->second;
1256 if (descriptors.hasDescriptorSIFT())
1258 desc.
setSize(1, descriptors.SIFT->size());
1259 for (
size_t i = 0; i < descriptors.SIFT->size(); i++)
1260 desc(0, i) = (*descriptors.SIFT)[i];
1263 else if (descriptors.hasDescriptorBLD())
1265 desc.
setSize(1, descriptors.BLD->size());
1266 for (
size_t i = 0; i < descriptors.BLD->size(); i++)
1267 desc(0, i) = (*descriptors.BLD)[i];
1270 else if (descriptors.hasDescriptorLATCH())
1272 desc.
setSize(1, descriptors.LATCH->size());
1273 for (
size_t i = 0; i < descriptors.LATCH->size(); i++)
1274 desc(0, i) = (*descriptors.LATCH)[i];
1277 else if (descriptors.hasDescriptorSURF())
1279 desc.
setSize(1, descriptors.SURF->size());
1280 for (
size_t i = 0; i < descriptors.SURF->size(); i++)
1281 desc(0, i) = (*descriptors.SURF)[i];
1284 else if (descriptors.hasDescriptorSpinImg())
1286 const size_t nR = descriptors.SpinImg_range_rows;
1288 descriptors.SpinImg->
size() / descriptors.SpinImg_range_rows;
1290 auto itD = descriptors.SpinImg->begin();
1291 for (
size_t r = 0;
r < nR;
r++)
1292 for (
size_t c = 0;
c < nC;
c++) desc.
coeffRef(
r,
c) = *itD++;
1295 else if (descriptors.hasDescriptorPolarImg())
1297 desc = *descriptors.PolarImg;
1300 else if (descriptors.hasDescriptorLogPolarImg())
1302 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.
GLuint GLuint GLsizei count
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)
double RAD2DEG(const double x)
Radians to degrees.
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::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
GLenum GLenum GLenum GLenum GLenum scale
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].
GLint GLint GLsizei GLsizei GLsizei depth
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.
T square(const T x)
Inline function for the square of a number.
#define ASSERT_(f)
Defines an assertion mechanism.
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.
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...
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.
mrpt::config::CConfigFileBase CConfigFileBase
TKeyPointMethod
Types of key point detectors.
TDescriptorType
The bitwise OR combination of values of TDescriptorType are used in CFeatureExtraction::computeDescri...
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.
GLsizei const GLchar ** string
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
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.
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.
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.
GLdouble GLdouble GLdouble r
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() ...
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...
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
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.
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.
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
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...
GLenum GLsizei GLsizei height
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
unsigned __int32 uint32_t
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.
GLuint GLuint GLsizei GLenum type
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.