48 #include <visp3/core/vpConfig.h>
55 #if defined(VISP_HAVE_MODULE_ME) && \
56 (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
58 #include <visp3/core/vpColor.h>
59 #include <visp3/core/vpImage.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/me/vpMeEllipse.h>
71 #define GETOPTARGS "cdi:h"
73 void usage(
const char *name,
const char *badparam, std::string ipath);
74 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display);
85 void usage(
const char *name,
const char *badparam, std::string ipath)
87 #if VISP_HAVE_DATASET_VERSION >= 0x030600
88 std::string ext(
"png");
90 std::string ext(
"pgm");
93 Test auto detection of dots using vpDot2.\n\
96 %s [-i <input image path>] [-c] [-d] [-h]\n",
101 -i <input image path> %s\n\
102 Set image input path.\n\
103 From this path read \"circle/circle.%s\"\n\
105 Setting the VISP_INPUT_IMAGE_PATH environment\n\
106 variable produces the same behaviour than using\n\
110 Disable the mouse click. Useful to automate the \n\
111 execution of this program without human intervention.\n\
114 Turn off the display.\n\
118 ipath.c_str(), ext.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],
nullptr, ipath);
158 usage(argv[0], optarg_, ipath);
164 if ((c == 1) || (c == -1)) {
166 usage(argv[0],
nullptr, 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)
177 #if defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV)
179 std::string env_ipath;
180 std::string opt_ipath;
183 std::string filename;
184 bool opt_click_allowed =
true;
185 bool opt_display =
true;
187 #if VISP_HAVE_DATASET_VERSION >= 0x030600
188 std::string ext(
"png");
190 std::string ext(
"pgm");
198 if (!env_ipath.empty())
202 if (getOptions(argc, argv, opt_ipath, opt_click_allowed, opt_display) ==
false) {
207 if (!opt_ipath.empty())
212 if (!opt_ipath.empty() && !env_ipath.empty()) {
213 if (ipath != env_ipath) {
214 std::cout << std::endl <<
"WARNING: " << std::endl;
215 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
216 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
217 <<
" we skip the environment variable." << std::endl;
222 if (opt_ipath.empty() && env_ipath.empty()) {
223 usage(argv[0],
nullptr, ipath);
224 std::cerr << std::endl <<
"ERROR:" << std::endl;
225 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
226 <<
" environment variable to specify the location of the " << std::endl
227 <<
" image path where test images are located." << std::endl
247 vpCTRACE <<
"Load: " << filename << std::endl;
255 std::cerr << std::endl <<
"ERROR:" << std::endl;
256 std::cerr <<
" Cannot read " << filename << std::endl;
257 std::cerr <<
" Check your -i " << ipath <<
" option " << std::endl
258 <<
" or VISP_INPUT_IMAGE_PATH environment variable." << std::endl;
263 #if defined(VISP_HAVE_X11)
265 #elif defined(VISP_HAVE_GTK)
267 #elif defined(VISP_HAVE_GDI)
269 #elif defined(HAVE_OPENCV_HIGHGUI)
275 display.init(I, 100, 100,
"Display...");
297 if (opt_display && opt_click_allowed) {
302 std::vector<vpImagePoint> ip;
318 std::cout <<
"Tracking on image: " << filename << std::endl;
324 if (opt_display && opt_click_allowed) {
325 std::cout <<
"A click to exit..." << std::endl;
328 std::cout <<
"------------------------------------------------------------" << std::endl;
332 std::cout <<
"Catch an exception: " << e << std::endl;
338 std::cout <<
"Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
346 std::cout <<
"visp_me module or X11, GTK, GDI or OpenCV display "
347 "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.
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Class that tracks an ellipse using moving edges.
void display(const vpImage< unsigned char > &I, const vpColor &col, unsigned int thickness=1)
void initTracking(const vpImage< unsigned char > &I, bool trackCircle=false, bool trackArc=false)
void track(const vpImage< unsigned char > &I)
void setDisplay(vpMeSite::vpMeSiteDisplayType select)
void setRange(const unsigned int &range)
void setLikelihoodThresholdType(const vpLikelihoodThresholdType likelihood_threshold_type)
void setThreshold(const double &threshold)
void setSampleStep(const double &sample_step)
double getSampleStep() const
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
void display(vpImage< unsigned char > &I, const std::string &title)
Display a gray-scale image.