@@ -48,6 +48,7 @@ class IBAGlobalParams{
4848 int PointCloudskip = 1 ;
4949 bool PointCloudOnlyPositiveX = false ;
5050 int max_bbeval = 200 ;
51+ double valid_rate = 0.5 ;
5152 bool verborse = true ;
5253 bool use_plane = true ;
5354};
@@ -90,7 +91,7 @@ void FindProjectCorrespondences(const VecVector3d &points, const ORB_SLAM2::KeyF
9091 std::vector<double > sq_dist (num_closest, std::numeric_limits<double >::max ());
9192 nanoflann::KNNResultSet<double , IndexType> resultSet (num_closest);
9293 resultSet.init (indices.data (), sq_dist.data ());
93- kdtree->index ->findNeighbors (resultSet, vKeyUnEigen[i].data (), nanoflann::SearchParameters (0 . 0F , true ));
94+ kdtree->index ->findNeighbors (resultSet, vKeyUnEigen[i].data (), nanoflann::SearchParameters ());
9495 if (resultSet.size () > 0 && sq_dist[0 ] <= max_corr_dist * max_corr_dist)
9596 corrset.push_back (std::make_pair (i, ProjectIndex[indices[0 ]]));
9697 }
@@ -328,14 +329,19 @@ std::tuple<double, double, double, int, int> BAError(
328329 }
329330 }
330331 }
331- assert (valid_cnt_3d_2d > 0 && valid_cnt_3d_3d > 0 );
332- corr_3d_2d_err /= valid_cnt_3d_2d;
333- corr_3d_3d_err /= valid_cnt_3d_3d;
332+ if (valid_cnt_3d_2d==0 && iba_params.err_weight [0 ] > 1e-10 )
333+ corr_3d_2d_err = std::numeric_limits<double >::max ();
334+ else
335+ corr_3d_2d_err /= valid_cnt_3d_2d;
336+ if (valid_cnt_3d_3d==0 && iba_params.err_weight [1 ] > 1e-10 )
337+ corr_3d_3d_err = std::numeric_limits<double >::max ();
338+ else
339+ corr_3d_3d_err /= valid_cnt_3d_3d;
334340 Cval /= Ccnt;
335341 // auto logger = LogEdges(corr_3d_3d_errlist);
336342 // print_map("corr3d_3d:",logger);
337343 if (verborse)
338- std::printf (" plane: %d, point: %d\n " , valid_pl_3d_3d, valid_pt_3d_3d);
344+ std::printf (" plane: %d, point: %d 3d-2d: %d \n " , valid_pl_3d_3d, valid_pt_3d_3d, valid_cnt_3d_2d );
339345 return {corr_3d_2d_err, corr_3d_3d_err, Cval, valid_cnt_3d_2d, cnt_3d_2d};
340346}
341347
@@ -381,9 +387,11 @@ class BALoss: public NOMAD::Evaluator
381387 std::tie (f1val, f2val, Cval, valid_edge_cnt, edge_cnt) = BAError (xvec, *PointClouds, kdtree_list, *PointCloudPoses, *KFIdMap, *KeyFrames, *iba_params);
382388 NOMAD::Double f = f1val * iba_params->err_weight [0 ] + f2val * iba_params->err_weight [1 ];
383389 NOMAD::Double C1 = Cval - iba_params->he_threshold , C2 = -Cval - iba_params->he_threshold ; // |Cval| <= he_threshold
390+ NOMAD::Double C3 = iba_params->valid_rate - static_cast <double >(valid_edge_cnt) / (edge_cnt+1 );
384391 std::string bbo = f.tostring ();
385392 bbo += " " + C1.tostring ();
386393 bbo += " " + C2.tostring ();
394+ bbo += " " + C3.tostring ();
387395 x.setBBO (bbo);
388396 countEval = true ;
389397 return true ;
@@ -456,9 +464,11 @@ int main(int argc, char** argv){
456464 iba_params.PointCloudskip = io_config[" PointCloudskip" ].as <int >();
457465 iba_params.PointCloudOnlyPositiveX = io_config[" PointCloudOnlyPositiveX" ].as <bool >();
458466 iba_params.max_bbeval = runtime_config[" max_bbeval" ].as <int >();
467+ iba_params.valid_rate = runtime_config[" valid_rate" ].as <double >();
459468 iba_params.verborse = runtime_config[" verborse" ].as <bool >();
460469 iba_params.use_plane = runtime_config[" use_plane" ].as <bool >();
461470 bool use_cache = runtime_config[" use_cache" ].as <bool >();
471+ bool use_vns = runtime_config[" use_vns" ].as <bool >();
462472 int seed = runtime_config[" seed" ].as <int >();
463473 const std::string NomadCacheFile = runtime_config[" cacheFile" ].as <std::string>();
464474 const double min_mesh = runtime_config[" min_mesh" ].as <double >();
@@ -553,6 +563,7 @@ int main(int argc, char** argv){
553563 bbOutputTypes.push_back (NOMAD::BBOutputType::OBJ);
554564 bbOutputTypes.push_back (NOMAD::BBOutputType::PB); // Relaxible Constraint |he_err| < delta
555565 bbOutputTypes.push_back (NOMAD::BBOutputType::PB); // Relaxible Constraint
566+ bbOutputTypes.push_back (NOMAD::BBOutputType::PB); // Corr Valid Rate > threshold
556567 nomad_params->set_BB_OUTPUT_TYPE (bbOutputTypes);
557568 NOMAD::ArrayOfDouble nomad_lb (lb), nomad_ub (ub);
558569 nomad_params->set_LOWER_BOUND (nomad_lb);
@@ -566,7 +577,7 @@ int main(int argc, char** argv){
566577 NOMAD::ArrayOfDouble nomad_mesh_minsize (min_mesh_size), nomad_frame_init (init_frame_size);
567578 nomad_params->set_INITIAL_POLL_SIZE (nomad_frame_init);
568579 nomad_params->set_MIN_MESH_SIZE (nomad_mesh_minsize);
569- nomad_params->setAttributeValue (" VNS_MADS_SEARCH" ,true );
580+ nomad_params->setAttributeValue (" VNS_MADS_SEARCH" ,use_vns );
570581 nomad_params->setAttributeValue (" DIRECTION_TYPE" ,NOMAD::DirectionType::ORTHO_2N);
571582 nomad_params->checkAndComply ();
572583 auto ev = std::make_unique<BALoss>(nomad_params->getEvalParams (), nomad_type,
0 commit comments