Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
vpImageIo.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * See the file LICENSE.txt at the root directory of this source
10 * distribution for additional information about the GNU GPL.
11 *
12 * For using ViSP with software that can not be combined with the GNU
13 * GPL, please contact Inria about acquiring a ViSP Professional
14 * Edition License.
15 *
16 * See https://visp.inria.fr for more information.
17 *
18 * This software was developed at:
19 * Inria Rennes - Bretagne Atlantique
20 * Campus Universitaire de Beaulieu
21 * 35042 Rennes Cedex
22 * France
23 *
24 * If you have questions regarding the use of this file, please contact
25 * Inria at visp@inria.fr
26 *
27 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29 *
30 * Description:
31 * Read/write images.
32 */
33
39#ifndef _vpImageIo_h_
40#define _vpImageIo_h_
41
42#include <visp3/core/vpDebug.h>
43#include <visp3/core/vpImage.h>
44#include <visp3/core/vpImageConvert.h>
45
46#include <iostream>
47#include <stdio.h>
48
98class VISP_EXPORT vpImageIo
99{
100private:
101 typedef enum {
102 FORMAT_PGM,
103 FORMAT_PPM,
104 FORMAT_JPEG,
105 FORMAT_PNG,
106 // Formats supported by opencv
107 FORMAT_TIFF,
108 FORMAT_BMP,
109 FORMAT_DIB,
110 FORMAT_PBM,
111 FORMAT_RASTER,
112 FORMAT_JPEG2000,
113 FORMAT_UNKNOWN
114 } vpImageFormatType;
115
116 static vpImageFormatType getFormat(const std::string &filename);
117 static std::string getExtension(const std::string &filename);
118
119public:
128
129 static void read(vpImage<unsigned char> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
130 static void read(vpImage<vpRGBa> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
131
132 static void write(const vpImage<unsigned char> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
133 static void write(const vpImage<vpRGBa> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
134
135 static void readPFM(vpImage<float> &I, const std::string &filename);
136 static void readPFM_HDR(vpImage<float> &I, const std::string &filename);
137 static void readPFM_HDR(vpImage<vpRGBf> &I, const std::string &filename);
138
139 static void readPGM(vpImage<unsigned char> &I, const std::string &filename);
140 static void readPGM(vpImage<vpRGBa> &I, const std::string &filename);
141
142 static void readPPM(vpImage<unsigned char> &I, const std::string &filename);
143 static void readPPM(vpImage<vpRGBa> &I, const std::string &filename);
144
145 static void readJPEG(vpImage<unsigned char> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
146 static void readJPEG(vpImage<vpRGBa> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
147
148 static void readPNG(vpImage<unsigned char> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
149 static void readPNG(vpImage<vpRGBa> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
150
151 static void readEXR(vpImage<float> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
152 static void readEXR(vpImage<vpRGBf> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
153
154 static void writePFM(const vpImage<float> &I, const std::string &filename);
155 static void writePFM_HDR(const vpImage<float> &I, const std::string &filename);
156 static void writePFM_HDR(const vpImage<vpRGBf> &I, const std::string &filename);
157
158 static void writePGM(const vpImage<unsigned char> &I, const std::string &filename);
159 static void writePGM(const vpImage<short> &I, const std::string &filename);
160 static void writePGM(const vpImage<vpRGBa> &I, const std::string &filename);
161
162 static void writePPM(const vpImage<unsigned char> &I, const std::string &filename);
163 static void writePPM(const vpImage<vpRGBa> &I, const std::string &filename);
164
165 static void writeJPEG(const vpImage<unsigned char> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND,
166 int quality = 90);
167 static void writeJPEG(const vpImage<vpRGBa> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND,
168 int quality = 90);
169
170 static void writePNG(const vpImage<unsigned char> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
171 static void writePNG(const vpImage<vpRGBa> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
172
173 static void writeEXR(const vpImage<float> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
174 static void writeEXR(const vpImage<vpRGBf> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
175};
176#endif
Read/write images with various image format.
Definition vpImageIo.h:99
vpImageIoBackendType
Image IO backend for only jpeg and png formats image loading and saving.
Definition vpImageIo.h:121
@ IO_DEFAULT_BACKEND
Default backend.
Definition vpImageIo.h:122
@ IO_SIMDLIB_BACKEND
Use embedded simd library.
Definition vpImageIo.h:125
@ IO_SYSTEM_LIB_BACKEND
Use system libraries like libpng or libjpeg.
Definition vpImageIo.h:123
@ IO_OPENCV_BACKEND
Use OpenCV.
Definition vpImageIo.h:124
Definition of the vpImage class member functions.
Definition vpImage.h:135