1 // This is brl/bseg/sdet/sdet_nonmax_suppression_params.cxx
2 #include <sstream>
3 #include <iostream>
4 #include "sdet_nonmax_suppression_params.h"
5 //:
6 // \file
7 // See sdet_nonmax_suppression_params.h
8 //
9 //-----------------------------------------------------------------------------
10 #ifdef _MSC_VER
11 #  include "vcl_msvc_warnings.h"
12 #endif
13 
14 //------------------------------------------------------------------------
15 // Constructors
16 //
17 
18 sdet_nonmax_suppression_params::
sdet_nonmax_suppression_params(const sdet_nonmax_suppression_params & nsp)19 sdet_nonmax_suppression_params(const sdet_nonmax_suppression_params& nsp)
20   : gevd_param_mixin()
21 {
22   InitParams(nsp.thresh_, nsp.pfit_type_);
23 }
24 
25 sdet_nonmax_suppression_params::
sdet_nonmax_suppression_params(const double thresh,const int pfit_type)26 sdet_nonmax_suppression_params(const double thresh, const int pfit_type)
27 {
28   InitParams(thresh, pfit_type);
29 }
30 
InitParams(double thresh,int pfit_type)31 void sdet_nonmax_suppression_params::InitParams(double thresh, int pfit_type)
32 {
33   thresh_ = thresh;
34   pfit_type_ = pfit_type;
35 }
36 
37 //-----------------------------------------------------------------------------
38 //
39 //:   Checks that parameters are within acceptable bounds
40 //    Note that msg << ends seems to restart the string and erase the
41 //    previous string. We should only use it as the last call, use
42 //    std::endl otherwise.
SanityCheck()43 bool sdet_nonmax_suppression_params::SanityCheck()
44 {
45   std::stringstream msg;
46   bool valid = true;
47 
48   if (thresh_<0 || thresh_>100)
49   {
50     msg << "ERROR: percentage threshold should be between 0 and 100";
51     valid = false;
52   }
53   msg << std::ends;
54 
55   SetErrorMsg(msg.str().c_str());
56   return valid;
57 }
58 
operator <<(std::ostream & os,const sdet_nonmax_suppression_params & nsp)59 std::ostream& operator<< (std::ostream& os, const sdet_nonmax_suppression_params& nsp)
60 {
61   return
62   os << "sdet_nonmax_suppression_params:\n[---\n"
63      << "Gradient threshold in percentage " << nsp.thresh_ << std::endl
64      << "---]" << std::endl;
65 }
66