42#include <visp3/core/vpImage.h>
43#include <visp3/core/vpImageConvert.h>
44#include <visp3/core/vpPolygon.h>
45#include <visp3/core/vpRect.h>
46#include <visp3/gui/vpDisplayFactory.h>
47#include <visp3/io/vpParseArgv.h>
50#define GETOPTARGS "cdh"
52#ifdef ENABLE_VISP_NAMESPACE
56void usage(
const char *name,
const char *badparam);
57bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display);
66void usage(
const char *name,
const char *badparam)
69Display polygon lines.\n\
78 Disable the mouse click. Useful to automate the \n\
79 execution of this program without human intervention.\n\
82 Disable the image display. This can be useful \n\
83 for automatic tests. \n\
86 Print the help.\n\n");
89 fprintf(stderr,
"ERROR: \n");
90 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
108bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display)
116 click_allowed =
false;
122 usage(argv[0],
nullptr);
126 usage(argv[0], optarg_);
131 if ((c == 1) || (c == -1)) {
133 usage(argv[0],
nullptr);
134 std::cerr <<
"ERROR: " << std::endl;
135 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
142int main(
int argc,
const char **argv)
144#ifdef VISP_HAVE_DISPLAY
145 bool opt_click_allowed =
true;
146 bool opt_display =
true;
149 if (getOptions(argc, argv, opt_click_allowed, opt_display) ==
false) {
153 if (opt_display && opt_click_allowed) {
157#if(VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
164 d->init(I, 0, 0,
"Grayscale image");
185 d2->init(I_color, I.getWidth(), 0,
"Color image");
187 for (
unsigned int i = 0;
i < I_color.getHeight();
i++) {
188 double hue =
i /
static_cast<double>(I_color.getHeight()), saturation = 1.0, value = 1.0;
189 unsigned char rgb[3];
192 for (
unsigned int j = 0;
j < I_color.getWidth();
j++) {
193 I_color[
i][
j].R = rgb[0];
194 I_color[
i][
j].G = rgb[1];
195 I_color[
i][
j].B = rgb[2];
217#if(VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
static const vpColor black
Class that defines generic functionalities for display.
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
static void flush(const vpImage< unsigned char > &I)
static void displayDotLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
static void HSVToRGB(const double *hue, const double *saturation, const double *value, unsigned char *rgb, unsigned int size)
Definition of the vpImage class member functions.
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
Defines a generic 2D polygon.
const std::vector< vpImagePoint > & getCorners() const
void initClick(const vpImage< unsigned char > &I, unsigned int size=5, const vpColor &color=vpColor::red, unsigned int thickness=1)
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.