54 #include <visp/vpDebug.h>
55 #include <visp/vpConfig.h>
62 #if (defined (VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI))
64 #include <visp/vpImage.h>
65 #include <visp/vpImageIo.h>
66 #include <visp/vpDisplayX.h>
67 #include <visp/vpDisplayGTK.h>
68 #include <visp/vpDisplayGDI.h>
69 #include <visp/vpColor.h>
71 #include <visp/vpMeEllipse.h>
72 #include <visp/vpParseArgv.h>
73 #include <visp/vpIoTools.h>
76 #define GETOPTARGS "cdi:h"
78 void usage(
const char *name,
const char *badparam, std::string ipath);
79 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display);
90 void usage(
const char *name,
const char *badparam, std::string ipath)
93 Test auto detection of dots using vpDot2.\n\
96 %s [-i <input image path>] [-c] [-d] [-h]\n", name);
100 -i <input image path> %s\n\
101 Set image input path.\n\
102 From this path read \"ViSP-images/circle/circle.pgm\"\n\
104 Setting the VISP_INPUT_IMAGE_PATH environment\n\
105 variable produces the same behaviour than using\n\
109 Disable the mouse click. Useful to automaze the \n\
110 execution of this program without humain intervention.\n\
113 Turn off the display.\n\
120 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
135 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display)
142 case 'c': click_allowed =
false;
break;
143 case 'd': display =
false;
break;
144 case 'i': ipath = optarg_;
break;
145 case 'h': usage(argv[0], NULL, ipath);
return false;
break;
148 usage(argv[0], optarg_, ipath);
153 if ((c == 1) || (c == -1)) {
155 usage(argv[0], NULL, ipath);
156 std::cerr <<
"ERROR: " << std::endl;
157 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
166 main(
int argc,
const char ** argv)
169 std::string env_ipath;
170 std::string opt_ipath;
173 std::string filename;
174 bool opt_click_allowed =
true;
175 bool opt_display =
true;
178 char *ptenv = getenv(
"VISP_INPUT_IMAGE_PATH");
183 if (! env_ipath.empty())
188 if (getOptions(argc, argv, opt_ipath, opt_click_allowed,
189 opt_display) ==
false) {
194 if (!opt_ipath.empty())
199 if (!opt_ipath.empty() && !env_ipath.empty()) {
200 if (ipath != env_ipath) {
201 std::cout << std::endl
202 <<
"WARNING: " << std::endl;
203 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
204 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
205 <<
" we skip the environment variable." << std::endl;
210 if (opt_ipath.empty() && env_ipath.empty()){
211 usage(argv[0], NULL, ipath);
212 std::cerr << std::endl
213 <<
"ERROR:" << std::endl;
214 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH "
216 <<
" environment variable to specify the location of the " << std::endl
217 <<
" image path where test images are located." << std::endl << std::endl;
231 filename = dirname +
"circle.pgm";
240 vpCTRACE <<
"Load: " << filename << std::endl;
250 std::cerr << std::endl
251 <<
"ERROR:" << std::endl;
252 std::cerr <<
" Cannot read " << filename << std::endl;
253 std::cerr <<
" Check your -i " << ipath <<
" option " << std::endl
254 <<
" or VISP_INPUT_IMAGE_PATH environment variable."
261 #if defined VISP_HAVE_X11
263 #elif defined VISP_HAVE_GTK
265 #elif defined VISP_HAVE_GDI
271 display.
init(I, 100, 100,
"Display...") ;
295 if (opt_display && opt_click_allowed) {
317 std::cout <<
"Tracking on image: " << filename << std::endl;
323 if (opt_display && opt_click_allowed) {
324 std::cout <<
"A click to exit..." << std::endl;
327 std::cout <<
"------------------------------------------------------------"<<std::endl;
331 std::cout <<
"Catch an exception: " << e << std::endl;
339 vpERROR_TRACE(
"You do not have X11, GTK or GDI display functionalities...");
void initTracking(const vpImage< unsigned char > &I)
void setPointsToTrack(const int &n)
Display for windows using GDI (available on any windows 32 platform).
void setSampleStep(const double &s)
Define the X11 console to display images.
error that can be emited by ViSP classes.
Class that tracks an ellipse moving edges.
Contains predetermined masks for sites and holds moving edges tracking parameters.
static const vpColor green
static void flush(const vpImage< unsigned char > &I)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
void set_i(const double ii)
void track(const vpImage< unsigned char > &Im)
void setDisplay(vpMeSite::vpMeSiteDisplayType select)
static void display(const vpImage< unsigned char > &I)
void display(const vpImage< unsigned char > &I, vpColor col)
The vpDisplayGTK allows to display image using the GTK+ library version 1.2.
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
void set_j(const double jj)
void setThreshold(const double &t)
void setCircle(bool is_circle)
virtual bool getClick(bool blocking=true)=0
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
void setRange(const unsigned int &r)
static void read(vpImage< unsigned char > &I, const char *filename)
double getSampleStep() const