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 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)
90 #if VISP_HAVE_DATASET_VERSION >= 0x030600
91 std::string ext(
"png");
93 std::string ext(
"pgm");
96 Tracking of a nurbs using vpMe.\n\
99 %s [-i <input image path>] [-c] [-d] [-h]\n",
104 -i <input image path> %s\n\
105 Set image input path.\n\
106 From this path read images \n\
107 \"ellipse-1/image.%%04d.%s\"\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 automate the \n\
114 execution of this program without human intervention.\n\
117 Turn off the display.\n\
121 ipath.c_str(), ext.c_str());
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)
147 click_allowed =
false;
156 usage(argv[0],
nullptr, ipath);
161 usage(argv[0], optarg_, ipath);
167 if ((c == 1) || (c == -1)) {
169 usage(argv[0],
nullptr, ipath);
170 std::cerr <<
"ERROR: " << std::endl;
171 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
178 int main(
int argc,
const char **argv)
181 std::string env_ipath;
182 std::string opt_ipath;
184 std::string filename;
185 bool opt_click_allowed =
true;
186 bool opt_display =
true;
188 #if VISP_HAVE_DATASET_VERSION >= 0x030600
189 std::string ext(
"png");
191 std::string ext(
"pgm");
199 if (!env_ipath.empty())
203 if (getOptions(argc, argv, opt_ipath, opt_click_allowed, opt_display) ==
false) {
208 if (!opt_ipath.empty())
213 if (!opt_ipath.empty() && !env_ipath.empty()) {
214 if (ipath != env_ipath) {
215 std::cout << std::endl <<
"WARNING: " << std::endl;
216 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
217 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
218 <<
" we skip the environment variable." << std::endl;
223 if (opt_ipath.empty() && env_ipath.empty()) {
224 usage(argv[0],
nullptr, ipath);
225 std::cerr << std::endl <<
"ERROR:" << std::endl;
226 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
227 <<
" environment variable to specify the location of the " << std::endl
228 <<
" image path where test images are located." << std::endl
249 #if defined(VISP_HAVE_X11)
251 #elif defined(VISP_HAVE_GTK)
253 #elif defined(VISP_HAVE_GDI)
255 #elif defined(HAVE_OPENCV_HIGHGUI)
261 display.init(I, 100, 100,
"Display...");
284 if (opt_click_allowed) {
285 std::cout <<
"Click on points along the edge with the left button." << std::endl;
286 std::cout <<
"Then click on the right button to continue." << std::endl;
291 std::list<vpImagePoint> list;
305 if (opt_display && opt_click_allowed) {
306 std::cout <<
"A click to continue..." << std::endl;
309 std::cout <<
"------------------------------------------------------------" << std::endl;
311 for (
int iter = 1; iter < 40; iter++) {
328 if (opt_display && opt_click_allowed) {
329 std::cout <<
"A click to exit..." << std::endl;
335 std::cout <<
"Catch an exception: " << e.
getMessage() << std::endl;
344 std::cout <<
"visp_me module or X11, GTK, GDI or OpenCV display "
345 "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...
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
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)
void display(vpImage< unsigned char > &I, const std::string &title)
Display a gray-scale image.
VISP_EXPORT int wait(double t0, double t)