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) {
119 else if (dx < 0 && dy >= 0) {
127 else if (dx < 0 && dy < 0) {
151 int octant = getOctant(imPt1, imPt2);
152 imPt1 = switchToOctantZeroFrom(octant, imPt1);
153 imPt2 = switchToOctantZeroFrom(octant, imPt2);
157 double D = 2 * dy - dx;
158 double y = imPt1.
get_v();
160 for (
int x = (
int)imPt1.
get_u(); x <= (
int)imPt2.
get_u(); x++) {
162 currentPt = switchFromOctantZeroTo(octant, currentPt);
164 unsigned int i = std::min<unsigned int>(I.
getHeight() - 1, (
unsigned int)std::max<double>(0.0, currentPt.get_i()));
165 unsigned int j = std::min<unsigned int>(I.
getWidth() - 1, (
unsigned int)std::max<double>(0.0, currentPt.get_j()));
184 #if defined(VISP_HAVE_MODULE_IMGPROC) && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
193 #elif defined(VISP_HAVE_GDI)
195 #elif defined(HAVE_OPENCV_HIGHGUI)
198 d.
init(I, 0, 0,
"Paint");
201 std::vector<vpPolygon> polygons;
202 for (
int i = 0; i < 3; i++) {
204 std::stringstream ss;
205 ss <<
"Left click to draw polygon " << i + 1 <<
"/3"
206 <<
", right click to close the shape.";
212 polygons.push_back(polygon);
225 for (
size_t i = 0; i < polygons.size(); i++) {
226 if (polygons[i].getCorners().size() <= 1)
229 for (
size_t j = 0; j < polygons[i].getCorners().size() - 1; j++)
230 drawLine(mask, 255, polygons[i].getCorners()[j], polygons[i].getCorners()[j + 1]);
232 drawLine(mask, 255, polygons[i].getCorners().front(), polygons[i].getCorners().back());
240 "Left click on a pixel location to fill the "
241 "shape, right click to quit.",
258 for (
unsigned int cpt = 0; cpt < mask.getSize(); cpt++) {
259 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="") vp_override
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)