50 #include <visp3/core/vpConfig.h>
57 #if defined(VISP_HAVE_MODULE_ME) && (defined (VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
59 #include <visp3/core/vpImage.h>
60 #include <visp3/io/vpImageIo.h>
61 #include <visp3/gui/vpDisplayX.h>
62 #include <visp3/gui/vpDisplayGTK.h>
63 #include <visp3/gui/vpDisplayGDI.h>
64 #include <visp3/gui/vpDisplayOpenCV.h>
65 #include <visp3/core/vpColor.h>
67 #include <visp3/me/vpMeEllipse.h>
68 #include <visp3/io/vpParseArgv.h>
69 #include <visp3/core/vpIoTools.h>
72 #define GETOPTARGS "cdi:h"
74 void usage(
const char *name,
const char *badparam, std::string ipath);
75 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display);
86 void usage(
const char *name,
const char *badparam, std::string ipath)
89 Test auto detection of dots using vpDot2.\n\
92 %s [-i <input image path>] [-c] [-d] [-h]\n", name);
96 -i <input image path> %s\n\
97 Set image input path.\n\
98 From this path read \"ViSP-images/circle/circle.pgm\"\n\
100 Setting the VISP_INPUT_IMAGE_PATH environment\n\
101 variable produces the same behaviour than using\n\
105 Disable the mouse click. Useful to automaze the \n\
106 execution of this program without humain intervention.\n\
109 Turn off the display.\n\
116 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
131 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display)
138 case 'c': click_allowed =
false;
break;
139 case 'd': display =
false;
break;
140 case 'i': ipath = optarg_;
break;
141 case 'h': usage(argv[0], NULL, ipath);
return false;
break;
144 usage(argv[0], optarg_, ipath);
149 if ((c == 1) || (c == -1)) {
151 usage(argv[0], NULL, ipath);
152 std::cerr <<
"ERROR: " << std::endl;
153 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
162 main(
int argc,
const char ** argv)
165 std::string env_ipath;
166 std::string opt_ipath;
169 std::string filename;
170 bool opt_click_allowed =
true;
171 bool opt_display =
true;
177 if (! env_ipath.empty())
181 if (getOptions(argc, argv, opt_ipath, opt_click_allowed,
182 opt_display) ==
false) {
187 if (!opt_ipath.empty())
192 if (!opt_ipath.empty() && !env_ipath.empty()) {
193 if (ipath != env_ipath) {
194 std::cout << std::endl
195 <<
"WARNING: " << std::endl;
196 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
197 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
198 <<
" we skip the environment variable." << std::endl;
203 if (opt_ipath.empty() && env_ipath.empty()){
204 usage(argv[0], NULL, ipath);
205 std::cerr << std::endl
206 <<
"ERROR:" << std::endl;
207 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH "
209 <<
" environment variable to specify the location of the " << std::endl
210 <<
" image path where test images are located." << std::endl << std::endl;
233 vpCTRACE <<
"Load: " << filename << std::endl;
243 std::cerr << std::endl
244 <<
"ERROR:" << std::endl;
245 std::cerr <<
" Cannot read " << filename << std::endl;
246 std::cerr <<
" Check your -i " << ipath <<
" option " << std::endl
247 <<
" or VISP_INPUT_IMAGE_PATH environment variable."
254 #if defined VISP_HAVE_X11
256 #elif defined VISP_HAVE_GTK
258 #elif defined VISP_HAVE_GDI
260 #elif defined VISP_HAVE_OPENCV
266 display.
init(I, 100, 100,
"Display...") ;
288 if (opt_display && opt_click_allowed) {
293 std::vector<vpImagePoint> ip;
309 std::cout <<
"Tracking on image: " << filename << std::endl;
315 if (opt_display && opt_click_allowed) {
316 std::cout <<
"A click to exit..." << std::endl;
319 std::cout <<
"------------------------------------------------------------"<<std::endl;
323 std::cout <<
"Catch an exception: " << e << std::endl;
332 std::cout <<
"visp_me module or X11, GTK, GDI or OpenCV display functionalities are required..." << std::endl;
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
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)
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
error that can be emited by ViSP classes.
Class that tracks an ellipse moving edges.
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
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 track(const vpImage< unsigned char > &Im)
void setDisplay(vpMeSite::vpMeSiteDisplayType select)
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
void display(const vpImage< unsigned char > &I, vpColor col)
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
static void read(vpImage< unsigned char > &I, const std::string &filename)
void setThreshold(const double &t)
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)
double getSampleStep() const