Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpImageIo.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2024 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
38
39#ifndef VP_IMAGE_IO_H
40#define VP_IMAGE_IO_H
41
42#include <visp3/core/vpImage.h>
43#include <visp3/core/vpImageConvert.h>
44
45#include <iostream>
46#include <stdio.h>
47
49
102
103class VISP_EXPORT vpImageIo
104{
105private:
106 typedef enum
107 {
108 FORMAT_PGM,
109 FORMAT_PPM,
110 FORMAT_JPEG,
111 FORMAT_PNG,
112 // Formats supported by opencv
113 FORMAT_TIFF,
114 FORMAT_BMP,
115 FORMAT_DIB,
116 FORMAT_PBM,
117 FORMAT_RASTER,
118 FORMAT_JPEG2000,
119 FORMAT_EXR,
120 FORMAT_PFM,
121 FORMAT_UNKNOWN
122 } vpImageFormatType;
123
124 static vpImageFormatType getFormat(const std::string &filename);
125
126public:
136
137 static void read(vpImage<unsigned char> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
138 static void read(vpImage<vpRGBa> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
139 static void read(vpImage<float> &I, const std::string &filename);
140
141 static void write(const vpImage<unsigned char> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
142 static void write(const vpImage<vpRGBa> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
143
144 static void readPFM(vpImage<float> &I, const std::string &filename);
145 static void readPFM_HDR(vpImage<float> &I, const std::string &filename);
146 static void readPFM_HDR(vpImage<vpRGBf> &I, const std::string &filename);
147
148 static void readPGM(vpImage<unsigned char> &I, const std::string &filename);
149 static void readPGM(vpImage<vpRGBa> &I, const std::string &filename);
150
151 static void readPPM(vpImage<unsigned char> &I, const std::string &filename);
152 static void readPPM(vpImage<vpRGBa> &I, const std::string &filename);
153
154 static void readJPEG(vpImage<unsigned char> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
155 static void readJPEG(vpImage<vpRGBa> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
156
157 static void readPNG(vpImage<unsigned char> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
158 static void readPNG(vpImage<vpRGBa> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
159
160 static void readEXR(vpImage<float> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
161 static void readEXR(vpImage<vpRGBf> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
162
163 static void writePFM(const vpImage<float> &I, const std::string &filename);
164 static void writePFM_HDR(const vpImage<float> &I, const std::string &filename);
165 static void writePFM_HDR(const vpImage<vpRGBf> &I, const std::string &filename);
166
167 static void writePGM(const vpImage<unsigned char> &I, const std::string &filename);
168 static void writePGM(const vpImage<short> &I, const std::string &filename);
169 static void writePGM(const vpImage<vpRGBa> &I, const std::string &filename);
170
171 static void writePPM(const vpImage<unsigned char> &I, const std::string &filename);
172 static void writePPM(const vpImage<vpRGBa> &I, const std::string &filename);
173
174 static void writeJPEG(const vpImage<unsigned char> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND,
175 int quality = 90);
176 static void writeJPEG(const vpImage<vpRGBa> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND,
177 int quality = 90);
178
179 static void writePNG(const vpImage<unsigned char> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
180 static void writePNG(const vpImage<vpRGBa> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
181
182 static void writeEXR(const vpImage<float> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
183 static void writeEXR(const vpImage<vpRGBf> &I, const std::string &filename, int backend = IO_DEFAULT_BACKEND);
184
185 static void readPNGfromMem(const std::vector<unsigned char> &buffer, vpImage<unsigned char> &I,
186 int backend = IO_DEFAULT_BACKEND);
187 static void readPNGfromMem(const std::vector<unsigned char> &buffer, vpImage<vpRGBa> &I,
188 int backend = IO_DEFAULT_BACKEND);
189
190 static void writePNGtoMem(const vpImage<unsigned char> &I, std::vector<unsigned char> &buffer,
191 int backend = IO_DEFAULT_BACKEND);
192 static void writePNGtoMem(const vpImage<vpRGBa> &I, std::vector<unsigned char> &buffer,
193 int backend = IO_DEFAULT_BACKEND, bool saveAlpha = false);
194};
195
196END_VISP_NAMESPACE
197
198#endif
Read/write images with various image format.
Definition vpImageIo.h:104
vpImageIoBackendType
Image IO backend for only jpeg and png formats image loading and saving.
Definition vpImageIo.h:129
@ IO_STB_IMAGE_BACKEND
Use embedded stb_image library.
Definition vpImageIo.h:134
@ IO_DEFAULT_BACKEND
Default backend.
Definition vpImageIo.h:130
@ IO_SIMDLIB_BACKEND
Use embedded simd library.
Definition vpImageIo.h:133
@ IO_SYSTEM_LIB_BACKEND
Use system libraries like libpng or libjpeg-turbo.
Definition vpImageIo.h:131
@ IO_OPENCV_BACKEND
Use OpenCV imgcodecs module.
Definition vpImageIo.h:132
Definition of the vpImage class member functions.
Definition vpImage.h:131