46#include <visp3/core/vpConfig.h>
47#include <visp3/core/vpDebug.h>
54#if defined(VISP_HAVE_MODULE_ME) && \
55 (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
57#include <visp3/core/vpColor.h>
58#include <visp3/core/vpImage.h>
59#include <visp3/core/vpImagePoint.h>
60#include <visp3/gui/vpDisplayGDI.h>
61#include <visp3/gui/vpDisplayGTK.h>
62#include <visp3/gui/vpDisplayOpenCV.h>
63#include <visp3/gui/vpDisplayX.h>
64#include <visp3/io/vpImageIo.h>
66#include <visp3/core/vpIoTools.h>
67#include <visp3/io/vpParseArgv.h>
68#include <visp3/io/vpVideoReader.h>
69#include <visp3/me/vpMeNurbs.h>
72#define GETOPTARGS "cdi:h"
74#ifdef ENABLE_VISP_NAMESPACE
78void usage(
const char *name,
const char *badparam, std::string ipath);
79bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display);
90void usage(
const char *name,
const char *badparam, std::string ipath)
92#if defined(VISP_HAVE_DATASET)
93#if VISP_HAVE_DATASET_VERSION >= 0x030600
94 std::string ext(
"png");
96 std::string ext(
"pgm");
100 std::string ext(
"png");
103Tracking of a nurbs using vpMe.\n\
106 %s [-i <input image path>] [-c] [-d] [-h]\n",
111 -i <input image path> %s\n\
112 Set image input path.\n\
113 From this path read images \n\
114 \"ellipse-1/image.%%04d.%s\"\n\
115 Setting the VISP_INPUT_IMAGE_PATH environment\n\
116 variable produces the same behaviour than using\n\
120 Disable the mouse click. Useful to automate the \n\
121 execution of this program without human intervention.\n\
124 Turn off the display.\n\
128 ipath.c_str(), ext.c_str());
131 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
146bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display)
154 click_allowed =
false;
163 usage(argv[0],
nullptr, ipath);
167 usage(argv[0], optarg_, ipath);
172 if ((c == 1) || (c == -1)) {
174 usage(argv[0],
nullptr, ipath);
175 std::cerr <<
"ERROR: " << std::endl;
176 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
183int main(
int argc,
const char **argv)
186 std::string env_ipath;
187 std::string opt_ipath;
190 bool opt_click_allowed =
true;
191 bool opt_display =
true;
193#if defined(VISP_HAVE_DATASET)
194#if VISP_HAVE_DATASET_VERSION >= 0x030600
195 std::string ext(
"png");
197 std::string ext(
"pgm");
201 std::string ext(
"png");
209 if (!env_ipath.empty())
213 if (getOptions(argc, argv, opt_ipath, opt_click_allowed, opt_display) ==
false) {
218 if (!opt_ipath.empty())
223 if (!opt_ipath.empty() && !env_ipath.empty()) {
224 if (ipath != env_ipath) {
225 std::cout << std::endl <<
"WARNING: " << std::endl;
226 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
227 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
228 <<
" we skip the environment variable." << std::endl;
233 if (opt_ipath.empty() && env_ipath.empty()) {
234 usage(argv[0],
nullptr, ipath);
235 std::cerr << std::endl <<
"ERROR:" << std::endl;
236 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
237 <<
" environment variable to specify the location of the " << std::endl
238 <<
" image path where test images are located." << std::endl
259#if defined(VISP_HAVE_X11)
261#elif defined(VISP_HAVE_GTK)
263#elif defined(VISP_HAVE_GDI)
265#elif defined(HAVE_OPENCV_HIGHGUI)
271 display.init(I, 100, 100,
"Display...");
294 if (opt_click_allowed) {
295 std::cout <<
"Click on points along the edge with the left button." << std::endl;
296 std::cout <<
"Then click on the right button to continue." << std::endl;
301 std::list<vpImagePoint> list;
315 if (opt_display && opt_click_allowed) {
316 std::cout <<
"A click to continue..." << std::endl;
319 std::cout <<
"------------------------------------------------------------" << std::endl;
321 for (
int iter = 1;
iter < 40;
iter++) {
338 if (opt_display && opt_click_allowed) {
339 std::cout <<
"A click to exit..." << std::endl;
345 std::cout <<
"Catch an exception: " <<
e.getMessage() << std::endl;
354 std::cout <<
"visp_me module or X11, GTK, GDI or OpenCV display "
355 "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.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition of the vpImage class member functions.
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) VP_OVERRIDE
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)