Base class for storing images. More...
#include <yarp/sig/Image.h>
Public Member Functions | |
Image () | |
Default constructor. More... | |
Image (const Image &alt) | |
Copy constructor. More... | |
Image (Image &&other) noexcept | |
Move constructor. More... | |
Image & | operator= (const Image &alt) |
Assignment operator. More... | |
Image & | operator= (Image &&other) noexcept |
Move assignment operator. More... | |
~Image () override | |
Destructor. More... | |
bool | copy (const Image &alt) |
Copy operator. More... | |
bool | copy (const Image &alt, size_t w, size_t h) |
Scaled copy. More... | |
bool | move (Image &&alt) noexcept |
move operator. More... | |
bool | swap (Image &alt) |
swap operator. More... | |
size_t | width () const |
Gets width of image in pixels. More... | |
size_t | height () const |
Gets height of image in pixels. More... | |
virtual size_t | getPixelSize () const |
Gets pixel size in memory in bytes. More... | |
virtual int | getPixelCode () const |
Gets pixel type identifier. More... | |
size_t | getRowSize () const |
Size of the underlying image buffer rows. More... | |
size_t | getQuantum () const |
The size of a row is constrained to be a multiple of the "quantum". More... | |
size_t | getPadding () const |
Returns the number of padding bytes. More... | |
unsigned char * | getRow (size_t r) |
Get the address of a the first byte of a row in memory. More... | |
const unsigned char * | getRow (size_t r) const |
Get the address of a the first byte of a row in memory, const versions. More... | |
unsigned char * | getPixelAddress (size_t x, size_t y) const |
Get address of a pixel in memory. More... | |
bool | isPixel (size_t x, size_t y) const |
Check whether a coordinate lies within the image. More... | |
void | zero () |
Set all pixels to 0. More... | |
void | resize (size_t imgWidth, size_t imgHeight) |
Reallocate an image to be of a desired size, throwing away its current contents. More... | |
void | resize (const Image &alt) |
Reallocate the size of the image to match another, throwing away the actual content of the image. More... | |
void | setExternal (const void *data, size_t imgWidth, size_t imgHeight) |
Use this to wrap an external image. More... | |
unsigned char * | getRawImage () const |
Access to the internal image buffer. More... | |
size_t | getRawImageSize () const |
Access to the internal buffer size information (this is how much memory has been allocated for the image). More... | |
void * | getIplImage () |
Returns IPL/OpenCV view of image, if possible. More... | |
const void * | getIplImage () const |
Returns IPL/OpenCV view of image, if possible. More... | |
void | wrapIplImage (void *iplImage) |
Act as a wrapper around an IPL/OpenCV image. More... | |
bool | read (yarp::os::ConnectionReader &connection) override |
Read image from a connection. More... | |
bool | write (yarp::os::ConnectionWriter &connection) const override |
Write image to a connection. More... | |
void | setQuantum (size_t imgQuantum) |
bool | topIsLowIndex () const |
void | setTopIsLowIndex (bool flag) |
control whether image has origin at top left (default) or bottom left. More... | |
char ** | getRowArray () |
Get an array of pointers to the rows of the image. More... | |
yarp::os::Type | getReadType () const override |
![]() | |
bool | read (ConnectionReader &reader) override=0 |
Read this object from a network connection. More... | |
bool | write (ConnectionWriter &writer) const override=0 |
Write this object to a network connection. More... | |
virtual Type | getType () const |
![]() | |
virtual | ~PortReader () |
Destructor. More... | |
virtual bool | read (ConnectionReader &reader)=0 |
Read this object from a network connection. More... | |
virtual Type | getReadType () const |
![]() | |
virtual | ~PortWriter () |
Destructor. More... | |
virtual bool | write (ConnectionWriter &writer) const =0 |
Write this object to a network connection. More... | |
virtual void | onCompletion () const |
This is called when the port has finished all writing operations. More... | |
virtual void | onCommencement () const |
This is called when the port is about to begin writing operations. More... | |
virtual yarp::os::Type | getWriteType () const |
Protected Member Functions | |
void | setPixelCode (int imgPixelCode) |
void | setPixelSize (size_t imgPixelSize) |
Additional Inherited Members | |
![]() | |
static bool | copyPortable (const PortWriter &writer, PortReader &reader) |
Copy one portable to another, via writing and reading. More... | |
Base class for storing images.
You actually want to use ImageOf or FlexImage. This is a minimal class, designed to be as interoperable as possible with other image classes in other libraries, particularly IPL-derived libraries such as OpenCV.
Image::Image | ( | ) |
Image::Image | ( | const Image & | alt | ) |
|
noexcept |
bool Image::copy | ( | const Image & | alt | ) |
bool Image::copy | ( | const Image & | alt, |
size_t | w, | ||
size_t | h | ||
) |
void * Image::getIplImage | ( | ) |
const void * Image::getIplImage | ( | ) | const |
|
inline |
|
inline |
|
virtual |
Gets pixel type identifier.
Images have an associated type identifier to permit automatic casting between different image types.
Reimplemented in yarp::sig::ImageOf< T >, yarp::sig::ImageOf< yarp::sig::PixelFloat >, yarp::sig::ImageOf< yarp::sig::PixelMono >, yarp::sig::ImageOf< yarp::sig::PixelRgb >, yarp::sig::ImageOf< PixelRgb >, yarp::sig::ImageOf< float >, yarp::sig::ImageOf< CellOccupancyData >, yarp::sig::ImageOf< CellFlagData >, yarp::sig::ImageOf< T >, yarp::sig::ImageOf< yarp::sig::PixelFloat >, yarp::sig::ImageOf< yarp::sig::PixelMono >, yarp::sig::ImageOf< yarp::sig::PixelRgb >, yarp::sig::ImageOf< PixelRgb >, yarp::sig::ImageOf< float >, yarp::sig::ImageOf< CellOccupancyData >, yarp::sig::ImageOf< CellFlagData >, yarp::sig::ImageOf< T >, yarp::sig::ImageOf< yarp::sig::PixelFloat >, yarp::sig::ImageOf< yarp::sig::PixelMono >, yarp::sig::ImageOf< yarp::sig::PixelRgb >, yarp::sig::ImageOf< PixelRgb >, yarp::sig::ImageOf< float >, yarp::sig::ImageOf< CellOccupancyData >, yarp::sig::ImageOf< CellFlagData >, yarp::sig::ImageOf< T >, yarp::sig::ImageOf< yarp::sig::PixelFloat >, yarp::sig::ImageOf< yarp::sig::PixelMono >, yarp::sig::ImageOf< yarp::sig::PixelRgb >, yarp::sig::ImageOf< PixelRgb >, yarp::sig::ImageOf< float >, yarp::sig::ImageOf< CellOccupancyData >, yarp::sig::ImageOf< CellFlagData >, yarp::sig::ImageOf< T >, yarp::sig::ImageOf< yarp::sig::PixelFloat >, yarp::sig::ImageOf< yarp::sig::PixelMono >, yarp::sig::ImageOf< yarp::sig::PixelRgb >, yarp::sig::ImageOf< PixelRgb >, yarp::sig::ImageOf< float >, yarp::sig::ImageOf< CellOccupancyData >, yarp::sig::ImageOf< CellFlagData >, yarp::sig::ImageOf< T >, yarp::sig::ImageOf< yarp::sig::PixelFloat >, yarp::sig::ImageOf< yarp::sig::PixelMono >, yarp::sig::ImageOf< yarp::sig::PixelRgb >, yarp::sig::ImageOf< PixelRgb >, yarp::sig::ImageOf< float >, yarp::sig::ImageOf< CellOccupancyData >, yarp::sig::ImageOf< CellFlagData >, yarp::sig::ImageOf< T >, yarp::sig::ImageOf< yarp::sig::PixelFloat >, yarp::sig::ImageOf< yarp::sig::PixelMono >, yarp::sig::ImageOf< yarp::sig::PixelRgb >, yarp::sig::ImageOf< PixelRgb >, yarp::sig::ImageOf< float >, yarp::sig::ImageOf< CellOccupancyData >, yarp::sig::ImageOf< CellFlagData >, yarp::sig::ImageOf< T >, yarp::sig::ImageOf< yarp::sig::PixelFloat >, yarp::sig::ImageOf< yarp::sig::PixelMono >, yarp::sig::ImageOf< yarp::sig::PixelRgb >, yarp::sig::ImageOf< PixelRgb >, yarp::sig::ImageOf< float >, yarp::sig::ImageOf< CellOccupancyData >, yarp::sig::ImageOf< CellFlagData >, yarp::sig::ImageOf< T >, yarp::sig::ImageOf< yarp::sig::PixelFloat >, yarp::sig::ImageOf< yarp::sig::PixelMono >, yarp::sig::ImageOf< yarp::sig::PixelRgb >, yarp::sig::ImageOf< PixelRgb >, yarp::sig::ImageOf< float >, yarp::sig::ImageOf< CellOccupancyData >, yarp::sig::ImageOf< CellFlagData >, yarp::sig::ImageOf< T >, yarp::sig::ImageOf< yarp::sig::PixelFloat >, yarp::sig::ImageOf< yarp::sig::PixelMono >, yarp::sig::ImageOf< yarp::sig::PixelRgb >, yarp::sig::ImageOf< PixelRgb >, yarp::sig::ImageOf< float >, yarp::sig::ImageOf< CellOccupancyData >, yarp::sig::ImageOf< CellFlagData >, yarp::sig::ImageOf< T >, yarp::sig::ImageOf< yarp::sig::PixelFloat >, yarp::sig::ImageOf< yarp::sig::PixelMono >, yarp::sig::ImageOf< yarp::sig::PixelRgb >, yarp::sig::ImageOf< PixelRgb >, yarp::sig::ImageOf< float >, yarp::sig::ImageOf< CellOccupancyData >, yarp::sig::ImageOf< CellFlagData >, yarp::sig::ImageOf< T >, yarp::sig::ImageOf< yarp::sig::PixelFloat >, yarp::sig::ImageOf< yarp::sig::PixelMono >, yarp::sig::ImageOf< yarp::sig::PixelRgb >, yarp::sig::ImageOf< PixelRgb >, yarp::sig::ImageOf< float >, yarp::sig::ImageOf< CellOccupancyData >, yarp::sig::ImageOf< CellFlagData >, yarp::sig::ImageOf< T >, yarp::sig::ImageOf< yarp::sig::PixelFloat >, yarp::sig::ImageOf< yarp::sig::PixelMono >, yarp::sig::ImageOf< yarp::sig::PixelRgb >, yarp::sig::ImageOf< PixelRgb >, yarp::sig::ImageOf< float >, yarp::sig::ImageOf< CellOccupancyData >, yarp::sig::ImageOf< CellFlagData >, yarp::sig::ImageOf< T >, yarp::sig::ImageOf< yarp::sig::PixelFloat >, yarp::sig::ImageOf< yarp::sig::PixelMono >, yarp::sig::ImageOf< yarp::sig::PixelRgb >, yarp::sig::ImageOf< PixelRgb >, yarp::sig::ImageOf< float >, yarp::sig::ImageOf< CellOccupancyData >, yarp::sig::ImageOf< CellFlagData >, yarp::sig::ImageOf< T >, yarp::sig::ImageOf< yarp::sig::PixelFloat >, yarp::sig::ImageOf< yarp::sig::PixelMono >, yarp::sig::ImageOf< yarp::sig::PixelRgb >, yarp::sig::ImageOf< PixelRgb >, yarp::sig::ImageOf< float >, yarp::sig::ImageOf< CellOccupancyData >, and yarp::sig::ImageOf< CellFlagData >.
|
virtual |
Gets pixel size in memory in bytes.
Reimplemented in yarp::sig::ImageOf< T >, yarp::sig::ImageOf< yarp::sig::PixelFloat >, yarp::sig::ImageOf< yarp::sig::PixelMono >, yarp::sig::ImageOf< yarp::sig::PixelRgb >, yarp::sig::ImageOf< PixelRgb >, yarp::sig::ImageOf< float >, yarp::sig::ImageOf< CellOccupancyData >, and yarp::sig::ImageOf< CellFlagData >.
|
inline |
unsigned char * Image::getRawImage | ( | ) | const |
size_t Image::getRawImageSize | ( | ) | const |
|
inlineoverridevirtual |
Reimplemented from yarp::os::PortReader.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Gets height of image in pixels.
|
inline |
|
noexcept |
|
overridevirtual |
Read image from a connection.
Implements yarp::os::Portable.
|
inline |
void Image::resize | ( | size_t | imgWidth, |
size_t | imgHeight | ||
) |
Reallocate an image to be of a desired size, throwing away its current contents.
If the desired size is the same as the current size, then no reallocation is done. But the resulting image should always be assumed to have undefined content. To rescale an image, maintaining its content, see the Image::copy methods.
imgWidth | the desired width (the number of possible x values) |
imgHeight | the desired height (the number of possible y values) |
void Image::setExternal | ( | const void * | data, |
size_t | imgWidth, | ||
size_t | imgHeight | ||
) |
void Image::setTopIsLowIndex | ( | bool | flag | ) |
bool Image::swap | ( | Image & | alt | ) |
|
inline |
|
inline |
Gets width of image in pixels.
void Image::wrapIplImage | ( | void * | iplImage | ) |
Act as a wrapper around an IPL/OpenCV image.
The wrapped image needs to exist for the rest of the lifetime of this oboject. Be careful if you use this method on objects read from or written to a BufferedPort, since the lifetime of such objects can be longer than you expect (see the documentation for yarp::os::BufferedPort::read, yarp::os::BufferedPort::prepare, and yarp::os::BufferedPort::write).
iplImage | pointer to an IplImage structure |
|
overridevirtual |
Write image to a connection.
Implements yarp::os::Portable.
void Image::zero | ( | ) |