38 #include <visp3/core/vpImage.h> 39 #include <visp3/io/vpImageIo.h> 40 #include <visp3/core/vpIoTools.h> 41 #include <visp3/io/vpParseArgv.h> 42 #include <visp3/core/vpDebug.h> 54 #define GETOPTARGS "cdi:p:h" 56 void usage(
const char *name,
const char *badparam, std::string ipath, std::string ppath);
57 bool getOptions(
int argc,
const char **argv, std::string &ipath, std::string &ppath);
70 void usage(
const char *name,
const char *badparam, std::string ipath, std::string ppath)
73 Read images on the disk.\n\ 76 %s [-i <input image path>] [-p <personal image path>]\n\ 82 -i <input image path> %s\n\ 83 Set image input path.\n\ 84 From this path read \"ViSP-images/Klimt/Klimt.pgm,\n\ 85 .ppm, .jpeg and .png images.\n\ 86 Setting the VISP_INPUT_IMAGE_PATH environment\n\ 87 variable produces the same behaviour than using\n\ 90 -p <personal image path> %s\n\ 91 Set personal image path.\n\ 92 From this path read the image \"%s\".\n\ 96 ipath.c_str(), ppath.c_str(), ppath.c_str());
99 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
113 bool getOptions(
int argc,
const char **argv, std::string &ipath, std::string &ppath)
120 case 'i': ipath = optarg_;
break;
121 case 'p': ppath = optarg_;
break;
122 case 'h': usage(argv[0], NULL, ipath, ppath);
return false;
break;
129 usage(argv[0], optarg_, ipath, ppath);
return false;
break;
133 if ((c == 1) || (c == -1)) {
135 usage(argv[0], NULL, ipath, ppath);
136 std::cerr <<
"ERROR: " << std::endl;
137 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
145 main(
int argc,
const char ** argv)
148 std::string env_ipath;
149 std::string opt_ipath;
150 std::string opt_ppath;
153 std::string filename;
159 if (! env_ipath.empty())
163 if (getOptions(argc, argv, opt_ipath, opt_ppath) ==
false) {
168 if (!opt_ipath.empty())
170 if (!opt_ppath.empty())
175 if (!opt_ipath.empty() && !env_ipath.empty()) {
176 if (ipath != env_ipath) {
177 std::cout << std::endl
178 <<
"WARNING: " << std::endl;
179 std::cout <<
" Since -i <visp image path=" << ipath <<
"> " 180 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
181 <<
" we skip the environment variable." << std::endl;
196 if (opt_ppath.empty())
200 printf(
"Read ppm ok\n");
203 printf(
"Read pgm ok\n");
206 printf(
"Read jpeg ok\n");
209 printf(
"Read jpg ok\n");
212 printf(
"Read png ok\n");
216 printf(
"Read ppm ok\n");
219 printf(
"Read pgm ok\n");
222 printf(
"Read jpeg ok\n");
225 printf(
"Read jpg ok\n");
228 printf(
"Read png ok\n");
232 filename = opt_ppath;
234 vpTRACE(
"image read without problem");
238 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 void read(vpImage< unsigned char > &I, const char *filename)