src/feature_detector/src/observed_parameter_manager.cpp
// TODO: Refactor this.
// Problems:
//  I think the matcher is retrained about 10 times.
//  Features are recomputed about 6 times.
//  Repetition.
//  The same names are used as in writeParametersToStorage.
Refactor this.
Problems:
I think the matcher is retrained about 10 times.
Features are recomputed about 6 times.
Repetition.
The same names are used as in writeParametersToStorage.
Refactor this . Problems : I think the matcher is retrained about 10 times . Features are recomputed about 6 times . Repetition . The same names are used as in writeParametersToStorage .
void ObservedParameterManager::setParametersFromStorage(cv::FileStorage& fs)
{
  auto fpn = fullParamName;
  {
    auto fn = fs[fpn("hessian_thresh")];  
    if (!fn.empty())
      setHessianThreshold((double)fn);
  }
  {
    auto fn = fs[fpn("num_octaves")];
    if (!fn.empty())
      setNumOctaves((int)fn);
  }
  {
    auto fn = fs[fpn("num_octave_layers")];
    if (!fn.empty())
      setNumOctaveLayers((int)fn);
  }
  {
    auto fn = fs[fpn("extended")];
    if (!fn.empty())
      setExtended(static_cast<bool>((int)fn));
  }
  {
    auto fn = fs[fpn("upright")];
    if (!fn.empty())
      setUpright(static_cast<bool>((int)fn));
  }
  {
    auto fn = fs[fpn("norm_type")];
    if (!fn.empty())
      setNormType(static_cast<NormType>((int)fn));
  }
  {
    auto fn = fs[fpn("cross_check")];
    if (!fn.empty())
      setCrossCheck(static_cast<bool>((int)fn));
  }
  {
    auto fn = fs[fpn("match_distance_thresh")];
    if (!fn.empty())
      setMatchDistanceThreshold((double)fn);
  }
  {
    auto fn = fs[fpn("ransac_reproj_thresh")];
    if (!fn.empty())
      setRansacReprojThreshold((double)fn);
  }
  {
    auto fn_image = fs[fpn("selection_image")];
    auto fn_area = fs[fpn("selection_area")];
    if (!fn_image.empty() && !fn_area.empty()) {
      cv::Mat m;
      fn_image >> m;
      cv::Rect r;
      fn_area >> r;
      setSelection(m, r);
    }
  }
}
void ObservedParameterManager :: setParametersFromStorage ( cv :: FileStorage & fs ) { auto fpn = fullParamName ; { auto fn = fs [ fpn ( " " ) ] ; if ( ! fn . empty ( ) ) setHessianThreshold ( ( double ) fn ) ; } { auto fn = fs [ fpn ( " " ) ] ; if ( ! fn . empty ( ) ) setNumOctaves ( ( int ) fn ) ; } { auto fn = fs [ fpn ( " " ) ] ; if ( ! fn . empty ( ) ) setNumOctaveLayers ( ( int ) fn ) ; } { auto fn = fs [ fpn ( " " ) ] ; if ( ! fn . empty ( ) ) setExtended ( static_cast < bool > ( ( int ) fn ) ) ; } { auto fn = fs [ fpn ( " " ) ] ; if ( ! fn . empty ( ) ) setUpright ( static_cast < bool > ( ( int ) fn ) ) ; } { auto fn = fs [ fpn ( " " ) ] ; if ( ! fn . empty ( ) ) setNormType ( static_cast < NormType > ( ( int ) fn ) ) ; } { auto fn = fs [ fpn ( " " ) ] ; if ( ! fn . empty ( ) ) setCrossCheck ( static_cast < bool > ( ( int ) fn ) ) ; } { auto fn = fs [ fpn ( " " ) ] ; if ( ! fn . empty ( ) ) setMatchDistanceThreshold ( ( double ) fn ) ; } { auto fn = fs [ fpn ( " " ) ] ; if ( ! fn . empty ( ) ) setRansacReprojThreshold ( ( double ) fn ) ; } { auto fn_image = fs [ fpn ( " " ) ] ; auto fn_area = fs [ fpn ( " " ) ] ; if ( ! fn_image . empty ( ) && ! fn_area . empty ( ) ) { cv :: Mat m ; fn_image >> m ; cv :: Rect r ; fn_area >> r ; setSelection ( m , r ) ; } } }
TODO: Refactor this.
TODO : Refactor this .
// file-node /*
  {
    auto fn = fs[fpn("kpt_response_thresh")];
    if (!fn.empty())
      setKeypointResponseThreshold((double)fn);
  }
  */