contrib/brl/bseg/sdet/sdet_fit_conics_params.cxx
Go to the documentation of this file.
00001 // This is brl/bseg/sdet/sdet_fit_conics_params.cxx
00002 #include "sdet_fit_conics_params.h"
00003 //:
00004 // \file
00005 // See sdet_fit_conics_params.h
00006 //
00007 //-----------------------------------------------------------------------------
00008 #include <vcl_sstream.h>
00009 #include <vcl_iostream.h>
00010 
00011 //------------------------------------------------------------------------
00012 // Constructors
00013 //
00014 
00015 sdet_fit_conics_params::
00016 sdet_fit_conics_params(const sdet_fit_conics_params& flp)
00017   : gevd_param_mixin(), vbl_ref_count()
00018 {
00019   InitParams(flp.min_fit_length_,
00020              flp.rms_distance_,flp.aspect_ratio_);
00021 }
00022 
00023 sdet_fit_conics_params::
00024 sdet_fit_conics_params(int min_fit_length,
00025                       double rms_distance,int aspect_ratio)
00026 {
00027   InitParams(min_fit_length, rms_distance,aspect_ratio);
00028 }
00029 
00030 void sdet_fit_conics_params::InitParams(int min_fit_length,
00031                                        double rms_distance,double aspect_ratio)
00032 {
00033   min_fit_length_ = min_fit_length;
00034   rms_distance_ = rms_distance;
00035   aspect_ratio_ = aspect_ratio;
00036 }
00037 
00038 //-----------------------------------------------------------------------------
00039 //
00040 //:   Checks that parameters are within acceptable bounds
00041 bool sdet_fit_conics_params::SanityCheck()
00042 {
00043   //  Note that msg << ends seems to restart the string and erase the
00044   //  previous string. We should only use it as the last call, use
00045   //  vcl_endl otherwise.
00046   vcl_stringstream msg;
00047   bool valid = true;
00048 
00049   if (min_fit_length_<3)
00050   {
00051     msg << "ERROR: need at least 3 points for a fit\n";
00052     valid = false;
00053   }
00054   if (rms_distance_>1)
00055   {
00056     msg << "ERROR: a line fit should be better than one pixel rms\n";
00057     valid = false;
00058   }
00059   if (aspect_ratio_>30)
00060   {
00061     msg << "ERROR: better to have an aspect ratio cutoff less than 10\n";
00062     valid = false;
00063   }
00064 
00065   msg << vcl_ends;
00066 
00067   SetErrorMsg(msg.str().c_str());
00068   return valid;
00069 }
00070 
00071 vcl_ostream& operator << (vcl_ostream& os, const sdet_fit_conics_params& flp)
00072 {
00073   return
00074   os << "sdet_fit_conics_params:\n[---\n"
00075      << "min fit length " << flp.min_fit_length_ << vcl_endl
00076      << "rms distance tolerance" << flp.rms_distance_ << vcl_endl
00077      <<"aspect ratio tolerance" <<flp.aspect_ratio_ <<vcl_endl
00078      << "---]\n";
00079 }