55 #include <visp/vpDebug.h>
56 #include <visp/vpConfig.h>
63 #if (defined (VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
65 #include <visp/vpImage.h>
66 #include <visp/vpImageIo.h>
67 #include <visp/vpImagePoint.h>
68 #include <visp/vpDisplayX.h>
69 #include <visp/vpDisplayGTK.h>
70 #include <visp/vpDisplayGDI.h>
71 #include <visp/vpDisplayOpenCV.h>
72 #include <visp/vpColor.h>
74 #include <visp/vpMeNurbs.h>
75 #include <visp/vpParseArgv.h>
76 #include <visp/vpIoTools.h>
77 #include <visp/vpVideoReader.h>
80 #define GETOPTARGS "cdi:h"
82 void usage(
const char *name,
const char *badparam, std::string ipath);
83 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display);
94 void usage(
const char *name,
const char *badparam, std::string ipath)
97 Tracking of a nurbs using vpMe.\n\
100 %s [-i <input image path>] [-c] [-d] [-h]\n", name);
104 -i <input image path> %s\n\
105 Set image input path.\n\
106 From this path read images \n\
107 \"ViSP-images/ellipse-1/image.%%04d.pgm\"\n\
108 Setting the VISP_INPUT_IMAGE_PATH environment\n\
109 variable produces the same behaviour than using\n\
113 Disable the mouse click. Useful to automaze the \n\
114 execution of this program without humain intervention.\n\
117 Turn off the display.\n\
124 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
139 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display)
146 case 'c': click_allowed =
false;
break;
147 case 'd': display =
false;
break;
148 case 'i': ipath = optarg_;
break;
149 case 'h': usage(argv[0], NULL, ipath);
return false;
break;
152 usage(argv[0], optarg_, ipath);
157 if ((c == 1) || (c == -1)) {
159 usage(argv[0], NULL, ipath);
160 std::cerr <<
"ERROR: " << std::endl;
161 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
170 main(
int argc,
const char ** argv)
173 std::string env_ipath;
174 std::string opt_ipath;
176 std::string filename;
177 bool opt_click_allowed =
true;
178 bool opt_display =
true;
184 if (! env_ipath.empty())
189 if (getOptions(argc, argv, opt_ipath, opt_click_allowed, 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;
238 #if defined VISP_HAVE_X11
240 #elif defined VISP_HAVE_GTK
242 #elif defined VISP_HAVE_GDI
244 #elif defined VISP_HAVE_OPENCV
250 display.
init(I, 100, 100,
"Display...") ;
272 if (opt_click_allowed)
274 std::cout <<
"Click on points along the edge with the left button." << std::endl;
275 std::cout <<
"Then click on the right button to continue." << std::endl;
281 std::list<vpImagePoint> list;
295 if (opt_display && opt_click_allowed) {
296 std::cout <<
"A click to continue..." << std::endl;
299 std::cout <<
"------------------------------------------------------------"<<std::endl;
301 for (
int iter = 1 ; iter < 40 ; iter++)
320 if (opt_display && opt_click_allowed) {
321 std::cout <<
"A click to exit..." << std::endl;
327 std::cout <<
"Catch an exception: " << e << std::endl;
335 vpERROR_TRACE(
"You do not have X11, GTK, GDI or OpenCV display functionalities...");
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
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.
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
error that can be emited by ViSP classes.
Contains predetermined masks for sites and holds moving edges tracking parameters.
static int wait(double t0, double t)
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 open(vpImage< vpRGBa > &I)
bool getFrame(vpImage< vpRGBa > &I, long frame)
void setDisplay(vpMeSite::vpMeSiteDisplayType select)
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the opencv library.
The vpDisplayGTK allows to display image using the GTK+ library version 1.2.
void setFileName(const char *filename)
void setThreshold(const double &t)
void setFirstFrameIndex(const long first_frame)
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)