45 #include <visp3/core/vpRobust.h>
48 #include <visp3/core/vpIoTools.h>
49 #include <visp3/io/vpParseArgv.h>
54 #define GETOPTARGS "cdho:"
56 void usage(
const char *name,
const char *badparam, std::string ofilename);
57 bool getOptions(
int argc,
const char **argv, std::string &ofilename);
67 void usage(
const char *name,
const char *badparam, std::string ofilename)
70 Test some vpMath functionalities. Compute weights and print\n\
71 them in an output file.\n\
73 Using gnuplot the content of the output file can be printed by:\n\
74 set style data line\n\
75 set ylabel \"weight\"\n\
77 set xlabel \"Normalized residuals\"\n\
78 plot '%s' title \"Tukey Estimator\" lw 2, 1 title \"Least-Squares\" lw 2\n\
82 %s [-o <output filename>] [-h]\n", ofilename.c_str(), name);
86 -o <output filename> %s\n\
87 Name and path of the file containing computed \n\
95 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
107 bool getOptions(
int argc,
const char **argv, std::string &ofilename)
114 case 'o': ofilename = optarg_;
break;
115 case 'h': usage(argv[0], NULL, ofilename);
return false;
break;
121 usage(argv[0], optarg_, ofilename);
126 if ((c == 1) || (c == -1)) {
128 usage(argv[0], NULL, ofilename);
129 std::cerr <<
"ERROR: " << std::endl;
130 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
140 main(
int argc,
const char ** argv)
143 std::string ofilename;
144 std::string username;
148 ofilename =
"C:/temp";
157 ofilename = ofilename +
"/" + username;
166 usage(argv[0], NULL, ofilename);
167 std::cerr << std::endl
168 <<
"ERROR:" << std::endl;
169 std::cerr <<
" Cannot create " << ofilename << std::endl;
170 std::cerr <<
" Check your -o " << ofilename <<
" option " << std::endl;
176 ofilename = ofilename +
"/w.dat";
179 if (getOptions(argc, argv, ofilename) ==
false) {
187 std::cout <<
"Create file: " << ofilename << std::endl;
188 f.open(ofilename.c_str());
190 usage(argv[0], NULL, ofilename);
191 std::cerr << std::endl
192 <<
"ERROR:" << std::endl;
193 std::cerr <<
" Cannot create the file: " << ofilename << std::endl;
194 std::cerr <<
" Check your -o " << ofilename <<
" option " << std::endl;
201 if (fabs(x/sig)<=(4.6851))
209 f << x <<
" "<<w <<std::endl ;
215 std::cout <<
"Catch an exception: " << e << std::endl;
error that can be emited by ViSP classes.
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
static double sqr(double x)