46 #include <visp3/core/vpConfig.h>
48 #if defined(VISP_HAVE_MODULE_ME) && defined(VISP_HAVE_DISPLAY)
50 #include <visp3/core/vpColor.h>
51 #include <visp3/core/vpImage.h>
52 #include <visp3/core/vpIoTools.h>
53 #include <visp3/gui/vpDisplayFactory.h>
54 #include <visp3/io/vpImageIo.h>
55 #include <visp3/io/vpParseArgv.h>
56 #include <visp3/me/vpMeEllipse.h>
59 #define GETOPTARGS "cdi:h"
61 #ifdef ENABLE_VISP_NAMESPACE
65 void usage(
const char *name,
const char *badparam, std::string ipath);
66 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display);
77 void usage(
const char *name,
const char *badparam, std::string ipath)
79 #if VISP_HAVE_DATASET_VERSION >= 0x030600
80 std::string ext(
"png");
82 std::string ext(
"pgm");
85 Test auto detection of dots using vpDot2.\n\
88 %s [-i <input image path>] [-c] [-d] [-h]\n",
93 -i <input image path> %s\n\
94 Set image input path.\n\
95 From this path read \"circle/circle.%s\"\n\
97 Setting the VISP_INPUT_IMAGE_PATH environment\n\
98 variable produces the same behaviour than using\n\
102 Disable the mouse click. Useful to automate the \n\
103 execution of this program without human intervention.\n\
106 Turn off the display.\n\
110 ipath.c_str(), ext.c_str());
113 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
128 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display)
136 click_allowed =
false;
145 usage(argv[0],
nullptr, ipath);
150 usage(argv[0], optarg_, ipath);
156 if ((c == 1) || (c == -1)) {
158 usage(argv[0],
nullptr, ipath);
159 std::cerr <<
"ERROR: " << std::endl;
160 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
167 int main(
int argc,
const char **argv)
169 #if defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV)
171 std::string env_ipath;
172 std::string opt_ipath;
175 std::string filename;
176 bool opt_click_allowed =
true;
177 bool opt_display =
true;
179 #if VISP_HAVE_DATASET_VERSION >= 0x030600
180 std::string ext(
"png");
182 std::string ext(
"pgm");
190 if (!env_ipath.empty())
194 if (getOptions(argc, argv, opt_ipath, opt_click_allowed, opt_display) ==
false) {
199 if (!opt_ipath.empty())
204 if (!opt_ipath.empty() && !env_ipath.empty()) {
205 if (ipath != env_ipath) {
206 std::cout << std::endl <<
"WARNING: " << std::endl;
207 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
208 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
209 <<
" we skip the environment variable." << std::endl;
214 if (opt_ipath.empty() && env_ipath.empty()) {
215 usage(argv[0],
nullptr, ipath);
216 std::cerr << std::endl <<
"ERROR:" << std::endl;
217 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
218 <<
" environment variable to specify the location of the " << std::endl
219 <<
" image path where test images are located." << std::endl
240 std::cout <<
"Load: " << filename << std::endl;
248 std::cerr << std::endl <<
"ERROR:" << std::endl;
249 std::cerr <<
" Cannot read " << filename << std::endl;
250 std::cerr <<
" Check your -i " << ipath <<
" option " << std::endl
251 <<
" or VISP_INPUT_IMAGE_PATH environment variable." << std::endl;
259 display->init(I, 100, 100,
"Display...");
281 if (opt_display && opt_click_allowed) {
286 std::vector<vpImagePoint> ip;
302 std::cout <<
"Tracking on image: " << filename << std::endl;
308 if (opt_display && opt_click_allowed) {
309 std::cout <<
"A click to exit..." << std::endl;
319 std::cout <<
"Catch an exception: " << e << std::endl;
325 std::cout <<
"Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
333 std::cout <<
"visp_me module or X11, GTK, GDI or OpenCV display "
334 "functionalities are required..."
static const vpColor green
Class that defines generic functionalities for display.
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)
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.