00001 // This is brl/bseg/sdet/sdet_nonmax_suppression_params.cxx 00002 #include "sdet_nonmax_suppression_params.h" 00003 //: 00004 // \file 00005 // See sdet_nonmax_suppression_params.h 00006 // 00007 //----------------------------------------------------------------------------- 00008 #include <vcl_sstream.h> 00009 #include <vcl_iostream.h> 00010 00011 //------------------------------------------------------------------------ 00012 // Constructors 00013 // 00014 00015 sdet_nonmax_suppression_params:: 00016 sdet_nonmax_suppression_params(const sdet_nonmax_suppression_params& nsp) 00017 : gevd_param_mixin() 00018 { 00019 InitParams(nsp.thresh_, nsp.pfit_type_); 00020 } 00021 00022 sdet_nonmax_suppression_params:: 00023 sdet_nonmax_suppression_params(const double thresh, const int pfit_type) 00024 { 00025 InitParams(thresh, pfit_type); 00026 } 00027 00028 void sdet_nonmax_suppression_params::InitParams(double thresh, int pfit_type) 00029 { 00030 thresh_ = thresh; 00031 pfit_type_ = pfit_type; 00032 } 00033 00034 //----------------------------------------------------------------------------- 00035 // 00036 //: Checks that parameters are within acceptable bounds 00037 // Note that msg << ends seems to restart the string and erase the 00038 // previous string. We should only use it as the last call, use 00039 // vcl_endl otherwise. 00040 bool sdet_nonmax_suppression_params::SanityCheck() 00041 { 00042 vcl_stringstream msg; 00043 bool valid = true; 00044 00045 if (thresh_<0 || thresh_>100) 00046 { 00047 msg << "ERROR: percentage threshold should be between 0 and 100"; 00048 valid = false; 00049 } 00050 msg << vcl_ends; 00051 00052 SetErrorMsg(msg.str().c_str()); 00053 return valid; 00054 } 00055 00056 vcl_ostream& operator<< (vcl_ostream& os, const sdet_nonmax_suppression_params& nsp) 00057 { 00058 return 00059 os << "sdet_nonmax_suppression_params:\n[---\n" 00060 << "Gradient threshold in percentage " << nsp.thresh_ << vcl_endl 00061 << "---]" << vcl_endl; 00062 }