22 #include <mrpt/examples_config.h>
23 string myDataDir(MRPT_EXAMPLES_BASE_DIRECTORY +
string(
"img_convolution_fft/"));
30 "/Trabajo/Experimentos/[2009] vOdometry Characterization/right1.jpg");
32 "/Trabajo/Experimentos/[2009] vOdometry Characterization/right2.jpg");
40 "J:/Trabajo/Experimentos/[2009] vOdometry Characterization/before.txt");
51 "/Trabajo/Experimentos/[2009] vOdometry Characterization/after.txt");
65 string imgL = MRPT_EXAMPLES_BASE_DIRECTORY +
66 string(
"vision_feature_extraction/") +
67 string(
"imgs/imL_p01.jpg");
68 string imgR = MRPT_EXAMPLES_BASE_DIRECTORY +
69 string(
"vision_feature_extraction/") +
70 string(
"imgs/imR_p01.jpg");
75 cerr <<
"Cannot load " << imgL << endl;
78 cout <<
"Loaded test image: " << imgL << endl;
82 cerr <<
"Cannot load " << imgR << endl;
85 cout <<
"Loaded test image: " << imgR << endl;
87 cout <<
"***************************************************" << endl;
88 cout <<
"***************************************************" << endl;
92 cout <<
"Detecting HARRIS features in LEFT image" << endl;
95 cout <<
"Detected " << featsHarris_L.
size() << endl;
97 cout <<
"Detecting HARRIS features in RIGHT image" << endl;
99 cout <<
"Detected " << featsHarris_R.
size() << endl;
101 cout <<
"***************************************************" << endl;
102 cout <<
"***************************************************" << endl;
109 cout <<
"Matching HARRIS features by CORRELATION" << endl;
112 cout <<
"Matches found: " << mHarris.size() << endl;
114 cout <<
"***************************************************" << endl;
125 CFeatureList featsHarris_L, featsHarris_R, featsSIFT_L, featsSIFT_R,
126 featsSURF_L, featsSURF_R, featsFAST_L, featsFAST_R;
130 string imgL = MRPT_EXAMPLES_BASE_DIRECTORY +
131 string(
"vision_feature_extraction/") +
132 string(
"imgs/imL_p01.jpg");
133 string imgR = MRPT_EXAMPLES_BASE_DIRECTORY +
134 string(
"vision_feature_extraction/") +
135 string(
"imgs/imR_p01.jpg");
145 cerr <<
"Cannot load " << imgL << endl;
148 cout <<
"Loaded test image: " << imgL << endl;
152 cerr <<
"Cannot load " << imgR << endl;
155 cout <<
"Loaded test image: " << imgR << endl;
157 cout <<
"***************************************************" << endl;
158 cout <<
"***************************************************" << endl;
162 cout <<
"Detecting HARRIS features in LEFT image" << endl;
165 cout <<
"Detected " << featsHarris_L.
size() << endl;
167 cout <<
"Detecting HARRIS features in RIGHT image" << endl;
169 cout <<
"Detected " << featsHarris_R.
size() << endl;
170 cout <<
"***************************************************" << endl;
173 cout <<
"Detecting SIFT features in LEFT image" << endl;
178 cout <<
"Detected " << featsSIFT_L.
size() << endl;
180 cout <<
"Detecting SIFT features in RIGHT image" << endl;
185 cout <<
"Detected " << featsSIFT_R.
size() << endl;
186 cout <<
"***************************************************" << endl;
189 cout <<
"Detecting SURF features in LEFT image" << endl;
192 cout <<
"Detected " << featsSURF_L.
size() << endl;
194 cout <<
"Detecting SURF features in RIGHT image" << endl;
196 cout <<
"Detected " << featsSURF_R.
size() << endl;
197 cout <<
"***************************************************" << endl;
200 cout <<
"Detecting FAST features in LEFT image" << endl;
203 cout <<
"Detected " << featsFAST_L.
size() << endl;
205 fast1.showImageAndPoints(imL, featsFAST_L);
207 cout <<
"Detecting FAST features in RIGHT image" << endl;
209 cout <<
"Detected " << featsFAST_R.
size() << endl;
210 cout <<
"***************************************************" << endl;
211 cout <<
"***************************************************" << endl;
213 fast2.showImageAndPoints(imR, featsFAST_R);
221 cout <<
"Matching HARRIS features by CORRELATION" << endl;
225 double T = tictac.
Tac();
226 cout <<
"[CC] Matches found: " << mHarris.size() <<
" in " << T * 1000.0f
232 matchFeatures(featsHarris_L, featsHarris_R, mHarris_SAD, opt);
234 cout <<
"[SAD] Matches found: " << mHarris_SAD.size() <<
" in "
235 << T * 1000.0f <<
" ms " << endl;
236 cout <<
"***************************************************" << endl;
240 cout <<
"Matching SIFT features by DESCRIPTOR" << endl;
244 cout <<
"Matches found: " << mSIFT.size() << endl;
245 cout <<
"***************************************************" << endl;
248 cout <<
"Matching SURF features by DESCRIPTOR" << endl;
252 cout <<
"Matches found: " << mSURF.size() << endl;
253 cout <<
"***************************************************" << endl;
256 cout <<
"Matching FAST features by CC" << endl;
261 cout <<
"[CC] Matches found: " << mFAST_CC.size() <<
" in " << T * 1000.0f
269 cout <<
"[SAD] Matches found: " << mFAST_SAD.size() <<
" in " << T * 1000.0f
271 cout <<
"***************************************************" << endl;
282 string imgL = MRPT_EXAMPLES_BASE_DIRECTORY +
283 string(
"vision_feature_extraction/") +
284 string(
"imgs/imL_p01.jpg");
285 string imgR = MRPT_EXAMPLES_BASE_DIRECTORY +
286 string(
"vision_feature_extraction/") +
287 string(
"imgs/imR_p01.jpg");
314 for (it1 = list1.
begin(); it1 != list1.
end(); ++it1)
316 for (it2 = list2.
begin(); it2 != list2.
end(); ++it2)
321 win2.
setPos(0, imH * 1.5);
322 CImage joinimage, copyjoinimage, copyInfoImage;
329 infoimage.filledRectangle(0, 0, imW2, imH2,
TColor(150, 150, 150));
330 infoimage.textOut(20, imH2 - 53,
"SAD",
TColor::blue());
331 infoimage.textOut(20, imH2 - 41,
"NCC",
TColor::blue());
332 infoimage.textOut(20, imH2 - 29,
"SIFT",
TColor::blue());
333 infoimage.textOut(20, imH2 - 17,
"SURF",
TColor::blue());
334 for (it1 = list1.
begin(); it1 != list1.
end(); ++it1)
336 copyInfoImage = infoimage;
337 copyjoinimage = joinimage;
341 (*it1)->x + imW, 0, (*it1)->x + imW, imH,
349 bool firstMatch =
true;
352 double minsad = 1.0, maxncc = 0.0;
353 float minsiftd = 1.0f, minsurfd = 1.0f;
354 int idxsad = 0, idxncc = 0, idxsiftd = 0, idxsurfd = 0;
356 for (it2 = list2.
begin(); it2 != list2.
end(); ++it2)
358 if (fabs((*it1)->y - (*it2)->y) <= 1.0 && (*it1)->x > (*it2)->x)
374 (*it1)->patch, (*it2)->patch, u,
v, ncc);
382 float siftd = (*it1)->descriptorSIFTDistanceTo(*(*it2));
383 if (siftd < minsiftd)
390 float surfd = (*it1)->descriptorSURFDistanceTo(*(*it2));
391 if (surfd < minsurfd)
401 (*it1)->x + imW, 0, (*it1)->x + imW, imH,
409 double rx0, rx1, ry0, ry1, tx,
ty;
410 rx0 = (*it2)->x + imW - 15;
411 rx1 = (*it2)->x + imW;
412 tx = (*it2)->x + imW - 13;
415 ry0 = (*it2)->y - 20;
416 ry1 = (*it2)->y - 10;
421 ry0 = (*it2)->y + 10;
422 ry1 = (*it2)->y + 20;
426 rx0, ry0, rx1, ry1,
TColor(150, 150, 150));
450 80 + idxsad * 50, imH2 - 53,
format(
"%.2f", minsad),
453 80 + idxncc * 50, imH2 - 41,
format(
"%.2f", maxncc),
456 80 + idxsiftd * 50, imH2 - 29,
format(
"%.2f", minsiftd),
459 80 + idxsurfd * 50, imH2 - 17,
format(
"%.2f", minsurfd),
462 win.showImage(copyjoinimage);
479 CFeatureList featsHarris, featsKLT, featsSIFT_Hess, featsSIFT_Lowe,
480 featsSIFT_Vedaldi, featsSURF, featsFAST;
489 cout <<
"------------------------------------------------------------------"
498 cout <<
"Detect Harris features... [f_harris.txt]" << endl;
502 cout <<
"Detected " << featsHarris.
size() <<
" features in ";
503 cout <<
format(
" %.03fms", tictac.
Tac() * 1000) << endl << endl;
508 cout <<
"Detect FAST features... [f_fast.txt]" << endl;
515 cout <<
"Detected " << featsFAST.
size() <<
" features in ";
516 cout <<
format(
" %.03fms", tictac.
Tac() * 1000) << endl << endl;
521 cout <<
"Computing SIFT descriptors only ... [f_harris+sift.txt]" << endl;
525 cout <<
format(
" %.03fms", tictac.
Tac() * 1000) << endl << endl;
528 cout <<
"Extracting KLT features... [f_klt.txt]" << endl;
534 cout <<
"Detected " << featsKLT.
size() <<
" features in ";
535 cout <<
format(
" %.03fms", tictac.
Tac() * 1000) << endl << endl;
540 cout <<
"Extracting SIFT features... [f_sift_hess.txt]" << endl;
545 cout <<
"Detected " << featsSIFT_Hess.
size() <<
" features in ";
546 cout <<
format(
" %.03fms", tictac.
Tac() * 1000) << endl << endl;
551 cout <<
"Extracting SURF features... [f_surf.txt]" << endl;
555 cout <<
"Detected " << featsSURF.
size() <<
" features in ";
556 cout <<
format(
" %.03fms", tictac.
Tac() * 1000) << endl << endl;
561 cout <<
"Computing spin images descriptors only ... [f_harris+spinimgs.txt]"
568 cout <<
format(
" %.03fms", tictac.
Tac() * 1000) << endl << endl;
585 if (!
img.loadFromFile(the_img))
587 cerr <<
"Cannot load " << the_img << endl;
590 cout <<
"Loaded test image: " << the_img << endl;
594 cout <<
"Extracting Harris features (tiled)... [f_harris_tiled.txt]";
601 cout <<
format(
" %.03fms", tictac.
Tac() * 1000) << endl;
603 cout <<
"Detected " << featsHarris.
size() <<
" features in " << endl;
608 cout <<
"Extracting Harris features... [f_harris.txt]";
614 cout <<
format(
" %.03fms", tictac.
Tac() * 1000) << endl;
625 int main(
int argc,
char** argv)
642 catch (std::exception& e)
644 std::cout <<
"MRPT exception caught: " << e.what() << std::endl;
649 printf(
"Another exception!!");