Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpImageIo.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
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 http://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  * Authors:
34  * Eric Marchand
35  *
36  *****************************************************************************/
37 
38 
44 #ifndef vpIMAGEIO_H
45 #define vpIMAGEIO_H
46 
47 #include <visp3/core/vpImage.h>
48 #include <visp3/core/vpDebug.h>
49 #include <visp3/core/vpRGBa.h>
50 #include <visp3/core/vpImageConvert.h>
51 
52 #include <stdio.h>
53 #include <iostream>
54 
55 #if defined(_WIN32)
56 # include <windows.h>
57 #endif
58 
59 #if defined(VISP_HAVE_JPEG)
60 #include <jpeglib.h>
61 #include <jerror.h>
62 #endif
63 
64 #if defined(VISP_HAVE_PNG)
65 #include <png.h>
66 #endif
67 
68 
116 class VISP_EXPORT vpImageIo
117 {
118 
119 private:
120 
121  typedef enum
122  {
123  FORMAT_PGM,
124  FORMAT_PPM,
125  FORMAT_JPEG,
126  FORMAT_PNG,
127  // Formats supported by opencv
128  FORMAT_TIFF,
129  FORMAT_BMP,
130  FORMAT_DIB,
131  FORMAT_PBM,
132  FORMAT_RASTER,
133  FORMAT_JPEG2000,
134  FORMAT_UNKNOWN
135  } vpImageFormatType;
136 
137  static vpImageFormatType getFormat(const std::string &filename) ;
138  static std::string getExtension(const std::string &filename);
139 
140 public:
141 
142  static void read(vpImage<unsigned char> &I, const std::string &filename) ;
143  static void read(vpImage<vpRGBa> &I, const std::string &filename) ;
144 
145  static void write(const vpImage<unsigned char> &I, const std::string &filename) ;
146  static void write(const vpImage<vpRGBa> &I, const std::string &filename) ;
147 
148  static void readPFM(vpImage<float> &I, const std::string &filename) ;
149 
150  static void readPGM(vpImage<unsigned char> &I, const std::string &filename) ;
151  static void readPGM(vpImage<vpRGBa> &I, const std::string &filename) ;
152 
153  static void readPPM(vpImage<unsigned char> &I, const std::string &filename) ;
154  static void readPPM(vpImage<vpRGBa> &I, const std::string &filename) ;
155 
156 #if (defined(VISP_HAVE_JPEG) || defined(VISP_HAVE_OPENCV))
157  static void readJPEG(vpImage<unsigned char> &I, const std::string &filename) ;
158  static void readJPEG(vpImage<vpRGBa> &I, const std::string &filename) ;
159 #endif
160 
161 #if (defined(VISP_HAVE_PNG) || defined(VISP_HAVE_OPENCV))
162  static void readPNG(vpImage<unsigned char> &I, const std::string &filename) ;
163  static void readPNG(vpImage<vpRGBa> &I, const std::string &filename) ;
164 #endif
165 
166  static void writePFM(const vpImage<float> &I, const std::string &filename) ;
167 
168  static void writePGM(const vpImage<unsigned char> &I, const std::string &filename) ;
169  static void writePGM(const vpImage<short> &I, const std::string &filename) ;
170  static void writePGM(const vpImage<vpRGBa> &I, const std::string &filename) ;
171 
172  static void writePPM(const vpImage<unsigned char> &I, const std::string &filename) ;
173  static void writePPM(const vpImage<vpRGBa> &I, const std::string &filename) ;
174 
175 #if (defined(VISP_HAVE_JPEG) || defined(VISP_HAVE_OPENCV))
176  static void writeJPEG(const vpImage<unsigned char> &I, const std::string &filename) ;
177  static void writeJPEG(const vpImage<vpRGBa> &I, const std::string &filename) ;
178 #endif
179 
180 #if (defined(VISP_HAVE_PNG) || defined(VISP_HAVE_OPENCV))
181  static void writePNG(const vpImage<unsigned char> &I, const std::string &filename) ;
182  static void writePNG(const vpImage<vpRGBa> &I, const std::string &filename) ;
183 #endif
184 
185  } ;
186 #endif
187 
Read/write images with various image format.
Definition: vpImageIo.h:116