52 #include <visp3/core/vpConfig.h> 53 #include <visp3/core/vpDebug.h> 60 #if defined(VISP_HAVE_MODULE_ME) && \ 61 (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)) 63 #include <visp3/core/vpColor.h> 64 #include <visp3/core/vpImage.h> 65 #include <visp3/core/vpImagePoint.h> 66 #include <visp3/gui/vpDisplayGDI.h> 67 #include <visp3/gui/vpDisplayGTK.h> 68 #include <visp3/gui/vpDisplayOpenCV.h> 69 #include <visp3/gui/vpDisplayX.h> 70 #include <visp3/io/vpImageIo.h> 72 #include <visp3/core/vpIoTools.h> 73 #include <visp3/io/vpParseArgv.h> 74 #include <visp3/io/vpVideoReader.h> 75 #include <visp3/me/vpMeNurbs.h> 78 #define GETOPTARGS "cdi:h" 80 void usage(
const char *name,
const char *badparam, std::string ipath);
81 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display);
92 void usage(
const char *name,
const char *badparam, std::string ipath)
95 Tracking of a nurbs using vpMe.\n\ 98 %s [-i <input image path>] [-c] [-d] [-h]\n", name);
102 -i <input image path> %s\n\ 103 Set image input path.\n\ 104 From this path read images \n\ 105 \"ellipse-1/image.%%04d.pgm\"\n\ 106 Setting the VISP_INPUT_IMAGE_PATH environment\n\ 107 variable produces the same behaviour than using\n\ 111 Disable the mouse click. Useful to automaze the \n\ 112 execution of this program without humain intervention.\n\ 115 Turn off the display.\n\ 118 Print the help.\n", ipath.c_str());
121 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
136 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display)
144 click_allowed =
false;
153 usage(argv[0], NULL, ipath);
158 usage(argv[0], optarg_, ipath);
164 if ((c == 1) || (c == -1)) {
166 usage(argv[0], NULL, ipath);
167 std::cerr <<
"ERROR: " << std::endl;
168 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
175 int main(
int argc,
const char **argv)
178 std::string env_ipath;
179 std::string opt_ipath;
181 std::string filename;
182 bool opt_click_allowed =
true;
183 bool opt_display =
true;
190 if (!env_ipath.empty())
194 if (getOptions(argc, argv, opt_ipath, opt_click_allowed, opt_display) ==
false) {
199 if (!opt_ipath.empty())
204 if (!opt_ipath.empty() && !env_ipath.empty()) {
205 if (ipath != env_ipath) {
206 std::cout << std::endl <<
"WARNING: " << std::endl;
207 std::cout <<
" Since -i <visp image path=" << ipath <<
"> " 208 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
209 <<
" we skip the environment variable." << std::endl;
214 if (opt_ipath.empty() && env_ipath.empty()) {
215 usage(argv[0], NULL, ipath);
216 std::cerr << std::endl <<
"ERROR:" << std::endl;
217 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
218 <<
" environment variable to specify the location of the " << std::endl
219 <<
" image path where test images are located." << std::endl
240 #if defined VISP_HAVE_X11 242 #elif defined VISP_HAVE_GTK 244 #elif defined VISP_HAVE_GDI 246 #elif defined VISP_HAVE_OPENCV 252 display.
init(I, 100, 100,
"Display...");
274 if (opt_click_allowed) {
275 std::cout <<
"Click on points along the edge with the left button." << std::endl;
276 std::cout <<
"Then click on the right button to continue." << std::endl;
280 std::list<vpImagePoint> list;
294 if (opt_display && opt_click_allowed) {
295 std::cout <<
"A click to continue..." << std::endl;
298 std::cout <<
"------------------------------------------------------------" << std::endl;
300 for (
int iter = 1; iter < 40; iter++) {
317 if (opt_display && opt_click_allowed) {
318 std::cout <<
"A click to exit..." << std::endl;
323 std::cout <<
"Catch an exception: " << e.
getMessage() << std::endl;
332 std::cout <<
"visp_me module or X11, GTK, GDI or OpenCV display " 333 "functionalities are required..." VISP_EXPORT int wait(double t0, double t)
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
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...
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.
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 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. Thus to enable this class OpenC...
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
const char * getMessage(void) const
void setFileName(const char *filename)
void setThreshold(const double &t)
void setFirstFrameIndex(const long first_frame)
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)