Visual Servoing Platform  version 3.2.1 under development (2019-07-16)
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 
107 private:
108  typedef enum {
109  FORMAT_PGM,
110  FORMAT_PPM,
111  FORMAT_JPEG,
112  FORMAT_PNG,
113  // Formats supported by opencv
114  FORMAT_TIFF,
115  FORMAT_BMP,
116  FORMAT_DIB,
117  FORMAT_PBM,
118  FORMAT_RASTER,
119  FORMAT_JPEG2000,
120  FORMAT_UNKNOWN
121  } vpImageFormatType;
122 
123  static vpImageFormatType getFormat(const std::string &filename);
124  static std::string getExtension(const std::string &filename);
125 
126 public:
127  static void read(vpImage<unsigned char> &I, const std::string &filename);
128  static void read(vpImage<vpRGBa> &I, const std::string &filename);
129 
130  static void write(const vpImage<unsigned char> &I, const std::string &filename);
131  static void write(const vpImage<vpRGBa> &I, const std::string &filename);
132 
133  static void readPFM(vpImage<float> &I, const std::string &filename);
134 
135  static void readPGM(vpImage<unsigned char> &I, const std::string &filename);
136  static void readPGM(vpImage<vpRGBa> &I, const std::string &filename);
137 
138  static void readPPM(vpImage<unsigned char> &I, const std::string &filename);
139  static void readPPM(vpImage<vpRGBa> &I, const std::string &filename);
140 
141  static void readJPEG(vpImage<unsigned char> &I, const std::string &filename);
142  static void readJPEG(vpImage<vpRGBa> &I, const std::string &filename);
143 
144  static void readPNG(vpImage<unsigned char> &I, const std::string &filename);
145  static void readPNG(vpImage<vpRGBa> &I, const std::string &filename);
146 
147  static void writePFM(const vpImage<float> &I, const std::string &filename);
148 
149  static void writePGM(const vpImage<unsigned char> &I, const std::string &filename);
150  static void writePGM(const vpImage<short> &I, const std::string &filename);
151  static void writePGM(const vpImage<vpRGBa> &I, const std::string &filename);
152 
153  static void writePPM(const vpImage<unsigned char> &I, const std::string &filename);
154  static void writePPM(const vpImage<vpRGBa> &I, const std::string &filename);
155 
156  static void writeJPEG(const vpImage<unsigned char> &I, const std::string &filename);
157  static void writeJPEG(const vpImage<vpRGBa> &I, const std::string &filename);
158 
159  static void writePNG(const vpImage<unsigned char> &I, const std::string &filename);
160  static void writePNG(const vpImage<vpRGBa> &I, const std::string &filename);
161 };
162 #endif
Read/write images with various image format.
Definition: vpImageIo.h:104