Visual Servoing Platform  version 3.5.0 under development (2022-02-15)
vpImageIo.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Read/write images.
33  *
34  * Authors:
35  * Eric Marchand
36  *
37  *****************************************************************************/
38 
44 #ifndef vpIMAGEIO_H
45 #define vpIMAGEIO_H
46 
47 #include <visp3/core/vpDebug.h>
48 #include <visp3/core/vpImage.h>
49 #include <visp3/core/vpImageConvert.h>
50 #include <visp3/core/vpRGBa.h>
51 
52 #include <iostream>
53 #include <stdio.h>
54 
104 class VISP_EXPORT vpImageIo
105 {
106 private:
107  typedef enum {
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_UNKNOWN
120  } vpImageFormatType;
121 
122  static vpImageFormatType getFormat(const std::string &filename);
123  static std::string getExtension(const std::string &filename);
124 
125 public:
132  IO_STB_IMAGE_BACKEND
133  };
134 
135  static void read(vpImage<unsigned char> &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND);
136  static void read(vpImage<vpRGBa> &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND);
137 
138  static void write(const vpImage<unsigned char> &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND);
139  static void write(const vpImage<vpRGBa> &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND);
140 
141  static void readPFM(vpImage<float> &I, const std::string &filename);
142 
143  static void readPGM(vpImage<unsigned char> &I, const std::string &filename);
144  static void readPGM(vpImage<vpRGBa> &I, const std::string &filename);
145 
146  static void readPPM(vpImage<unsigned char> &I, const std::string &filename);
147  static void readPPM(vpImage<vpRGBa> &I, const std::string &filename);
148 
149  static void readJPEG(vpImage<unsigned char> &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND);
150  static void readJPEG(vpImage<vpRGBa> &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND);
151 
152  static void readPNG(vpImage<unsigned char> &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND);
153  static void readPNG(vpImage<vpRGBa> &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND);
154 
155  static void writePFM(const vpImage<float> &I, const std::string &filename);
156 
157  static void writePGM(const vpImage<unsigned char> &I, const std::string &filename);
158  static void writePGM(const vpImage<short> &I, const std::string &filename);
159  static void writePGM(const vpImage<vpRGBa> &I, const std::string &filename);
160 
161  static void writePPM(const vpImage<unsigned char> &I, const std::string &filename);
162  static void writePPM(const vpImage<vpRGBa> &I, const std::string &filename);
163 
164  static void writeJPEG(const vpImage<unsigned char> &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND, int quality=90);
165  static void writeJPEG(const vpImage<vpRGBa> &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND, int quality=90);
166 
167  static void writePNG(const vpImage<unsigned char> &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND);
168  static void writePNG(const vpImage<vpRGBa> &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND);
169 };
170 #endif
Use embedded simd library.
Definition: vpImageIo.h:131
Use system libraries like libpng or libjpeg.
Definition: vpImageIo.h:129
vpImageIoBackendType
Image IO backend for only jpeg and png formats image loading and saving.
Definition: vpImageIo.h:127
Read/write images with various image format.
Definition: vpImageIo.h:104