Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
tutorial-export-image.cpp
1
2
#include <visp3/core/vpConfig.h>
3
#include <visp3/gui/vpDisplayFactory.h>
4
#include <visp3/io/vpImageIo.h>
5
6
#ifdef ENABLE_VISP_NAMESPACE
7
using namespace
VISP_NAMESPACE_NAME
;
8
#endif
9
10
int
main()
11
{
12
#if defined(VISP_HAVE_DISPLAY)
13
vpImage<unsigned char>
I(240, 320, 255);
// Create a black grey level image
14
vpImage<vpRGBa>
Ioverlay;
15
16
// Initialize the display with the image I. Display and image are now linked together
17
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
18
std::shared_ptr<vpDisplay>
d
=
vpDisplayFactory::createDisplay
(I, -1, -1,
"Save overlayed image"
,
vpDisplay::SCALE_AUTO
);
19
#else
20
vpDisplay
*
d
=
vpDisplayFactory::allocateDisplay
(I, -1, -1,
"Save overlayed image"
,
vpDisplay::SCALE_AUTO
);
21
#endif
22
// Set the display background with image I content
23
vpDisplay::display
(I);
24
// Draw a red rectangle in the display overlay (foreground)
25
vpDisplay::displayRectangle
(I, 10, 10, 100, 20,
vpColor::red
,
true
);
26
// Flush the foreground and background display
27
vpDisplay::flush
(I);
28
// Updates the color image with the original loaded image and the overlay
29
vpDisplay::getImage
(I, Ioverlay);
30
// Write the color image on the disk
31
std::string ofilename(
"overlay.png"
);
32
std::cout <<
"Save overlayed image in: "
<< ofilename << std::endl;
33
vpImageIo::write
(Ioverlay, ofilename);
34
// Wait for a click in the display window
35
std::cout <<
"A click to quit..."
<< std::endl;
36
vpDisplay::getClick
(I);
37
38
#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
39
delete
d
;
40
#endif
41
#else
42
std::cout <<
"No gui available to display an image..."
<< std::endl;
43
#endif
44
}
vpColor::red
static const vpColor red
Definition
vpColor.h:198
vpDisplay
Class that defines generic functionalities for display.
Definition
vpDisplay.h:171
vpDisplay::getClick
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
Definition
vpDisplay_uchar.cpp:894
vpDisplay::display
static void display(const vpImage< unsigned char > &I)
Definition
vpDisplay_uchar.cpp:869
vpDisplay::getImage
static void getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
Definition
vpDisplay.cpp:139
vpDisplay::flush
static void flush(const vpImage< unsigned char > &I)
Definition
vpDisplay_uchar.cpp:845
vpDisplay::SCALE_AUTO
@ SCALE_AUTO
Definition
vpDisplay.h:177
vpDisplay::displayRectangle
static void displayRectangle(const vpImage< unsigned char > &I, const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)
Definition
vpDisplay_uchar.cpp:665
vpImageIo::write
static void write(const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Definition
vpImageIo.cpp:336
vpImage
Definition of the vpImage class member functions.
Definition
vpImage.h:131
VISP_NAMESPACE_NAME
Definition
vpEigenConversion.h:44
vpDisplayFactory::createDisplay
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.
Definition
vpDisplayFactory.h:142
vpDisplayFactory::allocateDisplay
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.
Definition
vpDisplayFactory.h:68
yolo-centering-task-afma6.d
d
Definition
yolo-centering-task-afma6.py:273
tutorial
image
tutorial-export-image.cpp
Generated by
1.17.0