5 #include <visp3/core/vpImage.h>
6 #include <visp3/gui/vpDisplayGDI.h>
7 #include <visp3/gui/vpDisplayOpenCV.h>
8 #include <visp3/gui/vpDisplayX.h>
9 #include <visp3/io/vpImageIo.h>
11 #if defined(VISP_HAVE_MODULE_IMGPROC)
13 #include <visp3/imgproc/vpImgproc.h>
17 int main(
int argc,
const char **argv)
20 #if defined(VISP_HAVE_MODULE_IMGPROC) && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
23 std::string input_filename =
"img.pgm";
26 for (
int i = 1; i < argc; i++) {
27 if (std::string(argv[i]) ==
"--input" && i + 1 < argc) {
28 input_filename = std::string(argv[i + 1]);
29 }
else if (std::string(argv[i]) ==
"--connexity" && i + 1 < argc) {
31 }
else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
32 std::cout <<
"Usage: " << argv[0]
33 <<
" [--input <input image>] [--connexity <0: 4-connexity, "
34 "1: 8-connexity>] [--help]"
47 #elif defined(VISP_HAVE_GDI)
49 #elif defined(HAVE_OPENCV_HIGHGUI)
52 d.
init(I, 0, 0,
"Input image");
58 std::cout <<
"nbComponents=" << nbComponents << std::endl;
63 for (
unsigned int i = 0; i < I_conn.getHeight(); i++) {
64 for (
unsigned int j = 0; j < I_conn.getWidth(); j++) {
65 if (labels[i][j] != 0) {
73 d2.
init(I_conn, I.
getWidth(), 10,
"Connected components");
static vpColor getColor(const unsigned int &i)
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 flush(const vpImage< unsigned char > &I)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
unsigned int getWidth() const
unsigned int getHeight() const
VISP_EXPORT void connectedComponents(const vpImage< unsigned char > &I, vpImage< int > &labels, int &nbComponents, const vpImageMorphology::vpConnexityType &connexity=vpImageMorphology::CONNEXITY_4)