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/vpIoTools.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>
65 #include <visp3/io/vpParseArgv.h>
66 #include <visp3/me/vpMeEllipse.h>
69 #define GETOPTARGS "cdi:h"
71 #ifdef ENABLE_VISP_NAMESPACE
75 void usage(
const char *name,
const char *badparam, std::string ipath);
76 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display);
87 void usage(
const char *name,
const char *badparam, std::string ipath)
89 #if VISP_HAVE_DATASET_VERSION >= 0x030600
90 std::string ext(
"png");
92 std::string ext(
"pgm");
95 Test auto detection of dots using vpDot2.\n\
98 %s [-i <input image path>] [-c] [-d] [-h]\n",
103 -i <input image path> %s\n\
104 Set image input path.\n\
105 From this path read \"circle/circle.%s\"\n\
107 Setting the VISP_INPUT_IMAGE_PATH environment\n\
108 variable produces the same behaviour than using\n\
112 Disable the mouse click. Useful to automate the \n\
113 execution of this program without human intervention.\n\
116 Turn off the display.\n\
120 ipath.c_str(), ext.c_str());
123 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
138 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display)
146 click_allowed =
false;
155 usage(argv[0],
nullptr, ipath);
160 usage(argv[0], optarg_, ipath);
166 if ((c == 1) || (c == -1)) {
168 usage(argv[0],
nullptr, ipath);
169 std::cerr <<
"ERROR: " << std::endl;
170 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
177 int main(
int argc,
const char **argv)
179 #if defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV)
181 std::string env_ipath;
182 std::string opt_ipath;
185 std::string filename;
186 bool opt_click_allowed =
true;
187 bool opt_display =
true;
189 #if VISP_HAVE_DATASET_VERSION >= 0x030600
190 std::string ext(
"png");
192 std::string ext(
"pgm");
200 if (!env_ipath.empty())
204 if (getOptions(argc, argv, opt_ipath, opt_click_allowed, opt_display) ==
false) {
209 if (!opt_ipath.empty())
214 if (!opt_ipath.empty() && !env_ipath.empty()) {
215 if (ipath != env_ipath) {
216 std::cout << std::endl <<
"WARNING: " << std::endl;
217 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
218 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
219 <<
" we skip the environment variable." << std::endl;
224 if (opt_ipath.empty() && env_ipath.empty()) {
225 usage(argv[0],
nullptr, ipath);
226 std::cerr << std::endl <<
"ERROR:" << std::endl;
227 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
228 <<
" environment variable to specify the location of the " << std::endl
229 <<
" image path where test images are located." << std::endl
249 vpCTRACE <<
"Load: " << filename << std::endl;
257 std::cerr << std::endl <<
"ERROR:" << std::endl;
258 std::cerr <<
" Cannot read " << filename << std::endl;
259 std::cerr <<
" Check your -i " << ipath <<
" option " << std::endl
260 <<
" or VISP_INPUT_IMAGE_PATH environment variable." << std::endl;
265 #if defined(VISP_HAVE_X11)
267 #elif defined(VISP_HAVE_GTK)
269 #elif defined(VISP_HAVE_GDI)
271 #elif defined(HAVE_OPENCV_HIGHGUI)
277 display.init(I, 100, 100,
"Display...");
299 if (opt_display && opt_click_allowed) {
304 std::vector<vpImagePoint> ip;
320 std::cout <<
"Tracking on image: " << filename << std::endl;
326 if (opt_display && opt_click_allowed) {
327 std::cout <<
"A click to exit..." << std::endl;
330 std::cout <<
"------------------------------------------------------------" << std::endl;
334 std::cout <<
"Catch an exception: " << e << std::endl;
340 std::cout <<
"Cannot run this example: install Lapack, Eigen3 or OpenCV" << 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.
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)