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
65void usage(
const char *name,
const char *badparam, std::string ipath);
66bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display);
77void usage(
const char *name,
const char *badparam, std::string ipath)
79#if defined(VISP_HAVE_DATASET)
80#if VISP_HAVE_DATASET_VERSION >= 0x030600
81 std::string ext(
"png");
83 std::string ext(
"pgm");
87 std::string ext(
"png");
90Test auto detection of dots using vpDot2.\n\
93 %s [-i <input image path>] [-c] [-d] [-h]\n",
98 -i <input image path> %s\n\
99 Set image input path.\n\
100 From this path read \"circle/circle.%s\"\n\
102 Setting the VISP_INPUT_IMAGE_PATH environment\n\
103 variable produces the same behaviour than using\n\
107 Disable the mouse click. Useful to automate the \n\
108 execution of this program without human intervention.\n\
111 Turn off the display.\n\
115 ipath.c_str(), ext.c_str());
118 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
133bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display)
141 click_allowed =
false;
150 usage(argv[0],
nullptr, ipath);
154 usage(argv[0], optarg_, ipath);
159 if ((c == 1) || (c == -1)) {
161 usage(argv[0],
nullptr, ipath);
162 std::cerr <<
"ERROR: " << std::endl;
163 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
170int main(
int argc,
const char **argv)
172#if defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV)
174 std::string env_ipath;
175 std::string opt_ipath;
179 bool opt_click_allowed =
true;
180 bool opt_display =
true;
182#if defined(VISP_HAVE_DATASET)
183#if VISP_HAVE_DATASET_VERSION >= 0x030600
184 std::string ext(
"png");
186 std::string ext(
"pgm");
190 std::string ext(
"png");
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
248 std::cout <<
"Load: " <<
filename << std::endl;
256 std::cerr << std::endl <<
"ERROR:" << std::endl;
257 std::cerr <<
" Cannot read " <<
filename << std::endl;
258 std::cerr <<
" Check your -i " << ipath <<
" option " << std::endl
259 <<
" or VISP_INPUT_IMAGE_PATH environment variable." << std::endl;
267 display->init(I, 100, 100,
"Display...");
289 if (opt_display && opt_click_allowed) {
294 std::vector<vpImagePoint> ip;
310 std::cout <<
"Tracking on image: " <<
filename << std::endl;
316 if (opt_display && opt_click_allowed) {
317 std::cout <<
"A click to exit..." << std::endl;
327 std::cout <<
"Catch an exception: " <<
e << std::endl;
333 std::cout <<
"Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
341 std::cout <<
"visp_me module or X11, GTK, GDI or OpenCV display "
342 "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 ...
Definition of the vpImage class member functions.
Class that tracks an ellipse or a circle 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.