39 #include <visp3/core/vpIoTools.h>
40 #include <visp3/io/vpImageIo.h>
42 #include "private/vpImageIoBackend.h"
44 vpImageIo::vpImageFormatType vpImageIo::getFormat(
const std::string &filename)
46 std::string ext = vpImageIo::getExtension(filename);
48 if (ext.compare(
".PGM") == 0)
50 else if (ext.compare(
".pgm") == 0)
52 else if (ext.compare(
".PPM") == 0)
54 else if (ext.compare(
".ppm") == 0)
56 else if (ext.compare(
".JPG") == 0)
58 else if (ext.compare(
".jpg") == 0)
60 else if (ext.compare(
".JPEG") == 0)
62 else if (ext.compare(
".jpeg") == 0)
64 else if (ext.compare(
".PNG") == 0)
66 else if (ext.compare(
".png") == 0)
69 else if (ext.compare(
".TIFF") == 0)
71 else if (ext.compare(
".tiff") == 0)
73 else if (ext.compare(
".TIF") == 0)
75 else if (ext.compare(
".tif") == 0)
77 else if (ext.compare(
".BMP") == 0)
79 else if (ext.compare(
".bmp") == 0)
81 else if (ext.compare(
".DIB") == 0)
83 else if (ext.compare(
".dib") == 0)
85 else if (ext.compare(
".PBM") == 0)
87 else if (ext.compare(
".pbm") == 0)
89 else if (ext.compare(
".SR") == 0)
91 else if (ext.compare(
".sr") == 0)
93 else if (ext.compare(
".RAS") == 0)
95 else if (ext.compare(
".ras") == 0)
97 else if (ext.compare(
".JP2") == 0)
98 return FORMAT_JPEG2000;
99 else if (ext.compare(
".jp2") == 0)
100 return FORMAT_JPEG2000;
102 return FORMAT_UNKNOWN;
106 std::string vpImageIo::getExtension(
const std::string &filename)
109 size_t dot = filename.find_last_of(
".");
110 std::string ext = filename.substr(dot, filename.size() - 1);
147 const std::string message =
"Cannot read file: \"" + std::string(filename) +
"\" doesn't exist";
154 bool try_opencv_reader =
false;
156 switch (getFormat(final_filename)) {
164 readJPEG(I, final_filename, backend);
167 readPNG(I, final_filename, backend);
174 case FORMAT_JPEG2000:
176 try_opencv_reader =
true;
180 if (try_opencv_reader) {
181 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
182 readOpenCV(I, filename);
184 const std::string message =
"Cannot read file \"" + filename +
"\": No backend able to support this image format";
223 const std::string message =
"Cannot read file: \"" + std::string(filename) +
"\" doesn't exist";
229 bool try_opencv_reader =
false;
231 switch (getFormat(final_filename)) {
239 readJPEG(I, final_filename, backend);
242 readPNG(I, final_filename, backend);
249 case FORMAT_JPEG2000:
251 try_opencv_reader =
true;
255 if (try_opencv_reader) {
256 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
257 readOpenCV(I, filename);
259 const std::string message =
"Cannot read file \"" + filename +
"\": No backend able to support this image format";
289 bool try_opencv_writer =
false;
291 switch (getFormat(filename)) {
309 case FORMAT_JPEG2000:
311 try_opencv_writer =
true;
315 if (try_opencv_writer) {
316 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
317 writeOpenCV(I, filename, 90);
319 const std::string message =
"Cannot write file \"" + filename +
"\": No backend able to support this image format";
349 bool try_opencv_writer =
false;
351 switch (getFormat(filename)) {
369 case FORMAT_JPEG2000:
371 try_opencv_writer =
true;
375 if (try_opencv_writer) {
376 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
377 writeOpenCV(I, filename, 90);
379 const std::string message =
"Cannot write file \"" + filename +
"\": No backend able to support this image format";
398 #if !defined(VISP_HAVE_JPEG)
404 #if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
410 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
412 #elif defined(VISP_HAVE_JPEG)
414 #elif defined(VISP_HAVE_SIMDLIB)
416 #elif defined(VISP_HAVE_STBIMAGE)
421 const std::string message =
"Cannot read file \"" + filename +
"\": no backend available";
427 #if defined(VISP_HAVE_JPEG)
428 readJPEGLibjpeg(I, filename);
432 const std::string message =
"Cannot read file \"" + filename +
"\": jpeg library backend is not available";
437 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
438 readOpenCV(I, filename);
442 const std::string message =
"Cannot read file \"" + filename +
"\": OpenCV library backend is not available";
447 #if defined(VISP_HAVE_STBIMAGE)
448 readStb(I, filename);
452 const std::string message =
"Cannot read file \"" + filename +
"\": stb_image backend is not available";
457 #if defined(VISP_HAVE_SIMDLIB)
458 readSimdlib(I, filename);
462 const std::string message =
"Cannot read file \"" + filename +
"\": Simd library backend is not available";
481 #if !defined(VISP_HAVE_JPEG)
487 #if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
493 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS)
495 #elif defined(VISP_HAVE_JPEG)
497 #elif defined(VISP_HAVE_SIMDLIB)
499 #elif defined(VISP_HAVE_STBIMAGE)
504 const std::string message =
"Cannot read file \"" + filename +
"\": no backend available";
510 #if defined(VISP_HAVE_JPEG)
511 readJPEGLibjpeg(I, filename);
515 const std::string message =
"Cannot read file \"" + filename +
"\": jpeg library backend is not available";
520 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
521 readOpenCV(I, filename);
525 const std::string message =
"Cannot read file \"" + filename +
"\": OpenCV library backend is not available";
530 #if defined(VISP_HAVE_STBIMAGE)
531 readStb(I, filename);
535 const std::string message =
"Cannot read file \"" + filename +
"\": stb_image backend is not available";
540 #if defined(VISP_HAVE_SIMDLIB)
541 readSimdlib(I, filename);
545 const std::string message =
"Cannot read file \"" + filename +
"\": Simd library backend is not available";
564 #if !defined(VISP_HAVE_PNG)
570 #if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
576 #if defined(VISP_HAVE_PNG)
578 #elif defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS)
580 #elif defined(VISP_HAVE_SIMDLIB)
582 #elif defined(VISP_HAVE_STBIMAGE)
587 const std::string message =
"Cannot read file \"" + filename +
"\": no backend available";
593 #if defined(VISP_HAVE_PNG)
594 readPNGLibpng(I, filename);
598 const std::string message =
"Cannot read file \"" + filename +
"\": png library backend is not available";
603 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
604 readOpenCV(I, filename);
608 const std::string message =
"Cannot read file \"" + filename +
"\": OpenCV library backend is not available";
613 #if defined(VISP_HAVE_STBIMAGE)
614 readStb(I, filename);
618 const std::string message =
"Cannot read file \"" + filename +
"\": stb_image backend is not available";
623 #if defined(VISP_HAVE_SIMDLIB)
624 readSimdlib(I, filename);
628 const std::string message =
"Cannot read file \"" + filename +
"\": Simd library backend is not available";
647 #if !defined(VISP_HAVE_PNG)
653 #if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
659 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
661 #elif defined(VISP_HAVE_SIMDLIB)
663 #elif defined(VISP_HAVE_STBIMAGE)
668 const std::string message =
"Cannot read file \"" + filename +
"\": no backend available";
674 #if defined(VISP_HAVE_PNG)
675 readPNGLibpng(I, filename);
679 const std::string message =
"Cannot read file \"" + filename +
"\": png library backend is not available";
684 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
685 readOpenCV(I, filename);
689 const std::string message =
"Cannot read file \"" + filename +
"\": OpenCV library backend is not available";
694 #if defined(VISP_HAVE_STBIMAGE)
695 readStb(I, filename);
699 const std::string message =
"Cannot read file \"" + filename +
"\": stb_image backend is not available";
704 #if defined(VISP_HAVE_SIMDLIB)
705 readSimdlib(I, filename);
709 const std::string message =
"Cannot read file \"" + filename +
"\": Simd library backend is not available";
730 #if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
736 #if !defined(VISP_HAVE_TINYEXR)
743 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
744 readOpenCV(I, filename);
748 const std::string message =
"Cannot read file \"" + filename +
"\": OpenCV backend is not available";
753 #if defined(VISP_HAVE_TINYEXR)
754 readEXRTiny(I, filename);
758 const std::string message =
"Cannot read file \"" + filename +
"\": Default TinyEXR backend is not available";
779 #if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
785 #if !defined(VISP_HAVE_TINYEXR)
792 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
793 readOpenCV(I, filename);
797 const std::string message =
"Cannot read file \"" + filename +
"\": OpenCV backend is not available";
802 #if defined(VISP_HAVE_TINYEXR)
803 readEXRTiny(I, filename);
807 const std::string message =
"Cannot read file \"" + filename +
"\": TinyEXR backend is not available";
827 #if !defined(VISP_HAVE_JPEG)
828 #if defined(VISP_HAVE_SIMDLIB)
838 #if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
839 #if defined(VISP_HAVE_SIMDLIB)
849 #if defined(VISP_HAVE_JPEG)
851 #elif defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS)
853 #elif defined(VISP_HAVE_SIMDLIB)
855 #elif defined(VISP_HAVE_STBIMAGE)
860 const std::string message =
"Cannot save file \"" + filename +
"\": no available backend";
866 #if defined(VISP_HAVE_JPEG)
867 writeJPEGLibjpeg(I, filename, quality);
872 const std::string message =
"Cannot save file \"" + filename +
"\": jpeg backend is not available";
877 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) \
878 && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
879 writeOpenCV(I, filename, quality);
884 const std::string message =
"Cannot save file \"" + filename +
"\": OpenCV backend is not available";
889 #if defined(VISP_HAVE_SIMDLIB)
890 writeJPEGSimdlib(I, filename, quality);
895 const std::string message =
"Cannot save file \"" + filename +
"\": Simd library backend is not available";
900 #if defined(VISP_HAVE_STBIMAGE)
901 writeJPEGStb(I, filename, quality);
906 const std::string message =
"Cannot save file \"" + filename +
"\": stb_image backend is not available";
926 #if !defined(VISP_HAVE_JPEG)
927 #if defined(VISP_HAVE_SIMDLIB)
937 #if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
938 #if defined(VISP_HAVE_SIMDLIB)
948 #if defined(VISP_HAVE_JPEG)
950 #elif defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS)
952 #elif defined(VISP_HAVE_SIMDLIB)
954 #elif defined(VISP_HAVE_STBIMAGE)
959 const std::string message =
"Cannot save file \"" + filename +
"\": no backend available";
965 #if defined(VISP_HAVE_JPEG)
966 writeJPEGLibjpeg(I, filename, quality);
971 const std::string message =
"Cannot save file \"" + filename +
"\": jpeg library backend is not available";
976 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
977 writeOpenCV(I, filename, quality);
982 const std::string message =
"Cannot save file \"" + filename +
"\": OpenCV library backend is not available";
987 #if defined(VISP_HAVE_SIMDLIB)
988 writeJPEGSimdlib(I, filename, quality);
993 const std::string message =
"Cannot save file \"" + filename +
"\": Simd library backend is not available";
998 #if defined(VISP_HAVE_STBIMAGE)
999 writeJPEGStb(I, filename, quality);
1004 const std::string message =
"Cannot save file \"" + filename +
"\": stb_image backend is not available";
1023 #if !defined(VISP_HAVE_PNG)
1024 #if defined(VISP_HAVE_SIMDLIB)
1034 #if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
1035 #if defined(VISP_HAVE_SIMDLIB)
1045 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
1047 #elif defined(VISP_HAVE_SIMDLIB)
1049 #elif defined(VISP_HAVE_STBIMAGE)
1054 const std::string message =
"Cannot save file \"" + filename +
"\": no backend available";
1060 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
1061 writeOpenCV(I, filename, 90);
1065 const std::string message =
"Cannot save file \"" + filename +
"\": OpenCV library backend is not available";
1070 #if defined(VISP_HAVE_SIMDLIB)
1071 writePNGSimdlib(I, filename);
1075 const std::string message =
"Cannot save file \"" + filename +
"\": Simd library backend is not available";
1080 #if defined(VISP_HAVE_STBIMAGE)
1081 writePNGStb(I, filename);
1085 const std::string message =
"Cannot save file \"" + filename +
"\": stb_image backend is not available";
1090 #if defined(VISP_HAVE_PNG)
1091 writePNGLibpng(I, filename);
1095 const std::string message =
"Cannot save file \"" + filename +
"\": png library backend is not available";
1114 #if !defined(VISP_HAVE_PNG)
1115 #if defined(VISP_HAVE_SIMDLIB)
1125 #if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
1126 #if defined(VISP_HAVE_SIMDLIB)
1136 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
1138 #elif defined(VISP_HAVE_SIMDLIB)
1140 #elif defined(VISP_HAVE_STBIMAGE)
1145 const std::string message =
"Cannot save file \"" + filename +
"\": no backend available";
1151 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
1152 writeOpenCV(I, filename, 90);
1156 const std::string message =
"Cannot save file \"" + filename +
"\": OpenCV backend is not available";
1161 #if defined(VISP_HAVE_SIMDLIB)
1162 writePNGSimdlib(I, filename);
1166 const std::string message =
"Cannot save file \"" + filename +
"\": Simd library backend is not available";
1171 #if defined(VISP_HAVE_STBIMAGE)
1172 writePNGStb(I, filename);
1176 const std::string message =
"Cannot save file \"" + filename +
"\": stb_image backend is not available";
1181 #if defined(VISP_HAVE_PNG)
1182 writePNGLibpng(I, filename);
1186 const std::string message =
"Cannot save file \"" + filename +
"\": libpng backend is not available";
1207 #if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
1214 #if !defined(VISP_HAVE_TINYEXR)
1221 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
1222 writeOpenCV(I, filename);
1226 const std::string message =
"Cannot save file \"" + filename +
"\": OpenCV backend is not available";
1231 #if defined(VISP_HAVE_TINYEXR)
1232 writeEXRTiny(I, filename);
1236 const std::string message =
"Cannot save file \"" + filename +
"\": TinyEXR backend is not available";
1257 #if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
1263 #if !defined(VISP_HAVE_TINYEXR)
1270 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
1271 writeOpenCV(I, filename);
1275 const std::string message =
"Cannot save file \"" + filename +
"\": OpenCV backend is not available";
1280 #if defined(VISP_HAVE_TINYEXR)
1281 writeEXRTiny(I, filename);
1285 const std::string message =
"Cannot save file \"" + filename +
"\": TinyEXR backend is not available";
1411 #if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
1416 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS)
1418 #elif defined(VISP_HAVE_STBIMAGE)
1423 const std::string message =
"Cannot in-memory png read: OpenCV or std_image backend are not available";
1429 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) \
1430 && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
1431 readPNGfromMemOpenCV(buffer, I);
1437 const std::string message =
"Cannot in-memory png read: OpenCV backend is not available";
1442 #if defined(VISP_HAVE_STBIMAGE)
1443 readPNGfromMemStb(buffer, I);
1449 const std::string message =
"Cannot in-memory png read: std_image backend is not available";
1468 #if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
1473 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS)
1475 #elif defined(VISP_HAVE_STBIMAGE)
1480 const std::string message =
"Cannot in-memory png read: OpenCV or std_image backend are not available";
1486 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) \
1487 && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
1488 readPNGfromMemOpenCV(buffer, I);
1494 const std::string message =
"Cannot in-memory png read: OpenCV backend is not available";
1499 #if defined(VISP_HAVE_STBIMAGE)
1500 readPNGfromMemStb(buffer, I);
1506 const std::string message =
"Cannot in-memory png read: std_image backend is not available";
1526 #if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
1531 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS)
1533 #elif defined(VISP_HAVE_STBIMAGE)
1538 const std::string message =
"Cannot in-memory png write: OpenCV or std_image backend are not available";
1544 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) \
1545 && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
1546 writePNGtoMemOpenCV(I, buffer);
1550 const std::string message =
"Cannot in-memory png write: OpenCV backend is not available";
1555 #if defined(VISP_HAVE_STBIMAGE)
1556 writePNGtoMemStb(I, buffer);
1560 const std::string message =
"Cannot in-memory png write: std_image backend is not available";
1565 #if VISP_CXX_STANDARD > VISP_CXX_STANDARD_98
1566 const std::string message =
"The " + std::to_string(backend) +
" backend is not available.";
1589 #if !(defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS))
1594 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS)
1596 #elif defined(VISP_HAVE_STBIMAGE)
1601 const std::string message =
"Cannot in-memory png write: OpenCV or std_image backend are not available";
1607 #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) \
1608 && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC))
1609 writePNGtoMemOpenCV(I, buffer, saveAlpha);
1613 const std::string message =
"Cannot in-memory png write: OpenCV backend is not available";
1618 #if defined(VISP_HAVE_STBIMAGE)
1619 writePNGtoMemStb(I, buffer, saveAlpha);
1623 const std::string message =
"Cannot in-memory png write: std_image backend is not available";
1628 #if VISP_CXX_STANDARD > VISP_CXX_STANDARD_98
1629 const std::string message =
"The " + std::to_string(backend) +
" backend is not available.";
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)