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
69bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display);
71void usage(
const char *name,
const char *badparam, std::string ipath);
81void usage(
const char *name,
const char *badparam, std::string ipath)
83#if defined(VISP_HAVE_DATASET)
84#if VISP_HAVE_DATASET_VERSION >= 0x030600
85 std::string ext(
"png");
87 std::string ext(
"pgm");
91 std::string ext(
"png");
97 %s [-i <input image path>] [-c] [-d] [-h]\n",
102 -i <input image path> %s\n\
103 Set image input path.\n\
104 From this path read image \n\
105 \"ellipse/ellipse.%s\"\n\
106 Setting the VISP_INPUT_IMAGE_PATH environment\n\
107 variable produces the same behaviour than using\n\
111 Disable the mouse click. Useful to automate the \n\
112 execution of this program without human intervention.\n\
115 Turn off the display.\n\
119 ipath.c_str(), ext.c_str());
122 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
136bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &click_allowed,
bool &display)
144 click_allowed =
false;
153 usage(argv[0],
nullptr, ipath);
157 usage(argv[0], optarg_, ipath);
162 if ((c == 1) || (c == -1)) {
164 usage(argv[0],
nullptr, ipath);
165 std::cerr <<
"ERROR: " << std::endl;
166 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
173int main(
int argc,
const char **argv)
176 std::string env_ipath;
177 std::string opt_ipath;
181 bool opt_click_allowed =
true;
182 bool opt_display =
true;
184#if defined(VISP_HAVE_DATASET)
185#if VISP_HAVE_DATASET_VERSION >= 0x030600
186 std::string ext(
"png");
188 std::string ext(
"pgm");
192 std::string ext(
"png");
200 if (!env_ipath.empty())
204 if (getOptions(argc, argv, opt_ipath, opt_click_allowed, opt_display) ==
false) {
209 if (!opt_ipath.empty())
214 if (!opt_ipath.empty() && !env_ipath.empty()) {
215 if (ipath != env_ipath) {
216 std::cout << std::endl <<
"WARNING: " << std::endl;
217 std::cout <<
" Since -i <visp image path=" << ipath <<
"> "
218 <<
" is different from VISP_IMAGE_PATH=" << env_ipath << std::endl
219 <<
" we skip the environment variable." << std::endl;
224 if (opt_ipath.empty() && env_ipath.empty()) {
225 usage(argv[0],
nullptr, ipath);
226 std::cerr << std::endl <<
"ERROR:" << std::endl;
227 std::cerr <<
" Use -i <visp image path> option or set VISP_INPUT_IMAGE_PATH " << std::endl
228 <<
" environment variable to specify the location of the " << std::endl
229 <<
" image path where test images are located." << std::endl
252 std::cerr << std::endl <<
"ERROR:" << std::endl;
253 std::cerr <<
" Cannot read " <<
filename << std::endl;
254 std::cerr <<
" Check your -i " << ipath <<
" option " << std::endl
255 <<
" or VISP_INPUT_IMAGE_PATH environment variable." << std::endl;
260#if defined(VISP_HAVE_X11)
262#elif defined(VISP_HAVE_GTK)
264#elif defined(VISP_HAVE_GDI)
270 display.init(I, 100, 100,
"Display...");
282 std::cout <<
"debut 1\n";
299#ifdef VISP_HAVE_MODULE_FEATURES
304#ifdef VISP_HAVE_MODULE_FEATURES
308 if (opt_click_allowed) {
309 std::cout <<
"A click to exit..." << std::endl;
316 std::cout <<
"Catch an exception: " <<
e.getMessage() << std::endl;
321int 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.
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
Class that defines 2D ellipse visual feature.
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.
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)