51 #include <visp3/core/vpConfig.h> 58 #if defined(VISP_HAVE_MODULE_ME) && \ 59 (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)) 61 #include <visp3/core/vpColor.h> 62 #include <visp3/core/vpImage.h> 63 #include <visp3/gui/vpDisplayGDI.h> 64 #include <visp3/gui/vpDisplayGTK.h> 65 #include <visp3/gui/vpDisplayOpenCV.h> 66 #include <visp3/gui/vpDisplayX.h> 67 #include <visp3/io/vpImageIo.h> 69 #include <visp3/core/vpIoTools.h> 70 #include <visp3/io/vpParseArgv.h> 71 #include <visp3/me/vpMeEllipse.h> 74 #define GETOPTARGS "cdi:h" 76 void usage(
const char *name,
const char *badparam, std::string ipath);
77 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display);
88 void usage(
const char *name,
const char *badparam, std::string ipath)
91 Test auto detection of dots using vpDot2.\n\ 94 %s [-i <input image path>] [-c] [-d] [-h]\n", name);
98 -i <input image path> %s\n\ 99 Set image input path.\n\ 100 From this path read \"circle/circle.pgm\"\n\ 102 Setting the VISP_INPUT_IMAGE_PATH environment\n\ 103 variable produces the same behaviour than using\n\ 107 Disable the mouse click. Useful to automaze the \n\ 108 execution of this program without humain intervention.\n\ 111 Turn off the display.\n\ 114 Print the help.\n", ipath.c_str());
117 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
132 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display)
140 click_allowed =
false;
149 usage(argv[0], NULL, ipath);
154 usage(argv[0], optarg_, ipath);
160 if ((c == 1) || (c == -1)) {
162 usage(argv[0], NULL, ipath);
163 std::cerr <<
"ERROR: " << std::endl;
164 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
171 int main(
int argc,
const char **argv)
173 #if defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV) 175 std::string env_ipath;
176 std::string opt_ipath;
179 std::string filename;
180 bool opt_click_allowed =
true;
181 bool opt_display =
true;
188 if (!env_ipath.empty())
192 if (getOptions(argc, argv, opt_ipath, opt_click_allowed, opt_display) ==
false) {
197 if (!opt_ipath.empty())
202 if (!opt_ipath.empty() && !env_ipath.empty()) {
203 if (ipath != env_ipath) {
204 std::cout << std::endl <<
"WARNING: " << std::endl;
205 std::cout <<
" Since -i <visp image path=" << ipath <<
"> " 206 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
207 <<
" we skip the environment variable." << std::endl;
212 if (opt_ipath.empty() && env_ipath.empty()) {
213 usage(argv[0], NULL, ipath);
214 std::cerr << std::endl <<
"ERROR:" << std::endl;
215 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
216 <<
" environment variable to specify the location of the " << std::endl
217 <<
" image path where test images are located." << std::endl
240 vpCTRACE <<
"Load: " << filename << std::endl;
248 std::cerr << std::endl <<
"ERROR:" << std::endl;
249 std::cerr <<
" Cannot read " << filename << std::endl;
250 std::cerr <<
" Check your -i " << ipath <<
" option " << std::endl
251 <<
" or VISP_INPUT_IMAGE_PATH environment variable." << std::endl;
256 #if defined VISP_HAVE_X11 258 #elif defined VISP_HAVE_GTK 260 #elif defined VISP_HAVE_GDI 262 #elif defined VISP_HAVE_OPENCV 268 display.
init(I, 100, 100,
"Display...");
289 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;
322 std::cout <<
"Catch an exception: " << e << std::endl;
328 std::cout <<
"Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
336 std::cout <<
"visp_me module or X11, GTK, GDI or OpenCV display " 337 "functionalities are required..." void track(const vpImage< unsigned char > &I)
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
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 using 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 initTracking(const vpImage< unsigned char > &I, bool trackArc=false)
double getSampleStep() const
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...
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)