48 #include <visp3/core/vpConfig.h>
49 #include <visp3/core/vpDebug.h>
56 #if defined(VISP_HAVE_MODULE_ME) && \
57 (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
59 #include <visp3/core/vpColor.h>
60 #include <visp3/core/vpImage.h>
61 #include <visp3/core/vpImagePoint.h>
62 #include <visp3/gui/vpDisplayGDI.h>
63 #include <visp3/gui/vpDisplayGTK.h>
64 #include <visp3/gui/vpDisplayOpenCV.h>
65 #include <visp3/gui/vpDisplayX.h>
66 #include <visp3/io/vpImageIo.h>
68 #include <visp3/core/vpIoTools.h>
69 #include <visp3/io/vpParseArgv.h>
70 #include <visp3/io/vpVideoReader.h>
71 #include <visp3/me/vpMeNurbs.h>
74 #define GETOPTARGS "cdi:h"
76 #ifdef ENABLE_VISP_NAMESPACE
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)
94 #if VISP_HAVE_DATASET_VERSION >= 0x030600
95 std::string ext(
"png");
97 std::string ext(
"pgm");
100 Tracking of a nurbs using vpMe.\n\
103 %s [-i <input image path>] [-c] [-d] [-h]\n",
108 -i <input image path> %s\n\
109 Set image input path.\n\
110 From this path read images \n\
111 \"ellipse-1/image.%%04d.%s\"\n\
112 Setting the VISP_INPUT_IMAGE_PATH environment\n\
113 variable produces the same behaviour than using\n\
117 Disable the mouse click. Useful to automate the \n\
118 execution of this program without human intervention.\n\
121 Turn off the display.\n\
125 ipath.c_str(), ext.c_str());
128 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
143 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display)
151 click_allowed =
false;
160 usage(argv[0],
nullptr, ipath);
165 usage(argv[0], optarg_, ipath);
171 if ((c == 1) || (c == -1)) {
173 usage(argv[0],
nullptr, ipath);
174 std::cerr <<
"ERROR: " << std::endl;
175 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
182 int main(
int argc,
const char **argv)
185 std::string env_ipath;
186 std::string opt_ipath;
188 std::string filename;
189 bool opt_click_allowed =
true;
190 bool opt_display =
true;
192 #if VISP_HAVE_DATASET_VERSION >= 0x030600
193 std::string ext(
"png");
195 std::string ext(
"pgm");
203 if (!env_ipath.empty())
207 if (getOptions(argc, argv, opt_ipath, opt_click_allowed, opt_display) ==
false) {
212 if (!opt_ipath.empty())
217 if (!opt_ipath.empty() && !env_ipath.empty()) {
218 if (ipath != env_ipath) {
219 std::cout << std::endl <<
"WARNING: " << std::endl;
220 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
221 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
222 <<
" we skip the environment variable." << std::endl;
227 if (opt_ipath.empty() && env_ipath.empty()) {
228 usage(argv[0],
nullptr, ipath);
229 std::cerr << std::endl <<
"ERROR:" << std::endl;
230 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
231 <<
" environment variable to specify the location of the " << std::endl
232 <<
" image path where test images are located." << std::endl
253 #if defined(VISP_HAVE_X11)
255 #elif defined(VISP_HAVE_GTK)
257 #elif defined(VISP_HAVE_GDI)
259 #elif defined(HAVE_OPENCV_HIGHGUI)
265 display.init(I, 100, 100,
"Display...");
288 if (opt_click_allowed) {
289 std::cout <<
"Click on points along the edge with the left button." << std::endl;
290 std::cout <<
"Then click on the right button to continue." << std::endl;
295 std::list<vpImagePoint> list;
309 if (opt_display && opt_click_allowed) {
310 std::cout <<
"A click to continue..." << std::endl;
313 std::cout <<
"------------------------------------------------------------" << std::endl;
315 for (
int iter = 1; iter < 40; iter++) {
332 if (opt_display && opt_click_allowed) {
333 std::cout <<
"A click to exit..." << std::endl;
339 std::cout <<
"Catch an exception: " << e.
getMessage() << std::endl;
348 std::cout <<
"visp_me module or X11, GTK, GDI or OpenCV display "
349 "functionalities are required..."
static const vpColor green
Display for windows using GDI (available on any windows 32 platform).
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void flush(const vpImage< unsigned char > &I)
error that can be emitted by ViSP classes.
const char * getMessage() const
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
void setDisplay(vpMeSite::vpMeSiteDisplayType select)
void setPointsToTrack(const int &points_to_track)
void setRange(const unsigned int &range)
void setLikelihoodThresholdType(const vpLikelihoodThresholdType likelihood_threshold_type)
void setThreshold(const double &threshold)
void setSampleStep(const double &sample_step)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the...
void open(vpImage< vpRGBa > &I)
void setFileName(const std::string &filename)
void setFirstFrameIndex(const long first_frame)
bool getFrame(vpImage< vpRGBa > &I, long frame)
VISP_EXPORT int wait(double t0, double t)