45 #include <visp/vpDebug.h>
46 #include <visp/vpConfig.h>
51 #if (defined (VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI))
53 #include <visp/vpImage.h>
54 #include <visp/vpImageIo.h>
55 #include <visp/vpDisplayX.h>
56 #include <visp/vpDisplayGTK.h>
57 #include <visp/vpDisplayGDI.h>
58 #include <visp/vpDot.h>
59 #include <visp/vpFeatureEllipse.h>
60 #include <visp/vpCameraParameters.h>
61 #include <visp/vpFeatureBuilder.h>
62 #include <visp/vpParseArgv.h>
63 #include <visp/vpIoTools.h>
72 #define GETOPTARGS "cdi:h"
83 void usage(
const char *name,
const char *badparam, std::string ipath)
89 %s [-i <input image path>] [-c] [-d] [-h]\n", name);
93 -i <input image path> %s\n\
94 Set image input path.\n\
95 From this path read image \n\
96 \"ViSP-images/ellipse/ellipse.pgm\"\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 automaze the \n\
103 execution of this program without humain intervention.\n\
106 Turn off the display.\n\
113 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
128 bool getOptions(
int argc,
const char **argv, std::string &ipath,
129 bool &click_allowed,
bool &display)
136 case 'c': click_allowed =
false;
break;
137 case 'd': display =
false;
break;
138 case 'i': ipath = optarg;
break;
139 case 'h': usage(argv[0], NULL, ipath);
return false;
break;
142 usage(argv[0], optarg, ipath);
147 if ((c == 1) || (c == -1)) {
149 usage(argv[0], NULL, ipath);
150 std::cerr <<
"ERROR: " << std::endl;
151 std::cerr <<
" Bad argument " << optarg << std::endl << std::endl;
160 main(
int argc,
const char ** argv)
162 std::string env_ipath;
163 std::string opt_ipath;
166 std::string filename;
167 bool opt_click_allowed =
true;
168 bool opt_display =
true;
171 char *ptenv = getenv(
"VISP_INPUT_IMAGE_PATH");
176 if (! env_ipath.empty())
181 if (getOptions(argc, argv, opt_ipath,
182 opt_click_allowed, opt_display) ==
false) {
187 if (!opt_ipath.empty())
192 if (!opt_ipath.empty() && !env_ipath.empty()) {
193 if (ipath != env_ipath) {
194 std::cout << std::endl
195 <<
"WARNING: " << std::endl;
196 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
197 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
198 <<
" we skip the environment variable." << std::endl;
203 if (opt_ipath.empty() && env_ipath.empty()){
204 usage(argv[0], NULL, ipath);
205 std::cerr << std::endl
206 <<
"ERROR:" << std::endl;
207 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH "
209 <<
" environment variable to specify the location of the " << std::endl
210 <<
" image path where test images are located." << std::endl << std::endl;
224 filename = dirname +
"ellipse.pgm";
233 vpCTRACE <<
"Load: " << filename << std::endl;
243 std::cerr << std::endl
244 <<
"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."
253 #if defined VISP_HAVE_X11
255 #elif defined VISP_HAVE_GTK
257 #elif defined VISP_HAVE_GDI
264 display.
init(I, 100, 100,
"Display...") ;
302 if (opt_click_allowed) {
303 std::cout <<
"A click to exit..." << std::endl;
312 vpERROR_TRACE(
"You do not have X11, GTK or GDI display functionalities...");
void set_j(const double j)
void setMaxDotSize(double percentage)
Display for windows using GDI (available on any windows 32 platform).
Define the X11 console to display images.
void set_i(const double i)
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)
static void display(const vpImage< unsigned char > &I)
Generic class defining intrinsic camera parameters.
The vpDisplayGTK allows to display image using the GTK+ library version 1.2.
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
void display(const vpCameraParameters &cam, const vpImage< unsigned char > &I, const vpColor &color=vpColor::green, unsigned int thickness=1) const
void setGraphics(const bool activate)
This tracker is meant to track a dot (connected pixels with same gray level) on a vpImage...
void setComputeMoments(const bool activate)
virtual bool getClick(bool blocking=true)=0
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)
static void read(vpImage< unsigned char > &I, const char *filename)
void initTracking(const vpImage< unsigned char > &I)