39#include <visp3/core/vpIoTools.h>
40#include <visp3/io/vpImageIo.h>
42#include "private/vpImageIoBackend.h"
44#ifdef ENABLE_VISP_NAMESPACE
48vpImageIo::vpImageFormatType vpImageIo::getFormat(
const std::string &filename)
52 if (ext.find(
"pgm") != std::string::npos)
54 else if (ext.find(
"ppm") != std::string::npos)
56 else if (ext.find(
"jpg") != std::string::npos)
58 else if (ext.find(
"jpeg") != std::string::npos)
60 else if (ext.find(
"png") != std::string::npos)
63 else if (ext.find(
"tiff") != std::string::npos)
65 else if (ext.find(
"tif") != std::string::npos)
67 else if (ext.find(
"bmp") != std::string::npos)
69 else if (ext.find(
"dib") != std::string::npos)
71 else if (ext.find(
"pbm") != std::string::npos)
73 else if (ext.find(
"sr") != std::string::npos)
75 else if (ext.find(
"ras") != std::string::npos)
77 else if (ext.find(
"jp2") != std::string::npos)
78 return FORMAT_JPEG2000;
79 else if (ext.find(
"exr") != std::string::npos)
81 else if (ext.find(
"pfm") != std::string::npos)
84 return FORMAT_UNKNOWN;
120 const std::string message =
"Cannot read file: \"" + std::string(filename) +
"\" doesn't exist";
127 bool try_opencv_reader =
false;
129 switch (getFormat(final_filename)) {
137 readJPEG(I, final_filename, backend);
140 readPNG(I, final_filename, backend);
147 case FORMAT_JPEG2000:
149 try_opencv_reader =
true;
156 if (try_opencv_reader) {
157#if defined(VISP_HAVE_OPENCV) && \
158 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
159 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
160 readOpenCV(I, filename);
162 const std::string message =
"Cannot read file \"" + filename +
"\": No backend able to support this image format";
201 const std::string message =
"Cannot read file: \"" + std::string(filename) +
"\" doesn't exist";
207 bool try_opencv_reader =
false;
209 switch (getFormat(final_filename)) {
217 readJPEG(I, final_filename, backend);
220 readPNG(I, final_filename, backend);
227 case FORMAT_JPEG2000:
229 try_opencv_reader =
true;
235 if (try_opencv_reader) {
236#if defined(VISP_HAVE_OPENCV) && \
237 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
238 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
239 readOpenCV(I, filename);
241 const std::string message =
"Cannot read file \"" + filename +
"\": No backend able to support this image format";
270 const std::string message =
"Cannot read file: \"" + std::string(filename) +
"\" doesn't exist";
277 bool try_opencv_reader =
false;
279 switch (getFormat(final_filename)) {
281#ifdef VISP_HAVE_OPENCV
282 try_opencv_reader =
true;
284#if defined(VISP_HAVE_TINYEXR)
285 readEXRTiny(I, filename);
296 try_opencv_reader =
true;
302 if (try_opencv_reader) {
303#if defined(VISP_HAVE_OPENCV) && \
304 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
305 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
306 readOpenCV(I, filename);
308 const std::string message =
"Cannot read file \"" + filename +
"\": No backend able to support this image format";
338 bool try_opencv_writer =
false;
340 switch (getFormat(filename)) {
358 case FORMAT_JPEG2000:
361 try_opencv_writer =
true;
365 if (try_opencv_writer) {
366#if defined(VISP_HAVE_OPENCV) && \
367 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
368 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
369 writeOpenCV(I, filename, 90);
371 const std::string message =
"Cannot write file \"" + filename +
"\": No backend able to support this image format";
401 bool try_opencv_writer =
false;
403 switch (getFormat(filename)) {
421 case FORMAT_JPEG2000:
424 try_opencv_writer =
true;
428 if (try_opencv_writer) {
429#if defined(VISP_HAVE_OPENCV) && \
430 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
431 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
432 writeOpenCV(I, filename, 90);
434 const std::string message =
"Cannot write file \"" + filename +
"\": No backend able to support this image format";
453#if !defined(VISP_HAVE_JPEG)
459#if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
465#if defined(VISP_HAVE_OPENCV) && \
466 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
467 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
469#elif defined(VISP_HAVE_JPEG)
471#elif defined(VISP_HAVE_SIMDLIB)
473#elif defined(VISP_HAVE_STBIMAGE)
478 const std::string message =
"Cannot read file \"" + filename +
"\": no backend available";
484#if defined(VISP_HAVE_JPEG)
485 readJPEGLibjpeg(I, filename);
489 const std::string message =
"Cannot read file \"" + filename +
"\": jpeg library backend is not available";
494#if defined(VISP_HAVE_OPENCV) && \
495 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
496 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
497 readOpenCV(I, filename);
501 const std::string message =
"Cannot read file \"" + filename +
"\": OpenCV library backend is not available";
506#if defined(VISP_HAVE_STBIMAGE)
507 readStb(I, filename);
511 const std::string message =
"Cannot read file \"" + filename +
"\": stb_image backend is not available";
516#if defined(VISP_HAVE_SIMDLIB)
517 readSimdlib(I, filename);
521 const std::string message =
"Cannot read file \"" + filename +
"\": Simd library backend is not available";
540#if !defined(VISP_HAVE_JPEG)
546#if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
552#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS)
554#elif defined(VISP_HAVE_JPEG)
556#elif defined(VISP_HAVE_SIMDLIB)
558#elif defined(VISP_HAVE_STBIMAGE)
563 const std::string message =
"Cannot read file \"" + filename +
"\": no backend available";
569#if defined(VISP_HAVE_JPEG)
570 readJPEGLibjpeg(I, filename);
574 const std::string message =
"Cannot read file \"" + filename +
"\": jpeg library backend is not available";
579#if defined(VISP_HAVE_OPENCV) && \
580 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
581 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
582 readOpenCV(I, filename);
586 const std::string message =
"Cannot read file \"" + filename +
"\": OpenCV library backend is not available";
591#if defined(VISP_HAVE_STBIMAGE)
592 readStb(I, filename);
596 const std::string message =
"Cannot read file \"" + filename +
"\": stb_image backend is not available";
601#if defined(VISP_HAVE_SIMDLIB)
602 readSimdlib(I, filename);
606 const std::string message =
"Cannot read file \"" + filename +
"\": Simd library backend is not available";
625#if !defined(VISP_HAVE_PNG)
631#if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
637#if defined(VISP_HAVE_PNG)
639#elif defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS)
641#elif defined(VISP_HAVE_SIMDLIB)
643#elif defined(VISP_HAVE_STBIMAGE)
648 const std::string message =
"Cannot read file \"" + filename +
"\": no backend available";
654#if defined(VISP_HAVE_PNG)
655 readPNGLibpng(I, filename);
659 const std::string message =
"Cannot read file \"" + filename +
"\": png library backend is not available";
664#if defined(VISP_HAVE_OPENCV) && \
665 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
666 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
667 readOpenCV(I, filename);
671 const std::string message =
"Cannot read file \"" + filename +
"\": OpenCV library backend is not available";
676#if defined(VISP_HAVE_STBIMAGE)
677 readStb(I, filename);
681 const std::string message =
"Cannot read file \"" + filename +
"\": stb_image backend is not available";
686#if defined(VISP_HAVE_SIMDLIB)
687 readSimdlib(I, filename);
691 const std::string message =
"Cannot read file \"" + filename +
"\": Simd library backend is not available";
710#if !defined(VISP_HAVE_PNG)
716#if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
722#if defined(VISP_HAVE_OPENCV) && \
723 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
724 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
726#elif defined(VISP_HAVE_SIMDLIB)
728#elif defined(VISP_HAVE_STBIMAGE)
733 const std::string message =
"Cannot read file \"" + filename +
"\": no backend available";
739#if defined(VISP_HAVE_PNG)
740 readPNGLibpng(I, filename);
744 const std::string message =
"Cannot read file \"" + filename +
"\": png library backend is not available";
749#if defined(VISP_HAVE_OPENCV) && \
750 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
751 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
752 readOpenCV(I, filename);
756 const std::string message =
"Cannot read file \"" + filename +
"\": OpenCV library backend is not available";
761#if defined(VISP_HAVE_STBIMAGE)
762 readStb(I, filename);
766 const std::string message =
"Cannot read file \"" + filename +
"\": stb_image backend is not available";
771#if defined(VISP_HAVE_SIMDLIB)
772 readSimdlib(I, filename);
776 const std::string message =
"Cannot read file \"" + filename +
"\": Simd library backend is not available";
797#if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
803#if !defined(VISP_HAVE_TINYEXR)
810#if defined(VISP_HAVE_OPENCV) && \
811 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
812 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
813 readOpenCV(I, filename);
817 const std::string message =
"Cannot read file \"" + filename +
"\": OpenCV backend is not available";
822#if defined(VISP_HAVE_TINYEXR)
823 readEXRTiny(I, filename);
827 const std::string message =
"Cannot read file \"" + filename +
"\": Default TinyEXR backend is not available";
848#if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
854#if !defined(VISP_HAVE_TINYEXR)
861#if defined(VISP_HAVE_OPENCV) && \
862 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
863 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
864 readOpenCV(I, filename);
868 const std::string message =
"Cannot read file \"" + filename +
"\": OpenCV backend is not available";
873#if defined(VISP_HAVE_TINYEXR)
874 readEXRTiny(I, filename);
878 const std::string message =
"Cannot read file \"" + filename +
"\": TinyEXR backend is not available";
898#if !defined(VISP_HAVE_JPEG)
899#if defined(VISP_HAVE_SIMDLIB)
909#if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
910#if defined(VISP_HAVE_SIMDLIB)
920#if defined(VISP_HAVE_JPEG)
922#elif defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS)
924#elif defined(VISP_HAVE_SIMDLIB)
926#elif defined(VISP_HAVE_STBIMAGE)
931 const std::string message =
"Cannot save file \"" + filename +
"\": no available backend";
937#if defined(VISP_HAVE_JPEG)
938 writeJPEGLibjpeg(I, filename, quality);
943 const std::string message =
"Cannot save file \"" + filename +
"\": jpeg backend is not available";
948#if defined(VISP_HAVE_OPENCV) && \
949 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
950 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
951 writeOpenCV(I, filename, quality);
956 const std::string message =
"Cannot save file \"" + filename +
"\": OpenCV backend is not available";
961#if defined(VISP_HAVE_SIMDLIB)
962 writeJPEGSimdlib(I, filename, quality);
967 const std::string message =
"Cannot save file \"" + filename +
"\": Simd library backend is not available";
972#if defined(VISP_HAVE_STBIMAGE)
973 writeJPEGStb(I, filename, quality);
978 const std::string message =
"Cannot save file \"" + filename +
"\": stb_image backend is not available";
998#if !defined(VISP_HAVE_JPEG)
999#if defined(VISP_HAVE_SIMDLIB)
1009#if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
1010#if defined(VISP_HAVE_SIMDLIB)
1020#if defined(VISP_HAVE_JPEG)
1022#elif defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS)
1024#elif defined(VISP_HAVE_SIMDLIB)
1026#elif defined(VISP_HAVE_STBIMAGE)
1031 const std::string message =
"Cannot save file \"" + filename +
"\": no backend available";
1037#if defined(VISP_HAVE_JPEG)
1038 writeJPEGLibjpeg(I, filename, quality);
1043 const std::string message =
"Cannot save file \"" + filename +
"\": jpeg library backend is not available";
1048#if defined(VISP_HAVE_OPENCV) && \
1049 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
1050 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
1051 writeOpenCV(I, filename, quality);
1056 const std::string message =
"Cannot save file \"" + filename +
"\": OpenCV library backend is not available";
1061#if defined(VISP_HAVE_SIMDLIB)
1062 writeJPEGSimdlib(I, filename, quality);
1067 const std::string message =
"Cannot save file \"" + filename +
"\": Simd library backend is not available";
1072#if defined(VISP_HAVE_STBIMAGE)
1073 writeJPEGStb(I, filename, quality);
1078 const std::string message =
"Cannot save file \"" + filename +
"\": stb_image backend is not available";
1097#if !defined(VISP_HAVE_PNG)
1098#if defined(VISP_HAVE_SIMDLIB)
1108#if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
1109#if defined(VISP_HAVE_SIMDLIB)
1119#if defined(VISP_HAVE_OPENCV) && \
1120 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
1121 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
1123#elif defined(VISP_HAVE_SIMDLIB)
1125#elif defined(VISP_HAVE_STBIMAGE)
1130 const std::string message =
"Cannot save file \"" + filename +
"\": no backend available";
1136#if defined(VISP_HAVE_OPENCV) && \
1137 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
1138 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
1139 writeOpenCV(I, filename, 90);
1143 const std::string message =
"Cannot save file \"" + filename +
"\": OpenCV library backend is not available";
1148#if defined(VISP_HAVE_SIMDLIB)
1149 writePNGSimdlib(I, filename);
1153 const std::string message =
"Cannot save file \"" + filename +
"\": Simd library backend is not available";
1158#if defined(VISP_HAVE_STBIMAGE)
1159 writePNGStb(I, filename);
1163 const std::string message =
"Cannot save file \"" + filename +
"\": stb_image backend is not available";
1168#if defined(VISP_HAVE_PNG)
1169 writePNGLibpng(I, filename);
1173 const std::string message =
"Cannot save file \"" + filename +
"\": png library backend is not available";
1192#if !defined(VISP_HAVE_PNG)
1193#if defined(VISP_HAVE_SIMDLIB)
1203#if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
1204#if defined(VISP_HAVE_SIMDLIB)
1214#if defined(VISP_HAVE_OPENCV) && \
1215 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
1216 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
1218#elif defined(VISP_HAVE_SIMDLIB)
1220#elif defined(VISP_HAVE_STBIMAGE)
1225 const std::string message =
"Cannot save file \"" + filename +
"\": no backend available";
1231#if defined(VISP_HAVE_OPENCV) && \
1232 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
1233 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
1234 writeOpenCV(I, filename, 90);
1238 const std::string message =
"Cannot save file \"" + filename +
"\": OpenCV backend is not available";
1243#if defined(VISP_HAVE_SIMDLIB)
1244 writePNGSimdlib(I, filename);
1248 const std::string message =
"Cannot save file \"" + filename +
"\": Simd library backend is not available";
1253#if defined(VISP_HAVE_STBIMAGE)
1254 writePNGStb(I, filename);
1258 const std::string message =
"Cannot save file \"" + filename +
"\": stb_image backend is not available";
1263#if defined(VISP_HAVE_PNG)
1264 writePNGLibpng(I, filename);
1268 const std::string message =
"Cannot save file \"" + filename +
"\": libpng backend is not available";
1289#if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
1296#if !defined(VISP_HAVE_TINYEXR)
1303#if defined(VISP_HAVE_OPENCV) && \
1304 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
1305 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
1306 writeOpenCV(I, filename);
1310 const std::string message =
"Cannot save file \"" + filename +
"\": OpenCV backend is not available";
1315#if defined(VISP_HAVE_TINYEXR)
1316 writeEXRTiny(I, filename);
1320 const std::string message =
"Cannot save file \"" + filename +
"\": TinyEXR backend is not available";
1341#if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
1347#if !defined(VISP_HAVE_TINYEXR)
1354#if defined(VISP_HAVE_OPENCV) && \
1355 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
1356 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
1357 writeOpenCV(I, filename);
1361 const std::string message =
"Cannot save file \"" + filename +
"\": OpenCV backend is not available";
1366#if defined(VISP_HAVE_TINYEXR)
1367 writeEXRTiny(I, filename);
1371 const std::string message =
"Cannot save file \"" + filename +
"\": TinyEXR backend is not available";
1497#if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
1502#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS)
1504#elif defined(VISP_HAVE_STBIMAGE)
1509 const std::string message =
"Cannot in-memory png read: OpenCV or std_image backend are not available";
1515#if defined(VISP_HAVE_OPENCV) && \
1516 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
1517 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
1518 readPNGfromMemOpenCV(buffer, I);
1524 const std::string message =
"Cannot in-memory png read: OpenCV backend is not available";
1529#if defined(VISP_HAVE_STBIMAGE)
1530 readPNGfromMemStb(buffer, I);
1536 const std::string message =
"Cannot in-memory png read: std_image backend is not available";
1555#if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
1560#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS)
1562#elif defined(VISP_HAVE_STBIMAGE)
1567 const std::string message =
"Cannot in-memory png read: OpenCV or std_image backend are not available";
1573#if defined(VISP_HAVE_OPENCV) && \
1574 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
1575 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
1576 readPNGfromMemOpenCV(buffer, I);
1582 const std::string message =
"Cannot in-memory png read: OpenCV backend is not available";
1587#if defined(VISP_HAVE_STBIMAGE)
1588 readPNGfromMemStb(buffer, I);
1594 const std::string message =
"Cannot in-memory png read: std_image backend is not available";
1614#if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
1619#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS)
1621#elif defined(VISP_HAVE_STBIMAGE)
1626 const std::string message =
"Cannot in-memory png write: OpenCV or std_image backend are not available";
1632#if defined(VISP_HAVE_OPENCV) && \
1633 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
1634 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
1635 writePNGtoMemOpenCV(I, buffer);
1639 const std::string message =
"Cannot in-memory png write: OpenCV backend is not available";
1644#if defined(VISP_HAVE_STBIMAGE)
1645 writePNGtoMemStb(I, buffer);
1649 const std::string message =
"Cannot in-memory png write: std_image backend is not available";
1654#if VISP_CXX_STANDARD > VISP_CXX_STANDARD_98
1655 const std::string message =
"The " + std::to_string(backend) +
" backend is not available.";
1678#if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
1683#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS)
1685#elif defined(VISP_HAVE_STBIMAGE)
1690 const std::string message =
"Cannot in-memory png write: OpenCV or std_image backend are not available";
1696#if defined(VISP_HAVE_OPENCV) && \
1697 (((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || \
1698 ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)))
1699 writePNGtoMemOpenCV(I, buffer, saveAlpha);
1703 const std::string message =
"Cannot in-memory png write: OpenCV backend is not available";
1708#if defined(VISP_HAVE_STBIMAGE)
1709 writePNGtoMemStb(I, buffer, saveAlpha);
1713 const std::string message =
"Cannot in-memory png write: std_image backend is not available";
1718#if VISP_CXX_STANDARD > VISP_CXX_STANDARD_98
1719 const std::string message =
"The " + std::to_string(backend) +
" backend is not available.";
error that can be emitted by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
Error that can be emitted by the vpImage class and its derivatives.
static void writePFM(const vpImage< float > &I, const std::string &filename)
static void readPGM(vpImage< unsigned char > &I, const std::string &filename)
@ IO_STB_IMAGE_BACKEND
Use embedded stb_image library.
@ IO_DEFAULT_BACKEND
Default backend.
@ IO_SIMDLIB_BACKEND
Use embedded simd library.
@ IO_SYSTEM_LIB_BACKEND
Use system libraries like libpng or libjpeg-turbo.
@ IO_OPENCV_BACKEND
Use OpenCV imgcodecs module.
static void writeJPEG(const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND, int quality=90)
static void readJPEG(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
static void readPFM(vpImage< float > &I, const std::string &filename)
static void writePNG(const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
static void readPFM_HDR(vpImage< float > &I, const std::string &filename)
static void readPPM(vpImage< unsigned char > &I, const std::string &filename)
static void writePFM_HDR(const vpImage< float > &I, const std::string &filename)
static void readPNGfromMem(const std::vector< unsigned char > &buffer, vpImage< unsigned char > &I, int backend=IO_DEFAULT_BACKEND)
static void readEXR(vpImage< float > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
static void writePGM(const vpImage< unsigned char > &I, const std::string &filename)
static void writeEXR(const vpImage< float > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
static void writePNGtoMem(const vpImage< unsigned char > &I, std::vector< unsigned char > &buffer, int backend=IO_DEFAULT_BACKEND)
static void readPNG(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
static void writePPM(const vpImage< unsigned char > &I, const std::string &filename)
static void write(const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Definition of the vpImage class member functions.