5 #include <visp3/core/vpConfig.h>
6 #include <visp3/core/vpImage.h>
7 #include <visp3/gui/vpDisplayFactory.h>
9 #if defined(VISP_HAVE_MODULE_IMGPROC) && defined(VISP_HAVE_DISPLAY)
11 #include <visp3/imgproc/vpImgproc.h>
14 #ifdef ENABLE_VISP_NAMESPACE
106 return imPt_switched;
114 if (dx >= 0 && dy >= 0) {
122 else if (dx < 0 && dy >= 0) {
130 else if (dx < 0 && dy < 0) {
154 int octant = getOctant(imPt1, imPt2);
155 imPt1 = switchToOctantZeroFrom(octant, imPt1);
156 imPt2 = switchToOctantZeroFrom(octant, imPt2);
160 double D = 2 * dy - dx;
161 double y = imPt1.
get_v();
163 for (
int x = (
int)imPt1.
get_u(); x <= (
int)imPt2.
get_u(); x++) {
165 currentPt = switchFromOctantZeroTo(octant, currentPt);
167 unsigned int i = std::min<unsigned int>(I.
getHeight() - 1, (
unsigned int)std::max<double>(0.0, currentPt.get_i()));
168 unsigned int j = std::min<unsigned int>(I.
getWidth() - 1, (
unsigned int)std::max<double>(0.0, currentPt.get_j()));
187 #if defined(VISP_HAVE_MODULE_IMGPROC) && defined(VISP_HAVE_DISPLAY)
194 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
199 display->init(I, 0, 0,
"Paint");
202 std::vector<vpPolygon> polygons;
203 for (
int i = 0; i < 3; i++) {
205 std::stringstream ss;
206 ss <<
"Left click to draw polygon " << i + 1 <<
"/3"
207 <<
", right click to close the shape.";
213 polygons.push_back(polygon);
226 for (
size_t i = 0; i < polygons.size(); i++) {
227 if (polygons[i].getCorners().size() <= 1)
230 for (
size_t j = 0; j < polygons[i].getCorners().size() - 1; j++)
231 drawLine(mask, 255, polygons[i].getCorners()[j], polygons[i].getCorners()[j + 1]);
233 drawLine(mask, 255, polygons[i].getCorners().front(), polygons[i].getCorners().back());
241 "Left click on a pixel location to fill the "
242 "shape, right click to quit.",
259 for (
unsigned int cpt = 0; cpt < mask.getSize(); cpt++) {
260 if (mask.bitmap[cpt])
276 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11) && defined(VISP_HAVE_DISPLAY)
277 if (display !=
nullptr) {
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 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)
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.