@@ -160,7 +160,7 @@ namespace coloc
160
160
161
161
using KernelType = robust::ACKernelAdaptorEssential<
162
162
openMVG::essential::kernel::FivePointSolver,
163
- openMVG::fundamental::kernel::EpipolarDistanceError ,
163
+ openMVG::fundamental::kernel::SymmetricEpipolarDistanceError ,
164
164
Mat3>;
165
165
KernelType kernel (x1, norm2Dpt_1, params.imageSize .first , params.imageSize .second ,
166
166
x2, norm2Dpt_2, params.imageSize .first , params.imageSize .second ,
@@ -170,7 +170,7 @@ namespace coloc
170
170
const auto ACRansacOut = ACRANSAC (kernel, relativePose_info.vec_inliers , iterationCount, &relativePose_info.essential_matrix ,
171
171
relativePose_info.initial_residual_tolerance , false );
172
172
173
- relativePose_info.found_residual_precision = 5.0 ;
173
+ relativePose_info.found_residual_precision = ACRansacOut. first ;
174
174
175
175
if (relativePose_info.vec_inliers .size () < 2.5 * KernelType::Solver::MINIMUM_SAMPLES)
176
176
return EXIT_FAILURE;
@@ -243,9 +243,8 @@ namespace coloc
243
243
std::vector <IndMatch> putativeMatches, filteredMatches;
244
244
245
245
putativeMatches = commonFeatures;
246
-
247
246
commonFeatures.clear ();
248
-
247
+ /*
249
248
const PointFeatures featI = scene1->GetRegionsPositions();
250
249
const PointFeatures featJ = scene2->GetRegionsPositions();
251
250
@@ -291,7 +290,8 @@ namespace coloc
291
290
// *scene1.get(),
292
291
// *scene2.get(),
293
292
// putativeMatches);
294
- /*
293
+ */
294
+
295
295
const PointFeatures featI = scene1->GetRegionsPositions ();
296
296
const PointFeatures featJ = scene2->GetRegionsPositions ();
297
297
@@ -344,7 +344,7 @@ namespace coloc
344
344
std::cout << "Right coordinates: " << xR.col(k) << std::endl;
345
345
346
346
}
347
-
347
+ */
348
348
inliers.push_back (putativeMatches[k]);
349
349
myfile << res (0 , 0 ) << " ," << xL (0 , k) << " ," << xL (1 , k) << " ," << xR (0 , k) << " ," << xR (1 , k) << std::endl;
350
350
epipolarLineDeviations.push_back (std::abs (res (0 , 0 )));
@@ -358,16 +358,18 @@ namespace coloc
358
358
359
359
std::sort (std::begin (matchIndices), std::end (matchIndices), [&](int i1, int i2) { return epipolarLineDeviations[i1] < epipolarLineDeviations[i2]; });
360
360
std::sort (epipolarLineDeviations.begin (), epipolarLineDeviations.end ());
361
- //for (int ic = 0; ic < inliers.size(); ++ic)
362
- // commonFeatures.push_back(inliers[ic]);
363
-
364
- for (int ic = 0; ic < 2; ic++)
365
- commonFeatures.push_back(putativeMatches[matchIndices[ic]]);
361
+ for (int ic = 0 ; ic < inliers.size (); ++ic)
362
+ commonFeatures.push_back (inliers[ic]);
363
+ /*
364
+ if (matchIndices.size() != 0) {
365
+ for (int ic = 0; ic < 2; ic++)
366
+ commonFeatures.push_back(putativeMatches[matchIndices[ic]]);
367
+ }
366
368
*/
367
369
return EXIT_SUCCESS;
368
370
}
369
371
370
- std::unique_ptr <RelativePose_Info> computeRelativePose (Pair current_pair, FeatureMap& regions, PairWiseMatches& putativeMatches)
372
+ bool computeRelativePose (RelativePose_Info& relativePose, Pair current_pair, FeatureMap& regions, PairWiseMatches& putativeMatches)
371
373
{
372
374
const uint32_t I = std::min (current_pair.first , current_pair.second );
373
375
const uint32_t J = std::max (current_pair.first , current_pair.second );
@@ -378,12 +380,7 @@ namespace coloc
378
380
std::vector <IndMatch> pairMatches = putativeMatches[current_pair];
379
381
Mat xL (2 , pairMatches.size ());
380
382
Mat xR (2 , pairMatches.size ());
381
- for (size_t k = 0 ; k < pairMatches.size (); ++k) {
382
- xL.col (k) = featI[pairMatches[k].i_ ].coords ().cast <double >();
383
- xR.col (k) = featJ[pairMatches[k].j_ ].coords ().cast <double >();
384
- }
385
-
386
- RelativePose_Info relativePose;
383
+
387
384
388
385
const openMVG::cameras::Pinhole_Intrinsic_Radial_K3
389
386
camL (params->imageSize .first , params->imageSize .second , (params->K [current_pair.first ])(0 , 0 ), (params->K [current_pair.first ])(0 , 2 ), (params->K [current_pair.first ])(1 , 2 ),
@@ -393,6 +390,13 @@ namespace coloc
393
390
394
391
bool status, findPose = true ;
395
392
393
+ for (size_t k = 0 ; k < pairMatches.size (); ++k) {
394
+ xL.col (k) = featI[pairMatches[k].i_ ].coords ().cast <double >();
395
+ xL.col (k) = camL.get_ud_pixel (xL.col (k));
396
+ xR.col (k) = featJ[pairMatches[k].j_ ].coords ().cast <double >();
397
+ xR.col (k) = camR.get_ud_pixel (xR.col (k));
398
+ }
399
+
396
400
if (params->model == ' H' )
397
401
status = filterHomography (&camL, &camR, xL, xR, relativePose, *params, findPose);
398
402
else if (params->model == ' E' )
@@ -416,19 +420,50 @@ namespace coloc
416
420
<< std::endl;
417
421
}
418
422
419
- return std::make_unique<RelativePose_Info>(relativePose);
423
+ return status;
424
+ }
425
+
426
+ bool filterMatchesPair (Pair currentPair, FeatureMap& regions, PairWiseMatches& putativeMatches, PairWiseMatches& geometricMatches, InterPoseMap& relativePoses)
427
+ {
428
+ std::vector <IndMatch> pairMatches = putativeMatches[currentPair];
429
+ RelativePose_Info relativePose;
430
+
431
+ bool status = computeRelativePose (relativePose, currentPair, regions, putativeMatches);
432
+
433
+ std::vector <IndMatch> vec_geometricMatches;
434
+ for (int ic = 0 ; ic < relativePose.vec_inliers .size (); ++ic)
435
+ vec_geometricMatches.push_back (pairMatches[relativePose.vec_inliers [ic]]);
436
+
437
+ if (!vec_geometricMatches.empty ())
438
+ {
439
+ PairWiseMatches::iterator it = geometricMatches.find (currentPair);
440
+ if (geometricMatches.end () != it)
441
+ geometricMatches.at (currentPair) = vec_geometricMatches;
442
+ else
443
+ geometricMatches.insert ({ { currentPair.first , currentPair.second }, std::move (vec_geometricMatches) });
444
+ }
445
+
446
+ InterPoseMap::iterator it = relativePoses.find (currentPair);
447
+ if (relativePoses.end () != it)
448
+ relativePoses.at (currentPair) = relativePose;
449
+ else
450
+ relativePoses.insert ({ { currentPair.first , currentPair.second }, std::move (relativePose) });
451
+
452
+ return status;
420
453
}
421
454
422
455
void filterMatches (FeatureMap& regions, PairWiseMatches& putativeMatches, PairWiseMatches& geometricMatches, InterPoseMap& relativePoses)
423
456
{
424
457
for (const auto matchedPair : putativeMatches) {
425
458
Pair currentPair = matchedPair.first ;
426
459
std::vector <IndMatch> pairMatches = putativeMatches[currentPair];
427
- std::unique_ptr<RelativePose_Info> relativePose = computeRelativePose (matchedPair.first , regions, putativeMatches);
460
+ RelativePose_Info relativePose;
461
+
462
+ bool status = computeRelativePose (relativePose, matchedPair.first , regions, putativeMatches);
428
463
429
464
std::vector <IndMatch> vec_geometricMatches;
430
- for (int ic = 0 ; ic < relativePose-> vec_inliers .size (); ++ic)
431
- vec_geometricMatches.push_back (pairMatches[relativePose-> vec_inliers [ic]]);
465
+ for (int ic = 0 ; ic < relativePose. vec_inliers .size (); ++ic)
466
+ vec_geometricMatches.push_back (pairMatches[relativePose. vec_inliers [ic]]);
432
467
433
468
if (!vec_geometricMatches.empty ())
434
469
{
@@ -441,9 +476,9 @@ namespace coloc
441
476
442
477
InterPoseMap::iterator it = relativePoses.find (currentPair);
443
478
if (relativePoses.end () != it)
444
- relativePoses.at (currentPair) = * relativePose;
479
+ relativePoses.at (currentPair) = relativePose;
445
480
else
446
- relativePoses.insert ({ { currentPair.first , currentPair.second }, std::move (* relativePose) });
481
+ relativePoses.insert ({ { currentPair.first , currentPair.second }, std::move (relativePose) });
447
482
}
448
483
}
449
484
};
0 commit comments