44 #include <visp3/core/vpConfig.h>
45 #include <visp3/core/vpDebug.h>
46 #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI))
48 #include <visp3/blob/vpDot2.h>
49 #include <visp3/core/vpCameraParameters.h>
50 #include <visp3/core/vpImage.h>
51 #include <visp3/core/vpIoTools.h>
52 #include <visp3/gui/vpDisplayGDI.h>
53 #include <visp3/gui/vpDisplayGTK.h>
54 #include <visp3/gui/vpDisplayX.h>
55 #include <visp3/io/vpImageIo.h>
56 #include <visp3/io/vpParseArgv.h>
57 #ifdef VISP_HAVE_MODULE_FEATURES
58 #include <visp3/visual_features/vpFeatureBuilder.h>
59 #include <visp3/visual_features/vpFeatureEllipse.h>
69 #define GETOPTARGS "cdi:h"
71 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display);
73 void usage(
const char *name,
const char *badparam, std::string ipath);
83 void usage(
const char *name,
const char *badparam, std::string ipath)
89 %s [-i <input image path>] [-c] [-d] [-h]\n", name);
93 -i <input image path> %s\n\
94 Set image input path.\n\
95 From this path read image \n\
96 \"ellipse/ellipse.pgm\"\n\
97 Setting the VISP_INPUT_IMAGE_PATH environment\n\
98 variable produces the same behaviour than using\n\
102 Disable the mouse click. Useful to automaze the \n\
103 execution of this program without humain intervention.\n\
106 Turn off the display.\n\
109 Print the help.\n", ipath.c_str());
112 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
126 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display)
134 click_allowed =
false;
143 usage(argv[0], NULL, ipath);
148 usage(argv[0], optarg_, ipath);
154 if ((c == 1) || (c == -1)) {
156 usage(argv[0], NULL, ipath);
157 std::cerr <<
"ERROR: " << std::endl;
158 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
165 int main(
int argc,
const char **argv)
168 std::string env_ipath;
169 std::string opt_ipath;
172 std::string filename;
173 bool opt_click_allowed =
true;
174 bool opt_display =
true;
181 if (!env_ipath.empty())
185 if (getOptions(argc, argv, opt_ipath, opt_click_allowed, opt_display) ==
false) {
190 if (!opt_ipath.empty())
195 if (!opt_ipath.empty() && !env_ipath.empty()) {
196 if (ipath != env_ipath) {
197 std::cout << std::endl <<
"WARNING: " << std::endl;
198 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
199 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
200 <<
" we skip the environment variable." << std::endl;
205 if (opt_ipath.empty() && env_ipath.empty()) {
206 usage(argv[0], NULL, ipath);
207 std::cerr << std::endl <<
"ERROR:" << std::endl;
208 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
209 <<
" environment variable to specify the location of the " << std::endl
210 <<
" image path where test images are located." << std::endl
233 vpCTRACE <<
"Load: " << filename << std::endl;
241 std::cerr << std::endl <<
"ERROR:" << std::endl;
242 std::cerr <<
" Cannot read " << filename << std::endl;
243 std::cerr <<
" Check your -i " << ipath <<
" option " << std::endl
244 <<
" or VISP_INPUT_IMAGE_PATH environment variable." << std::endl;
249 #if defined VISP_HAVE_X11
251 #elif defined VISP_HAVE_GTK
253 #elif defined VISP_HAVE_GDI
259 display.init(I, 100, 100,
"Display...");
271 std::cout <<
"debut 1\n";
287 #ifdef VISP_HAVE_MODULE_FEATURES
292 #ifdef VISP_HAVE_MODULE_FEATURES
296 if (opt_click_allowed) {
297 std::cout <<
"A click to exit..." << std::endl;
303 std::cout <<
"Catch an exception: " << e.
getMessage() << std::endl;
308 int main() {
vpERROR_TRACE(
"You do not have X11, GTK or GDI display functionalities..."); }