5 #include <visp3/core/vpImage.h>
6 #include <visp3/gui/vpDisplayGDI.h>
7 #include <visp3/gui/vpDisplayOpenCV.h>
8 #include <visp3/gui/vpDisplayX.h>
10 #if defined(VISP_HAVE_MODULE_IMGPROC) && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
12 #include <visp3/imgproc/vpImgproc.h>
103 return imPt_switched;
111 if (dx >= 0 && dy >= 0) {
117 }
else if (dx < 0 && dy >= 0) {
123 }
else if (dx < 0 && dy < 0) {
144 int octant = getOctant(imPt1, imPt2);
145 imPt1 = switchToOctantZeroFrom(octant, imPt1);
146 imPt2 = switchToOctantZeroFrom(octant, imPt2);
150 double D = 2 * dy - dx;
151 double y = imPt1.
get_v();
153 for (
int x = (
int)imPt1.
get_u(); x <= (
int)imPt2.
get_u(); x++) {
155 currentPt = switchFromOctantZeroTo(octant, currentPt);
157 unsigned int i = std::min(I.
getHeight() - 1, (
unsigned int)std::max(0.0, currentPt.get_i()));
158 unsigned int j = std::min(I.
getWidth() - 1, (
unsigned int)std::max(0.0, currentPt.get_j()));
177 #if defined(VISP_HAVE_MODULE_IMGPROC) && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
186 #elif defined(VISP_HAVE_GDI)
188 #elif defined(HAVE_OPENCV_HIGHGUI)
191 d.
init(I, 0, 0,
"Paint");
194 std::vector<vpPolygon> polygons;
195 for (
int i = 0; i < 3; i++) {
197 std::stringstream ss;
198 ss <<
"Left click to draw polygon " << i + 1 <<
"/3"
199 <<
", right click to close the shape.";
205 polygons.push_back(polygon);
218 for (
size_t i = 0; i < polygons.size(); i++) {
219 if (polygons[i].getCorners().size() <= 1)
222 for (
size_t j = 0; j < polygons[i].getCorners().size() - 1; j++)
223 drawLine(mask, 255, polygons[i].getCorners()[j], polygons[i].getCorners()[j + 1]);
225 drawLine(mask, 255, polygons[i].getCorners().front(), polygons[i].getCorners().back());
233 "Left click on a pixel location to fill the "
234 "shape, right click to quit.",
251 for (
unsigned int cpt = 0; cpt < mask.getSize(); cpt++) {
252 if (mask.bitmap[cpt])
Display for windows using GDI (available on any windows 32 platform).
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
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 win_x=-1, int win_y=-1, const std::string &win_title="")
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 getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
static void flush(const vpImage< unsigned char > &I)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
void set_uv(double u, double v)
unsigned int getWidth() const
Type * bitmap
points toward the bitmap
unsigned int getHeight() const
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)
VISP_EXPORT void floodFill(vpImage< unsigned char > &I, const vpImagePoint &seedPoint, const unsigned char oldValue, const unsigned char newValue, const vpImageMorphology::vpConnexityType &connexity=vpImageMorphology::CONNEXITY_4)