41 #include <visp3/core/vpDebug.h>
42 #include <visp3/core/vpConfig.h>
47 #if (defined (VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI))
49 #include <visp3/core/vpCameraParameters.h>
50 #include <visp3/gui/vpDisplayX.h>
51 #include <visp3/gui/vpDisplayGTK.h>
52 #include <visp3/gui/vpDisplayGDI.h>
53 #include <visp3/core/vpIoTools.h>
54 #include <visp3/core/vpImage.h>
55 #include <visp3/io/vpImageIo.h>
56 #include <visp3/io/vpParseArgv.h>
57 #include <visp3/blob/vpDot2.h>
58 #ifdef VISP_HAVE_MODULE_FEATURES
59 # include <visp3/visual_features/vpFeatureEllipse.h>
60 # include <visp3/visual_features/vpFeatureBuilder.h>
70 #define GETOPTARGS "cdi:h"
72 bool getOptions(
int argc,
const char **argv, std::string &ipath,
73 bool &click_allowed,
bool &display);
75 void usage(
const char *name,
const char *badparam, std::string ipath);
85 void usage(
const char *name,
const char *badparam, std::string ipath)
91 %s [-i <input image path>] [-c] [-d] [-h]\n", name);
95 -i <input image path> %s\n\
96 Set image input path.\n\
97 From this path read image \n\
98 \"ViSP-images/ellipse/ellipse.pgm\"\n\
99 Setting the VISP_INPUT_IMAGE_PATH environment\n\
100 variable produces the same behaviour than using\n\
104 Disable the mouse click. Useful to automaze the \n\
105 execution of this program without humain intervention.\n\
108 Turn off the display.\n\
115 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
130 bool getOptions(
int argc,
const char **argv, std::string &ipath,
131 bool &click_allowed,
bool &display)
138 case 'c': click_allowed =
false;
break;
139 case 'd': display =
false;
break;
140 case 'i': ipath = optarg_;
break;
141 case 'h': usage(argv[0], NULL, ipath);
return false;
break;
144 usage(argv[0], optarg_, ipath);
149 if ((c == 1) || (c == -1)) {
151 usage(argv[0], NULL, ipath);
152 std::cerr <<
"ERROR: " << std::endl;
153 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
162 main(
int argc,
const char ** argv)
165 std::string env_ipath;
166 std::string opt_ipath;
169 std::string filename;
170 bool opt_click_allowed =
true;
171 bool opt_display =
true;
177 if (! env_ipath.empty())
182 if (getOptions(argc, argv, opt_ipath,
183 opt_click_allowed, opt_display) ==
false) {
188 if (!opt_ipath.empty())
193 if (!opt_ipath.empty() && !env_ipath.empty()) {
194 if (ipath != env_ipath) {
195 std::cout << std::endl
196 <<
"WARNING: " << std::endl;
197 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
198 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
199 <<
" we skip the environment variable." << std::endl;
204 if (opt_ipath.empty() && env_ipath.empty()){
205 usage(argv[0], NULL, ipath);
206 std::cerr << std::endl
207 <<
"ERROR:" << std::endl;
208 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH "
210 <<
" environment variable to specify the location of the " << std::endl
211 <<
" image path where test images are located." << std::endl << std::endl;
234 vpCTRACE <<
"Load: " << filename << std::endl;
244 std::cerr << std::endl
245 <<
"ERROR:" << std::endl;
246 std::cerr <<
" Cannot read " << filename << std::endl;
247 std::cerr <<
" Check your -i " << ipath <<
" option " << std::endl
248 <<
" or VISP_INPUT_IMAGE_PATH environment variable."
254 #if defined VISP_HAVE_X11
256 #elif defined VISP_HAVE_GTK
258 #elif defined VISP_HAVE_GDI
264 display.
init(I, 100, 100,
"Display...") ;
276 std::cout <<
"debut 1\n";
293 #ifdef VISP_HAVE_MODULE_FEATURES
298 #ifdef VISP_HAVE_MODULE_FEATURES
302 if (opt_click_allowed) {
303 std::cout <<
"A click to exit..." << std::endl;
310 std::cout <<
"Catch an exception: " << e.
getMessage() << std::endl;
318 vpERROR_TRACE(
"You do not have X11, GTK or GDI display functionalities...");
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
Display for windows using GDI (available on any windows 32 platform).
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
error that can be emited by ViSP classes.
This tracker is meant to track a blob (connex pixels with same gray level) on a vpImage.
void track(const vpImage< unsigned char > &I)
static void flush(const vpImage< unsigned char > &I)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
void set_i(const double ii)
static void display(const vpImage< unsigned char > &I)
Generic class defining intrinsic camera parameters.
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
const char * getMessage(void) const
void setComputeMoments(const bool activate)
void set_j(const double jj)
void display(const vpCameraParameters &cam, const vpImage< unsigned char > &I, const vpColor &color=vpColor::green, unsigned int thickness=1) const
static void read(vpImage< unsigned char > &I, const std::string &filename)
void initTracking(const vpImage< unsigned char > &I, unsigned int size=0)
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Class that defines 2D ellipse visual feature.
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
void setGraphics(const bool activate)