Visual Servoing Platform  version 3.6.1 under development (2024-12-17)
vpImageIoBackend.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  * Backend functions implementation for image I/O operations.
32  */
33 
39 #ifndef _vpImageIoBackend_h_
40 #define _vpImageIoBackend_h_
41 
42 #include <visp3/core/vpImage.h>
43 
44 BEGIN_VISP_NAMESPACE
45 
46 // Portable FloatMap format (PFM)
47 // Portable Graymap format (PGM)
48 // Portable Pixmap format (PPM)
49 void vp_writePFM(const vpImage<float> &I, const std::string &filename);
50 void vp_writePFM_HDR(const vpImage<float> &I, const std::string &filename);
51 void vp_writePFM_HDR(const vpImage<vpRGBf> &I, const std::string &filename);
52 void vp_writePGM(const vpImage<unsigned char> &I, const std::string &filename);
53 void vp_writePGM(const vpImage<short> &I, const std::string &filename);
54 void vp_writePGM(const vpImage<vpRGBa> &I, const std::string &filename);
55 void vp_readPFM(vpImage<float> &I, const std::string &filename);
56 void vp_readPFM_HDR(vpImage<float> &I, const std::string &filename);
57 void vp_readPFM_HDR(vpImage<vpRGBf> &I, const std::string &filename);
58 void vp_readPGM(vpImage<unsigned char> &I, const std::string &filename);
59 void vp_readPGM(vpImage<vpRGBa> &I, const std::string &filename);
60 void vp_readPPM(vpImage<unsigned char> &I, const std::string &filename);
61 void vp_readPPM(vpImage<vpRGBa> &I, const std::string &filename);
62 void vp_writePPM(const vpImage<unsigned char> &I, const std::string &filename);
63 void vp_writePPM(const vpImage<vpRGBa> &I, const std::string &filename);
64 
65 // libjpeg
66 void readJPEGLibjpeg(vpImage<unsigned char> &I, const std::string &filename);
67 void readJPEGLibjpeg(vpImage<vpRGBa> &I, const std::string &filename);
68 
69 void writeJPEGLibjpeg(const vpImage<unsigned char> &I, const std::string &filename, int quality);
70 void writeJPEGLibjpeg(const vpImage<vpRGBa> &I, const std::string &filename, int quality);
71 
72 // libpng
73 void readPNGLibpng(vpImage<unsigned char> &I, const std::string &filename);
74 void readPNGLibpng(vpImage<vpRGBa> &I, const std::string &filename);
75 
76 void writePNGLibpng(const vpImage<unsigned char> &I, const std::string &filename);
77 void writePNGLibpng(const vpImage<vpRGBa> &I, const std::string &filename);
78 
79 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) \
80  && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
81 // OpenCV
82 void readOpenCV(vpImage<unsigned char> &I, const std::string &filename);
83 void readOpenCV(vpImage<vpRGBa> &I, const std::string &filename);
84 void readOpenCV(vpImage<float> &I, const std::string &filename);
85 void readOpenCV(vpImage<vpRGBf> &I, const std::string &filename);
86 
87 void writeOpenCV(const vpImage<unsigned char> &I, const std::string &filename, int quality);
88 void writeOpenCV(const vpImage<vpRGBa> &I, const std::string &filename, int quality);
89 void writeOpenCV(const vpImage<float> &I, const std::string &filename);
90 void writeOpenCV(const vpImage<vpRGBf> &I, const std::string &filename);
91 
92 void readPNGfromMemOpenCV(const std::vector<unsigned char> &buffer, vpImage<unsigned char> &I);
93 void readPNGfromMemOpenCV(const std::vector<unsigned char> &buffer, vpImage<vpRGBa> &I);
94 
95 void writePNGtoMemOpenCV(const vpImage<unsigned char> &I, std::vector<unsigned char> &buffer);
96 void writePNGtoMemOpenCV(const vpImage<vpRGBa> &I, std::vector<unsigned char> &buffer, bool saveAlpha);
97 #endif
98 
99 #if defined(VISP_HAVE_SIMDLIB)
100 // Simd lib
101 void readSimdlib(vpImage<unsigned char> &I, const std::string &filename);
102 void readSimdlib(vpImage<vpRGBa> &I, const std::string &filename);
103 
104 void writeJPEGSimdlib(const vpImage<unsigned char> &I, const std::string &filename, int quality);
105 void writeJPEGSimdlib(const vpImage<vpRGBa> &I, const std::string &filename, int quality);
106 
107 void writePNGSimdlib(const vpImage<unsigned char> &I, const std::string &filename);
108 void writePNGSimdlib(const vpImage<vpRGBa> &I, const std::string &filename);
109 #endif
110 
111 #if defined(VISP_HAVE_TINYEXR)
112 // TinyEXR lib
113 void readEXRTiny(vpImage<float> &I, const std::string &filename);
114 void readEXRTiny(vpImage<vpRGBf> &I, const std::string &filename);
115 
116 void writeEXRTiny(const vpImage<float> &I, const std::string &filename);
117 void writeEXRTiny(const vpImage<vpRGBf> &I, const std::string &filename);
118 #endif
119 
120 #if defined(VISP_HAVE_STBIMAGE)
121 // stb_image lib
122 void readStb(vpImage<unsigned char> &I, const std::string &filename);
123 void readStb(vpImage<vpRGBa> &I, const std::string &filename);
124 
125 void writeJPEGStb(const vpImage<unsigned char> &I, const std::string &filename, int quality);
126 void writeJPEGStb(const vpImage<vpRGBa> &I, const std::string &filename, int quality);
127 
128 void writePNGStb(const vpImage<unsigned char> &I, const std::string &filename);
129 void writePNGStb(const vpImage<vpRGBa> &I, const std::string &filename);
130 
131 void readPNGfromMemStb(const std::vector<unsigned char> &buffer, vpImage<unsigned char> &I);
132 void readPNGfromMemStb(const std::vector<unsigned char> &buffer, vpImage<vpRGBa> &I);
133 
134 void writePNGtoMemStb(const vpImage<unsigned char> &I, std::vector<unsigned char> &buffer);
135 void writePNGtoMemStb(const vpImage<vpRGBa> &I, std::vector<unsigned char> &buffer, bool saveAlpha);
136 #endif
137 
138 END_VISP_NAMESPACE
139 
140 #endif