![]() |
Visual Servoing Platform
version 3.6.1 under development (2023-10-03)
|
#include <visp3/io/vpImageIo.h>
Public Types | |
enum | vpImageIoBackendType { IO_DEFAULT_BACKEND , IO_SYSTEM_LIB_BACKEND , IO_OPENCV_BACKEND , IO_SIMDLIB_BACKEND , IO_STB_IMAGE_BACKEND } |
Static Public Member Functions | |
static void | read (vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND) |
static void | read (vpImage< vpRGBa > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND) |
static void | write (const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND) |
static void | write (const vpImage< vpRGBa > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND) |
static void | readPFM (vpImage< float > &I, const std::string &filename) |
static void | readPFM_HDR (vpImage< float > &I, const std::string &filename) |
static void | readPFM_HDR (vpImage< vpRGBf > &I, const std::string &filename) |
static void | readPGM (vpImage< unsigned char > &I, const std::string &filename) |
static void | readPGM (vpImage< vpRGBa > &I, const std::string &filename) |
static void | readPPM (vpImage< unsigned char > &I, const std::string &filename) |
static void | readPPM (vpImage< vpRGBa > &I, const std::string &filename) |
static void | readJPEG (vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND) |
static void | readJPEG (vpImage< vpRGBa > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND) |
static void | readPNG (vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND) |
static void | readPNG (vpImage< vpRGBa > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND) |
static void | readEXR (vpImage< float > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND) |
static void | readEXR (vpImage< vpRGBf > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND) |
static void | writePFM (const vpImage< float > &I, const std::string &filename) |
static void | writePFM_HDR (const vpImage< float > &I, const std::string &filename) |
static void | writePFM_HDR (const vpImage< vpRGBf > &I, const std::string &filename) |
static void | writePGM (const vpImage< unsigned char > &I, const std::string &filename) |
static void | writePGM (const vpImage< short > &I, const std::string &filename) |
static void | writePGM (const vpImage< vpRGBa > &I, const std::string &filename) |
static void | writePPM (const vpImage< unsigned char > &I, const std::string &filename) |
static void | writePPM (const vpImage< vpRGBa > &I, const std::string &filename) |
static void | writeJPEG (const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND, int quality=90) |
static void | writeJPEG (const vpImage< vpRGBa > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND, int quality=90) |
static void | writePNG (const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND) |
static void | writePNG (const vpImage< vpRGBa > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND) |
static void | writeEXR (const vpImage< float > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND) |
static void | writeEXR (const vpImage< vpRGBf > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND) |
Read/write images with various image format.
This class has its own implementation of PGM and PPM images read/write.
This class may benefit from optional 3rd parties:
The code below shows how to convert an PPM P6 image file format into a PGM P5 image file format. The extension of the filename is here used in read() and write() functions to set the image file format (".pgm" for PGM P5 and ".ppm" for PPM P6).
This other example available in tutorial-image-reader.cpp shows how to read/write jpeg images. It supposes that libjpeg
is installed.
Definition at line 98 of file vpImageIo.h.
Image IO backend for only jpeg and png formats image loading and saving.
Definition at line 121 of file vpImageIo.h.
|
static |
Read the contents of the image filename, allocate memory for the corresponding grayscale image, update its content, and return a reference to the image.
If the image has been already initialized, memory allocation is done only if the new image size is different, else we re-use the same memory space.
Supported formats are:
*.pgm
file*.ppm
file*.pfm
file*.jpg
, *.jpeg
files*.png
fileIf ViSP is build with OpenCV support, additional formats are considered:
*.jp2
, *.rs
, *.ras
, *.tiff
, *.tif
, *.png
, *.bmp
, *.pbm
files.If EXIF information is embedded in the image file, the EXIF orientation is ignored.
I | : Image to set with the filename content. |
filename | : Name of the file containing the image. |
backend | : Library backend type (see vpImageIo::vpImageIoBackendType) for image reading. This parameter is only used when the image need to be loaded in jpeg or png format. To know which is the default backend see respectively void vpImageIo::readJPEG(const vpImage<unsigned char> &, const std::string &, int) and void vpImageIo::readPNG(const vpImage<unsigned char> &, const std::string &, int). |
Definition at line 143 of file vpImageIo.cpp.
References vpIoTools::checkFilename(), vpImageException::ioError, vpIoTools::path(), readJPEG(), readPGM(), readPNG(), and readPPM().
Referenced by vpDiskGrabber::acquire(), vpImageSimulator::init(), vpMbTracker::initClick(), vpKeyPoint::loadLearningData(), and vpVirtualGrabber::vpVirtualGrabber().
|
static |
Read the contents of the image filename, allocate memory for the corresponding grayscale image, update its content, and return a reference to the image.
If the image has been already initialized, memory allocation is done only if the new image size is different, else we re-use the same memory space.
Supported formats are:
*.pgm
file*.ppm
file*.pfm
file*.jpg
, *.jpeg
files*.png
fileIf ViSP is build with OpenCV support, additional formats are considered:
*.jp2
, *.rs
, *.ras
, *.tiff
, *.tif
, *.png
, *.bmp
, *.pbm
files.If EXIF information is embedded in the image file, the EXIF orientation is ignored.
I | : Image to set with the filename content. |
filename | : Name of the file containing the image. |
backend | : Library backend type (see vpImageIo::vpImageIoBackendType) for image reading. This parameter is only used when the image need to be loaded in jpeg or png format. To know which is the default backend see respectively void vpImageIo::readJPEG(const vpImage<unsigned char> &, const std::string &, int) and void vpImageIo::readPNG(const vpImage<unsigned char> &, const std::string &, int). |
Definition at line 219 of file vpImageIo.cpp.
References vpIoTools::checkFilename(), vpImageException::ioError, vpIoTools::path(), readJPEG(), readPGM(), readPNG(), and readPPM().
|
static |
Load an image in EXR format.
[out] | I | : Floating-point single channel image. |
[in] | filename | : Image location. |
[in] | backend | : Supported backends are described in vpImageIo::vpImageIoBackendType. Only OpenCV and the Tiny OpenEXR image libraries can currently read EXR image. The default backend vpImageIo::IO_DEFAULT_BACKEND is the Tiny OpenEXR image library. |
Definition at line 587 of file vpImageIo.cpp.
References IO_DEFAULT_BACKEND, IO_OPENCV_BACKEND, IO_SIMDLIB_BACKEND, IO_STB_IMAGE_BACKEND, IO_SYSTEM_LIB_BACKEND, and vpImageException::ioError.
|
static |
Load an image in EXR format.
[out] | I | : Floating-point three channels image. |
[in] | filename | : Image location. |
[in] | backend | : Supported backends are described in vpImageIo::vpImageIoBackendType. Only OpenCV and the Tiny OpenEXR image libraries can currently read EXR image. The default backend vpImageIo::IO_DEFAULT_BACKEND is the Tiny OpenEXR image library. |
Definition at line 625 of file vpImageIo.cpp.
References IO_DEFAULT_BACKEND, IO_OPENCV_BACKEND, IO_SIMDLIB_BACKEND, IO_STB_IMAGE_BACKEND, IO_SYSTEM_LIB_BACKEND, and vpImageException::ioError.
|
static |
Load a jpeg image. If it is a color image it is converted in gray.
[out] | I | : Gray level image. |
[in] | filename | : Image location. |
[in] | backend | : Supported backends are described in vpImageIo::vpImageIoBackendType. Depending on its availability, the default backend vpImageIo::IO_DEFAULT_BACKEND is chosen in the following order: vpImageIo::IO_OPENCV_BACKEND, vpImageIo::IO_SYSTEM_LIB_BACKEND, vpImageIo::IO_STB_IMAGE_BACKEND. |
Definition at line 395 of file vpImageIo.cpp.
References IO_DEFAULT_BACKEND, IO_OPENCV_BACKEND, IO_SIMDLIB_BACKEND, IO_STB_IMAGE_BACKEND, and IO_SYSTEM_LIB_BACKEND.
Referenced by read().
|
static |
Load a jpeg image. If it is a gray image it is converted in color.
[out] | I | : Color image. |
[in] | filename | : Image location. |
[in] | backend | : Supported backends are described in vpImageIo::vpImageIoBackendType. Depending on its availability, the default backend vpImageIo::IO_DEFAULT_BACKEND is chosen in the following order: vpImageIo::IO_OPENCV_BACKEND, vpImageIo::IO_SYSTEM_LIB_BACKEND, vpImageIo::IO_STB_IMAGE_BACKEND. |
Definition at line 444 of file vpImageIo.cpp.
References IO_DEFAULT_BACKEND, IO_OPENCV_BACKEND, IO_SIMDLIB_BACKEND, IO_STB_IMAGE_BACKEND, and IO_SYSTEM_LIB_BACKEND.
|
static |
Load an image in portable float map format.
[out] | I | : Image read from filename. |
[in] | filename | : Image location. |
Definition at line 966 of file vpImageIo.cpp.
Referenced by vpDiskGrabber::acquire().
|
static |
Load an image in portable float map format and not restricted to the [0, 255] dynamic range.
[out] | I | : Image read from filename. |
[in] | filename | : Image location. |
Definition at line 973 of file vpImageIo.cpp.
Load an image in portable float map format and not restricted to the [0, 255] dynamic range.
[out] | I | : Image read from filename and with three channels. |
[in] | filename | : Image location. |
Definition at line 980 of file vpImageIo.cpp.
|
static |
Load an image in portable gray map format. If the image is in color, it is converted in gray level.
[out] | I | : Image read from filename. |
[in] | filename | : Image location. |
Definition at line 987 of file vpImageIo.cpp.
Referenced by read().
Load an image in portable float map format. If the image is in gray, it is converted in color.
[out] | I | : Image read from filename. |
[in] | filename | : Image location. |
Definition at line 994 of file vpImageIo.cpp.
|
static |
Load an image in png format. If it is a color image it is converted in gray.
[out] | I | : Gray level image. |
[in] | filename | : Image location. |
[in] | backend | : Supported backends are described in vpImageIo::vpImageIoBackendType. Depending on its availability, the default backend vpImageIo::IO_DEFAULT_BACKEND is chosen in the following order: vpImageIo::IO_SYSTEM_LIB_BACKEND, vpImageIo::IO_OPENCV_BACKEND, vpImageIo::IO_STB_IMAGE_BACKEND. |
Definition at line 493 of file vpImageIo.cpp.
References IO_DEFAULT_BACKEND, IO_OPENCV_BACKEND, IO_SIMDLIB_BACKEND, IO_STB_IMAGE_BACKEND, and IO_SYSTEM_LIB_BACKEND.
Referenced by read().
|
static |
Load an image in png format. If it is a gray level image it is converted in color.
[out] | I | : Color image. |
[in] | filename | : Image location. |
[in] | backend | : Supported backends are described in vpImageIo::vpImageIoBackendType. Depending on its availability, the default backend vpImageIo::IO_DEFAULT_BACKEND is chosen in the following order: vpImageIo::IO_OPENCV_BACKEND, vpImageIo::IO_STB_IMAGE_BACKEND. |
Definition at line 542 of file vpImageIo.cpp.
References IO_DEFAULT_BACKEND, IO_OPENCV_BACKEND, IO_SIMDLIB_BACKEND, IO_STB_IMAGE_BACKEND, and IO_SYSTEM_LIB_BACKEND.
|
static |
Load an image in portable pixmap format. If the image is in color, it is converted in gray level.
[out] | I | : Image read from filename. |
[in] | filename | : Image location. |
Definition at line 1001 of file vpImageIo.cpp.
Referenced by read().
Load an image in portable pixmap format. If the image is in gray, it is converted in color.
[out] | I | : Image read from filename. |
[in] | filename | : Image location. |
Definition at line 1008 of file vpImageIo.cpp.
|
static |
Write the content of the image in the file which name is given by filename.
Supported formats are:
*.pgm
file*.ppm
file*.pfm
file*.jpg
, *.jpeg
files*.png
fileIf ViSP is build with OpenCV support, additional formats are considered:
*.jp2
, *.rs
, *.ras
, *.tiff
, *.tif
, *.png
, *.bmp
, *.pbm
files.I | : Image to write. |
filename | : Name of the file containing the image. |
backend | : Library backend type (see vpImageIo::vpImageIoBackendType) for image writing. This parameter is only used when the image need to be saved in jpeg or png format. To know which is the default backend see respectively void vpImageIo::writeJPEG(const vpImage<unsigned char> &, const std::string &, int, int) and void vpImageIo::writePNG(const vpImage<unsigned char> &, const std::string &, int). |
Definition at line 287 of file vpImageIo.cpp.
References vpImageException::ioError, writeJPEG(), writePGM(), writePNG(), and writePPM().
Referenced by vpImageStorageWorker< Type >::run(), vpVideoWriter::saveFrame(), vpKeyPoint::saveLearningData(), and vpSimulator::write().
|
static |
Write the content of the image in the file which name is given by filename.
Supported formats are:
*.pgm
file*.ppm
file*.pfm
file*.jpg
, *.jpeg
files*.png
fileIf ViSP is build with OpenCV support, additional formats are considered:
*.jp2
, *.rs
, *.ras
, *.tiff
, *.tif
, *.png
, *.bmp
, *.pbm
files.I | : Image to write. |
filename | : Name of the file containing the image. |
backend | : Library backend type (see vpImageIo::vpImageIoBackendType) for image writing. This parameter is only used when the image need to be saved in jpeg or png format. To know which is the default backend see respectively void vpImageIo::writeJPEG(const vpImage<vpRGBa> &, const std::string &, int, int) and void vpImageIo::writePNG(const vpImage<vpRGBa> &, const std::string &, int). |
Definition at line 347 of file vpImageIo.cpp.
References vpImageException::ioError, writeJPEG(), writePGM(), writePNG(), and writePPM().
|
static |
Save an image in EXR format.
[in] | I | : Floating-point single channel image. |
[in] | filename | : Image location. |
[in] | backend | : Supported backends are described in vpImageIo::vpImageIoBackendType. Only OpenCV and the Tiny OpenEXR image libraries can currently save EXR image. The default backend vpImageIo::IO_DEFAULT_BACKEND is the Tiny OpenEXR image library. |
Definition at line 849 of file vpImageIo.cpp.
References IO_DEFAULT_BACKEND, IO_OPENCV_BACKEND, IO_SIMDLIB_BACKEND, IO_STB_IMAGE_BACKEND, IO_SYSTEM_LIB_BACKEND, and vpImageException::ioError.
|
static |
Save an image in EXR format.
[in] | I | : Floating-point three channels image. |
[in] | filename | : Image location. |
[in] | backend | : Supported backends are described in vpImageIo::vpImageIoBackendType. Only OpenCV and the Tiny OpenEXR image libraries can currently save EXR image. The default backend vpImageIo::IO_DEFAULT_BACKEND is the Tiny OpenEXR image library. |
Definition at line 887 of file vpImageIo.cpp.
References IO_DEFAULT_BACKEND, IO_OPENCV_BACKEND, IO_SIMDLIB_BACKEND, IO_STB_IMAGE_BACKEND, IO_SYSTEM_LIB_BACKEND, and vpImageException::ioError.
|
static |
Save an image in jpeg format.
[in] | I | : Gray level image. |
[in] | filename | : Image location. |
[in] | backend | : Supported backends are described in vpImageIo::vpImageIoBackendType. Depending on its availability, the default backend vpImageIo::IO_DEFAULT_BACKEND is chosen in the following order: vpImageIo::IO_SYSTEM_LIB_BACKEND, vpImageIo::IO_OPENCV_BACKEND, vpImageIo::IO_SIMDLIB_BACKEND. |
[in] | quality | : Image quality percentage in range 0-100. |
Definition at line 666 of file vpImageIo.cpp.
References IO_DEFAULT_BACKEND, IO_OPENCV_BACKEND, IO_SIMDLIB_BACKEND, IO_STB_IMAGE_BACKEND, and IO_SYSTEM_LIB_BACKEND.
Referenced by write().
|
static |
Save an image in jpeg format.
[in] | I | : Color image. |
[in] | filename | : Image location. |
[in] | backend | : Supported backends are described in vpImageIo::vpImageIoBackendType. Depending on its availability, the default backend vpImageIo::IO_DEFAULT_BACKEND is chosen in the following order: vpImageIo::IO_SYSTEM_LIB_BACKEND, vpImageIo::IO_OPENCV_BACKEND, vpImageIo::IO_SIMDLIB_BACKEND. |
[in] | quality | : Image quality percentage in range 0-100. |
Definition at line 714 of file vpImageIo.cpp.
References IO_DEFAULT_BACKEND, IO_OPENCV_BACKEND, IO_SIMDLIB_BACKEND, IO_STB_IMAGE_BACKEND, and IO_SYSTEM_LIB_BACKEND.
|
static |
Save an image in portable float map format.
[in] | I | : Image to save. |
[in] | filename | : Image location. |
Definition at line 922 of file vpImageIo.cpp.
|
static |
Save a high-dynamic range (not restricted to the [0-255] intensity range) floating-point image in portable float map format.
[in] | I | : Grayscale floating-point image to save. |
[in] | filename | : Image location. |
Definition at line 930 of file vpImageIo.cpp.
Save a RGB high-dynamic range (not restricted to the [0-255] intensity range) floating-point image in portable float map format.
[in] | I | : RGB floating-point image to save. |
[in] | filename | : Image location. |
Definition at line 938 of file vpImageIo.cpp.
|
static |
Save a gray level image in portable gray map format.
[in] | I | : Image to save. |
[in] | filename | : Image location. |
Definition at line 952 of file vpImageIo.cpp.
|
static |
Save an image in portable gray map format.
[in] | I | : Image to save. |
[in] | filename | : Image location. |
Definition at line 945 of file vpImageIo.cpp.
Referenced by write().
Save a color image in portable gray map format.
[in] | I | : Image to save. |
[in] | filename | : Image location. |
Definition at line 959 of file vpImageIo.cpp.
|
static |
Save an image in png format.
[in] | I | : Gray level image. |
[in] | filename | : Image location. |
[in] | backend | : Supported backends are described in vpImageIo::vpImageIoBackendType. Depending on its availability, the default backend vpImageIo::IO_DEFAULT_BACKEND is chosen in the following order: vpImageIo::IO_OPENCV_BACKEND, vpImageIo::IO_SIMDLIB_BACKEND. |
Definition at line 761 of file vpImageIo.cpp.
References IO_DEFAULT_BACKEND, IO_OPENCV_BACKEND, IO_SIMDLIB_BACKEND, IO_STB_IMAGE_BACKEND, and IO_SYSTEM_LIB_BACKEND.
Referenced by write().
|
static |
Save an image in png format.
[in] | I | : Color image. |
[in] | filename | : Image location. |
[in] | backend | : Supported backends are described in vpImageIo::vpImageIoBackendType. Depending on its availability, the default backend vpImageIo::IO_DEFAULT_BACKEND is chosen in the following order: vpImageIo::IO_OPENCV_BACKEND, vpImageIo::IO_SYSTEM_LIB_BACKEND, vpImageIo::IO_SIMDLIB_BACKEND. |
Definition at line 806 of file vpImageIo.cpp.
References IO_DEFAULT_BACKEND, IO_OPENCV_BACKEND, IO_SIMDLIB_BACKEND, IO_STB_IMAGE_BACKEND, and IO_SYSTEM_LIB_BACKEND.
|
static |
Save a gray level image in portable pixmap format.
[in] | I | : Image to save. |
[in] | filename | : Image location. |
Definition at line 1015 of file vpImageIo.cpp.
Referenced by write().
Save a color level image in portable pixmap format.
[in] | I | : Image to save. |
[in] | filename | : Image location. |
Definition at line 1022 of file vpImageIo.cpp.