40 #include <visp3/core/vpConfig.h>
41 #include <visp3/core/vpDebug.h>
42 #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI))
44 #include <visp3/blob/vpDot2.h>
45 #include <visp3/core/vpCameraParameters.h>
46 #include <visp3/core/vpImage.h>
47 #include <visp3/core/vpIoTools.h>
48 #include <visp3/gui/vpDisplayGDI.h>
49 #include <visp3/gui/vpDisplayGTK.h>
50 #include <visp3/gui/vpDisplayX.h>
51 #include <visp3/io/vpImageIo.h>
52 #include <visp3/io/vpParseArgv.h>
53 #ifdef VISP_HAVE_MODULE_FEATURES
54 #include <visp3/visual_features/vpFeatureBuilder.h>
55 #include <visp3/visual_features/vpFeatureEllipse.h>
65 #define GETOPTARGS "cdi:h"
67 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display);
69 void usage(
const char *name,
const char *badparam, std::string ipath);
79 void usage(
const char *name,
const char *badparam, std::string ipath)
81 #if VISP_HAVE_DATASET_VERSION >= 0x030600
82 std::string ext(
"png");
84 std::string ext(
"pgm");
90 %s [-i <input image path>] [-c] [-d] [-h]\n",
95 -i <input image path> %s\n\
96 Set image input path.\n\
97 From this path read image \n\
98 \"ellipse/ellipse.%s\"\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 automate the \n\
105 execution of this program without human intervention.\n\
108 Turn off the display.\n\
112 ipath.c_str(), ext.c_str());
115 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
129 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display)
137 click_allowed =
false;
146 usage(argv[0],
nullptr, ipath);
151 usage(argv[0], optarg_, ipath);
157 if ((c == 1) || (c == -1)) {
159 usage(argv[0],
nullptr, ipath);
160 std::cerr <<
"ERROR: " << std::endl;
161 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
168 int main(
int argc,
const char **argv)
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
237 vpCTRACE <<
"Load: " << filename << std::endl;
241 std::cerr << std::endl <<
"ERROR:" << std::endl;
242 std::cerr <<
" Cannot read " << filename << std::endl;
243 std::cerr <<
" Check your -i " << ipath <<
" option " << std::endl
244 <<
" or VISP_INPUT_IMAGE_PATH environment variable." << std::endl;
249 #if defined(VISP_HAVE_X11)
251 #elif defined(VISP_HAVE_GTK)
253 #elif defined(VISP_HAVE_GDI)
259 display.init(I, 100, 100,
"Display...");
271 std::cout <<
"debut 1\n";
287 #ifdef VISP_HAVE_MODULE_FEATURES
292 #ifdef VISP_HAVE_MODULE_FEATURES
296 if (opt_click_allowed) {
297 std::cout <<
"A click to exit..." << std::endl;
303 std::cout <<
"Catch an exception: " << e.
getMessage() << std::endl;
308 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...
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
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 vpDot &d)
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)
void display(vpImage< unsigned char > &I, const std::string &title)
Display a gray-scale image.