38 #include <visp3/core/vpConfig.h>
39 #include <visp3/core/vpDebug.h>
40 #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI))
42 #include <visp3/blob/vpDot2.h>
43 #include <visp3/core/vpCameraParameters.h>
44 #include <visp3/core/vpImage.h>
45 #include <visp3/core/vpIoTools.h>
46 #include <visp3/gui/vpDisplayGDI.h>
47 #include <visp3/gui/vpDisplayGTK.h>
48 #include <visp3/gui/vpDisplayX.h>
49 #include <visp3/io/vpImageIo.h>
50 #include <visp3/io/vpParseArgv.h>
51 #ifdef VISP_HAVE_MODULE_FEATURES
52 #include <visp3/visual_features/vpFeatureBuilder.h>
53 #include <visp3/visual_features/vpFeatureEllipse.h>
63 #define GETOPTARGS "cdi:h"
65 #ifdef ENABLE_VISP_NAMESPACE
69 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display);
71 void usage(
const char *name,
const char *badparam, std::string ipath);
81 void usage(
const char *name,
const char *badparam, std::string ipath)
83 #if VISP_HAVE_DATASET_VERSION >= 0x030600
84 std::string ext(
"png");
86 std::string ext(
"pgm");
92 %s [-i <input image path>] [-c] [-d] [-h]\n",
97 -i <input image path> %s\n\
98 Set image input path.\n\
99 From this path read image \n\
100 \"ellipse/ellipse.%s\"\n\
101 Setting the VISP_INPUT_IMAGE_PATH environment\n\
102 variable produces the same behaviour than using\n\
106 Disable the mouse click. Useful to automate the \n\
107 execution of this program without human intervention.\n\
110 Turn off the display.\n\
114 ipath.c_str(), ext.c_str());
117 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
131 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display)
139 click_allowed =
false;
148 usage(argv[0],
nullptr, ipath);
153 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;
170 int main(
int argc,
const char **argv)
173 std::string env_ipath;
174 std::string opt_ipath;
177 std::string filename;
178 bool opt_click_allowed =
true;
179 bool opt_display =
true;
181 #if VISP_HAVE_DATASET_VERSION >= 0x030600
182 std::string ext(
"png");
184 std::string ext(
"pgm");
192 if (!env_ipath.empty())
196 if (getOptions(argc, argv, opt_ipath, opt_click_allowed, opt_display) ==
false) {
201 if (!opt_ipath.empty())
206 if (!opt_ipath.empty() && !env_ipath.empty()) {
207 if (ipath != env_ipath) {
208 std::cout << std::endl <<
"WARNING: " << std::endl;
209 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
210 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
211 <<
" we skip the environment variable." << std::endl;
216 if (opt_ipath.empty() && env_ipath.empty()) {
217 usage(argv[0],
nullptr, ipath);
218 std::cerr << std::endl <<
"ERROR:" << std::endl;
219 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
220 <<
" environment variable to specify the location of the " << std::endl
221 <<
" image path where test images are located." << std::endl
239 vpCTRACE <<
"Load: " << filename << std::endl;
244 std::cerr << std::endl <<
"ERROR:" << std::endl;
245 std::cerr <<
" Cannot read " << filename << std::endl;
246 std::cerr <<
" Check your -i " << ipath <<
" option " << std::endl
247 <<
" or VISP_INPUT_IMAGE_PATH environment variable." << std::endl;
252 #if defined(VISP_HAVE_X11)
254 #elif defined(VISP_HAVE_GTK)
256 #elif defined(VISP_HAVE_GDI)
262 display.init(I, 100, 100,
"Display...");
274 std::cout <<
"debut 1\n";
291 #ifdef VISP_HAVE_MODULE_FEATURES
296 #ifdef VISP_HAVE_MODULE_FEATURES
300 if (opt_click_allowed) {
301 std::cout <<
"A click to exit..." << std::endl;
308 std::cout <<
"Catch an exception: " << e.
getMessage() << std::endl;
313 int main() { vpERROR_TRACE(
"You do not have X11, GTK or GDI display functionalities..."); }
Generic class defining intrinsic camera parameters.
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...
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)
This tracker is meant to track a blob (connex pixels with same gray level) on a vpImage.
void track(const vpImage< unsigned char > &I, bool canMakeTheWindowGrow=true)
void setGraphics(bool activate)
void setComputeMoments(bool activate)
void initTracking(const vpImage< unsigned char > &I, unsigned int size=0)
error that can be emitted by ViSP classes.
const char * getMessage() const
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpImagePoint &t)
Class that defines 2D ellipse visual feature.
void display(const vpCameraParameters &cam, const vpImage< unsigned char > &I, const vpColor &color=vpColor::green, unsigned int thickness=1) const VP_OVERRIDE
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 ...
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)