5 #include <visp3/core/vpConfig.h>
6 #include <visp3/core/vpImage.h>
7 #include <visp3/gui/vpDisplayGDI.h>
8 #include <visp3/gui/vpDisplayOpenCV.h>
9 #include <visp3/gui/vpDisplayX.h>
11 #if defined(VISP_HAVE_MODULE_IMGPROC) && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
13 #include <visp3/imgproc/vpImgproc.h>
16 #ifdef ENABLE_VISP_NAMESPACE
108 return imPt_switched;
116 if (dx >= 0 && dy >= 0) {
124 else if (dx < 0 && dy >= 0) {
132 else if (dx < 0 && dy < 0) {
156 int octant = getOctant(imPt1, imPt2);
157 imPt1 = switchToOctantZeroFrom(octant, imPt1);
158 imPt2 = switchToOctantZeroFrom(octant, imPt2);
162 double D = 2 * dy - dx;
163 double y = imPt1.
get_v();
165 for (
int x = (
int)imPt1.
get_u(); x <= (
int)imPt2.
get_u(); x++) {
167 currentPt = switchFromOctantZeroTo(octant, currentPt);
169 unsigned int i = std::min<unsigned int>(I.
getHeight() - 1, (
unsigned int)std::max<double>(0.0, currentPt.get_i()));
170 unsigned int j = std::min<unsigned int>(I.
getWidth() - 1, (
unsigned int)std::max<double>(0.0, currentPt.get_j()));
189 #if defined(VISP_HAVE_MODULE_IMGPROC) && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
198 #elif defined(VISP_HAVE_GDI)
200 #elif defined(HAVE_OPENCV_HIGHGUI)
203 d.
init(I, 0, 0,
"Paint");
206 std::vector<vpPolygon> polygons;
207 for (
int i = 0; i < 3; i++) {
209 std::stringstream ss;
210 ss <<
"Left click to draw polygon " << i + 1 <<
"/3"
211 <<
", right click to close the shape.";
217 polygons.push_back(polygon);
230 for (
size_t i = 0; i < polygons.size(); i++) {
231 if (polygons[i].getCorners().size() <= 1)
234 for (
size_t j = 0; j < polygons[i].getCorners().size() - 1; j++)
235 drawLine(mask, 255, polygons[i].getCorners()[j], polygons[i].getCorners()[j + 1]);
237 drawLine(mask, 255, polygons[i].getCorners().front(), polygons[i].getCorners().back());
245 "Left click on a pixel location to fill the "
246 "shape, right click to quit.",
263 for (
unsigned int cpt = 0; cpt < mask.getSize(); cpt++) {
264 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(VISP_NAMESPACE_ADDRESSING vpImage< unsigned char > &I, const VISP_NAMESPACE_ADDRESSING vpImagePoint &seedPoint, const unsigned char oldValue, const unsigned char newValue, const VISP_NAMESPACE_ADDRESSING vpImageMorphology::vpConnexityType &connexity=VISP_NAMESPACE_ADDRESSING vpImageMorphology::CONNEXITY_4)