44 #include <visp3/core/vpImage.h> 45 #include <visp3/core/vpImageConvert.h> 46 #include <visp3/core/vpPolygon.h> 47 #include <visp3/core/vpRect.h> 48 #include <visp3/gui/vpDisplayD3D.h> 49 #include <visp3/gui/vpDisplayGDI.h> 50 #include <visp3/gui/vpDisplayGTK.h> 51 #include <visp3/gui/vpDisplayOpenCV.h> 52 #include <visp3/gui/vpDisplayX.h> 53 #include <visp3/io/vpParseArgv.h> 56 #define GETOPTARGS "cdh" 58 void usage(
const char *name,
const char *badparam);
59 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &
display);
68 void usage(
const char *name,
const char *badparam)
71 Display polygon lines.\n\ 74 %s [-c] [-d] [-h]\n", name);
79 Disable the mouse click. Useful to automate the \n\ 80 execution of this program without humain intervention.\n\ 83 Disable the image display. This can be useful \n\ 84 for automatic tests. \n\ 87 Print the help.\n\n");
90 fprintf(stderr,
"ERROR: \n");
91 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
109 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &
display)
117 click_allowed =
false;
123 usage(argv[0], NULL);
128 usage(argv[0], optarg_);
134 if ((c == 1) || (c == -1)) {
136 usage(argv[0], NULL);
137 std::cerr <<
"ERROR: " << std::endl;
138 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
145 int main(
int argc,
const char **argv)
147 #ifdef VISP_HAVE_DISPLAY 148 bool opt_click_allowed =
true;
149 bool opt_display =
true;
152 if (getOptions(argc, argv, opt_click_allowed, opt_display) ==
false) {
156 if (opt_display && opt_click_allowed) {
160 #if defined(VISP_HAVE_X11) 162 #elif defined(VISP_HAVE_GTK) 164 #elif defined(VISP_HAVE_GDI) 166 #elif defined(VISP_HAVE_D3D9) 168 #elif defined(VISP_HAVE_OPENCV) 171 d.
init(I, 0, 0,
"Grayscale image");
194 for (
unsigned int i = 0; i < I_color.getHeight(); i++) {
195 double hue = i / (double)I_color.getHeight(), saturation = 1.0, value = 1.0;
196 unsigned char rgb[3];
199 for (
unsigned int j = 0; j < I_color.getWidth(); j++) {
200 I_color[i][j].R = rgb[0];
201 I_color[i][j].G = rgb[1];
202 I_color[i][j].B = rgb[2];
const std::vector< vpImagePoint > & getCorners() const
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
unsigned int getWidth() const
static const vpColor black
Display for windows using GDI (available on any windows 32 platform).
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
static void flush(const vpImage< unsigned char > &I)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
Defines a generic 2D polygon.
Display for windows using Direct3D 3rd party. Thus to enable this class Direct3D should be installed...
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
void initClick(const vpImage< unsigned char > &I, unsigned int size=5, const vpColor &color=vpColor::red, unsigned int thickness=1)
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
static void HSVToRGB(const double *hue, const double *saturation, const double *value, unsigned char *rgb, const unsigned int size)
static void displayDotLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)