50 #include <visp3/core/vpIoTools.h> 51 #include <visp3/core/vpRobust.h> 52 #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\ 91 Print the help.\n", ofilename.c_str());
94 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
106 bool getOptions(
int argc,
const char **argv, std::string &ofilename)
117 usage(argv[0], NULL, ofilename);
125 usage(argv[0], optarg_, ofilename);
131 if ((c == 1) || (c == -1)) {
133 usage(argv[0], NULL, ofilename);
134 std::cerr <<
"ERROR: " << std::endl;
135 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
142 int main(
int argc,
const char **argv)
145 std::string ofilename;
146 std::string username;
150 ofilename =
"C:/temp";
159 ofilename = ofilename +
"/" + username;
167 usage(argv[0], NULL, ofilename);
168 std::cerr << std::endl <<
"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 <<
"ERROR:" << std::endl;
192 std::cerr <<
" Cannot create the file: " << ofilename << std::endl;
193 std::cerr <<
" Check your -o " << ofilename <<
" option " << std::endl;
198 if (fabs(x / sig) <= (4.6851)) {
203 f << x <<
" " << w << std::endl;
208 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)