Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpImageIoPortable.cpp
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 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 for portable image format I/O operations.
32 */
33
38
39#include "vpImageIoBackend.h"
40#include <visp3/core/vpImageConvert.h>
41#include <visp3/core/vpIoTools.h>
42#include <visp3/core/vpEndian.h>
43
45
46#ifndef DOXYGEN_SHOULD_SKIP_THIS
47
48
49void vp_decodeHeaderPNM(const std::string &filename, std::ifstream &fd, const std::string &magic, unsigned int &w,
50 unsigned int &h, unsigned int &maxval);
51void vp_decodeHeaderPFM(const std::string &filename, std::ifstream &fd, std::string &magic, unsigned int &w,
52 unsigned int &h, double &scale, bool &littleEndian);
53
63void vp_decodeHeaderPNM(const std::string &filename, std::ifstream &fd, const std::string &magic, unsigned int &w,
64 unsigned int &h, unsigned int &maxval)
65{
66 std::string line;
67 unsigned int nb_elt = 4, cpt_elt = 0;
68 while (cpt_elt != nb_elt) {
69 // Skip empty lines or lines starting with # (comment)
70 while (std::getline(fd, line) && (line.compare(0, 1, "#") == 0 || line.size() == 0)) {
71 }
72
73 if (fd.eof()) {
74 fd.close();
75 throw(vpImageException(vpImageException::ioError, "Cannot read header of file \"%s\"", filename.c_str()));
76 }
77
78 std::vector<std::string> header = vpIoTools::splitChain(line, std::string(" "));
79
80 if (header.size() == 0) {
81 fd.close();
82 throw(vpImageException(vpImageException::ioError, "Cannot read header of file \"%s\"", filename.c_str()));
83 }
84
85 if (cpt_elt == 0) { // decode magic
86 if (header[0].compare(0, magic.size(), magic) != 0) {
87 fd.close();
88 throw(vpImageException(vpImageException::ioError, "\"%s\" is not a PNM file with magic number %s",
89 filename.c_str(), magic.c_str()));
90 }
91 ++cpt_elt;
92 header.erase(header.begin(),
93 header.begin() + 1); // erase first element that is processed
94 }
95 while (header.size()) {
96 if (cpt_elt == 1) { // decode width
97 std::istringstream ss(header[0]);
98 ss >> w;
99 ++cpt_elt;
100 header.erase(header.begin(),
101 header.begin() + 1); // erase first element that is processed
102 }
103 else if (cpt_elt == 2) { // decode height
104 std::istringstream ss(header[0]);
105 ss >> h;
106 ++cpt_elt;
107 header.erase(header.begin(),
108 header.begin() + 1); // erase first element that is processed
109 }
110 else if (cpt_elt == 3) { // decode maxval
111 std::istringstream ss(header[0]);
112 ss >> maxval;
113 ++cpt_elt;
114 header.erase(header.begin(),
115 header.begin() + 1); // erase first element that is processed
116 }
117 }
118 }
119}
120
121void vp_decodeHeaderPFM(const std::string &filename, std::ifstream &fd, std::string &magic, unsigned int &w,
122 unsigned int &h, double &scale, bool &littleEndian)
123{
124 std::string line;
125 const unsigned int nb_elt = 4;
126 unsigned int cpt_elt = 0;
127 while (cpt_elt != nb_elt) {
128 // Skip empty lines or lines starting with # (comment)
129 while (std::getline(fd, line) && (line.compare(0, 1, "#") == 0 || line.size() == 0)) {
130 }
131
132 if (fd.eof()) {
133 fd.close();
134 throw(vpImageException(vpImageException::ioError, "Cannot read header of file \"%s\"", filename.c_str()));
135 }
136
137 std::vector<std::string> header = vpIoTools::splitChain(line, std::string(" "));
138
139 if (header.empty()) {
140 fd.close();
141 throw(vpImageException(vpImageException::ioError, "Cannot read header of file \"%s\"", filename.c_str()));
142 }
143
144 if (cpt_elt == 0) { // decode magic
145 magic = header[0];
146 if (magic != "PF" && magic != "Pf") {
147 fd.close();
149 "\"%s\" is not a PFM file with PF (RGB) or Pf (gray) magic number", filename.c_str()));
150 }
151 ++cpt_elt;
152 header.erase(header.begin(),
153 header.begin() + 1); // erase first element that is processed
154 }
155 while (header.size()) {
156 if (cpt_elt == 1) { // decode width
157 std::istringstream ss(header[0]);
158 ss >> w;
159 ++cpt_elt;
160 header.erase(header.begin(),
161 header.begin() + 1); // erase first element that is processed
162 }
163 else if (cpt_elt == 2) { // decode height
164 std::istringstream ss(header[0]);
165 ss >> h;
166 ++cpt_elt;
167 header.erase(header.begin(),
168 header.begin() + 1); // erase first element that is processed
169 }
170 else if (cpt_elt == 3) { // decode byte order
171 std::istringstream ss(header[0]);
172 ss >> scale;
173 littleEndian = scale < 0;
174 ++cpt_elt;
175 header.erase(header.begin(),
176 header.begin() + 1); // erase first element that is processed
177 }
178 }
179 }
180}
181#endif
182
183//--------------------------------------------------------------------------
184// PFM
185//--------------------------------------------------------------------------
186
195void vp_writePFM(const vpImage<float> &I, const std::string &filename)
196{
197 FILE *fd;
198
199 // Test the filename
200 if (filename.empty()) {
201 throw(vpImageException(vpImageException::ioError, "Cannot write PFM image: filename empty"));
202 }
203
204 fd = fopen(filename.c_str(), "wb");
205
206 if (fd == nullptr) {
207 throw(vpImageException(vpImageException::ioError, "Cannot create PFM file \"%s\"", filename.c_str()));
208 }
209
210 // Write the head
211 fprintf(fd, "P8\n"); // Magic number
212 fprintf(fd, "%u %u\n", I.getWidth(), I.getHeight()); // Image size
213 fprintf(fd, "255\n"); // Max level
214
215 // Write the bitmap
216 size_t ierr;
217 size_t nbyte = I.getWidth() * I.getHeight();
218
219 ierr = fwrite(I.bitmap, sizeof(float), nbyte, fd);
220 if (ierr != nbyte) {
221 fclose(fd);
222 throw(vpImageException(vpImageException::ioError, "Cannot save PFM file \"%s\": only %d bytes over %d saved ",
223 filename.c_str(), ierr, nbyte));
224 }
225
226 fflush(fd);
227 fclose(fd);
228}
229
230void vp_writePFM_HDR(const vpImage<float> &I, const std::string &filename)
231{
232 // Test the filename
233 if (filename.empty()) {
234 throw(vpImageException(vpImageException::ioError, "Cannot write PFM image: filename empty"));
235 }
236
237 FILE *fd = fopen(filename.c_str(), "wb");
238 if (fd == nullptr) {
239 throw(vpImageException(vpImageException::ioError, "Cannot create PFM file \"%s\"", filename.c_str()));
240 }
241
242 // Write the head
243 fprintf(fd, "Pf\n"); // Magic number
244 fprintf(fd, "%u %u\n", I.getWidth(), I.getHeight()); // Image size
245#ifdef VISP_LITTLE_ENDIAN
246 fprintf(fd, "%f\n", -1.0f); // Byte order
247#else
248 fprintf(fd, "%f\n", 1.0f); // Byte order
249#endif
250
251 // Write the bitmap
252 size_t nbyte = I.getWidth();
253 for (int i = static_cast<int>(I.getHeight()) - 1; i >= 0; i--) {
254 size_t ierr = fwrite(I[i], sizeof(float), nbyte, fd);
255 if (ierr != nbyte) {
256 fclose(fd);
257 throw(vpImageException(vpImageException::ioError, "Cannot save PFM file \"%s\": only %d bytes over %d saved ",
258 filename.c_str(), ierr, nbyte));
259 }
260 }
261
262 fflush(fd);
263 fclose(fd);
264}
265
266void vp_writePFM_HDR(const vpImage<vpRGBf> &I, const std::string &filename)
267{
268 // Test the filename
269 if (filename.empty()) {
270 throw(vpImageException(vpImageException::ioError, "Cannot write PFM image: filename empty"));
271 }
272
273 FILE *fd = fopen(filename.c_str(), "wb");
274 if (fd == nullptr) {
275 throw(vpImageException(vpImageException::ioError, "Cannot create PFM file \"%s\"", filename.c_str()));
276 }
277
278 // Write the head
279 fprintf(fd, "PF\n"); // Magic number
280 fprintf(fd, "%u %u\n", I.getWidth(), I.getHeight()); // Image size
281#ifdef VISP_LITTLE_ENDIAN
282 fprintf(fd, "%f\n", -1.0f); // Byte order
283#else
284 fprintf(fd, "%f\n", 1.0f); // Byte order
285#endif
286
287 // Write the bitmap
288 size_t nbyte = I.getWidth() * 3;
289 for (int i = static_cast<int>(I.getHeight()) - 1; i >= 0; i--) {
290 size_t ierr = fwrite(I[i], sizeof(float), nbyte, fd);
291 if (ierr != nbyte) {
292 fclose(fd);
293 throw(vpImageException(vpImageException::ioError, "Cannot save PFM file \"%s\": only %d bytes over %d saved ",
294 filename.c_str(), ierr, nbyte));
295 }
296 }
297
298 fflush(fd);
299 fclose(fd);
300}
301
302//--------------------------------------------------------------------------
303// PGM
304//--------------------------------------------------------------------------
305
313void vp_writePGM(const vpImage<unsigned char> &I, const std::string &filename)
314{
315 FILE *fd;
316
317 // Test the filename
318 if (filename.empty()) {
319 throw(vpImageException(vpImageException::ioError, "Cannot create PGM file: filename empty"));
320 }
321
322 fd = fopen(filename.c_str(), "wb");
323
324 if (fd == nullptr) {
325 throw(vpImageException(vpImageException::ioError, "Cannot create PGM file \"%s\"", filename.c_str()));
326 }
327
328 // Write the head
329 fprintf(fd, "P5\n"); // Magic number
330 fprintf(fd, "%u %u\n", I.getWidth(), I.getHeight()); // Image size
331 fprintf(fd, "255\n"); // Max level
332
333 // Write the bitmap
334 size_t ierr;
335 size_t nbyte = I.getWidth() * I.getHeight();
336
337 ierr = fwrite(I.bitmap, sizeof(unsigned char), nbyte, fd);
338 if (ierr != nbyte) {
339 fclose(fd);
340 throw(vpImageException(vpImageException::ioError, "Cannot save PGM file \"%s\": only %d over %d bytes saved",
341 filename.c_str(), ierr, nbyte));
342 }
343
344 fflush(fd);
345 fclose(fd);
346}
347
355void vp_writePGM(const vpImage<short> &I, const std::string &filename)
356{
358 unsigned int nrows = I.getHeight();
359 unsigned int ncols = I.getWidth();
360
361 Iuc.resize(nrows, ncols);
362
363 for (unsigned int i = 0; i < nrows * ncols; ++i)
364 Iuc.bitmap[i] = (unsigned char)I.bitmap[i];
365
366 vp_writePGM(Iuc, filename);
367}
368
377void vp_writePGM(const vpImage<vpRGBa> &I, const std::string &filename)
378{
379
380 FILE *fd;
381
382 // Test the filename
383 if (filename.empty()) {
384 throw(vpImageException(vpImageException::ioError, "Cannot create PGM file: filename empty"));
385 }
386
387 fd = fopen(filename.c_str(), "wb");
388
389 if (fd == nullptr) {
390 throw(vpImageException(vpImageException::ioError, "Cannot create PGM file \"%s\"", filename.c_str()));
391 }
392
393 // Write the head
394 fprintf(fd, "P5\n"); // Magic number
395 fprintf(fd, "%u %u\n", I.getWidth(), I.getHeight()); // Image size
396 fprintf(fd, "255\n"); // Max level
397
398 // Write the bitmap
399 size_t ierr;
400 size_t nbyte = I.getWidth() * I.getHeight();
401
404
405 ierr = fwrite(Itmp.bitmap, sizeof(unsigned char), nbyte, fd);
406 if (ierr != nbyte) {
407 fclose(fd);
408 throw(vpImageException(vpImageException::ioError, "Cannot save PGM file \"%s\": only %d over %d bytes saved",
409 filename.c_str(), ierr, nbyte));
410 }
411
412 fflush(fd);
413 fclose(fd);
414}
415
430void vp_readPFM(vpImage<float> &I, const std::string &filename)
431{
432 unsigned int w = 0, h = 0, maxval = 0;
433 const unsigned int w_max = 100000, h_max = 100000, maxval_max = 255;
434 const std::string magic("P8");
435
436 std::ifstream fd(filename.c_str(), std::ios::binary);
437
438 // Open the filename
439 if (!fd.is_open()) {
440 throw(vpImageException(vpImageException::ioError, "Cannot open file \"%s\"", filename.c_str()));
441 }
442
443 vp_decodeHeaderPNM(filename, fd, magic, w, h, maxval);
444
445 if (w > w_max || h > h_max) {
446 fd.close();
447 throw(vpException(vpException::badValue, "Bad image size in \"%s\"", filename.c_str()));
448 }
449 if (maxval > maxval_max) {
450 fd.close();
451 throw(vpImageException(vpImageException::ioError, "Bad maxval in \"%s\"", filename.c_str()));
452 }
453
454 if ((h != I.getHeight()) || (w != I.getWidth())) {
455 I.resize(h, w);
456 }
457
458 unsigned int nbyte = I.getHeight() * I.getWidth();
459 fd.read((char *)I.bitmap, sizeof(float) * nbyte);
460 if (!fd) {
461 fd.close();
462 throw(vpImageException(vpImageException::ioError, "Read only %d of %d bytes in file \"%s\"", fd.gcount(), nbyte,
463 filename.c_str()));
464 }
465
466 fd.close();
467}
468
484void vp_readPFM_HDR(vpImage<float> &I, const std::string &filename)
485{
486 std::ifstream fd(filename.c_str(), std::ios::binary);
487
488 // Open the filename
489 if (!fd.is_open()) {
490 throw(vpImageException(vpImageException::ioError, "Cannot open file \"%s\"", filename.c_str()));
491 }
492
493 const unsigned int w_max = 100000, h_max = 100000;
494 const std::string magicRGB("PF"), magicGray("Pf");
495 std::string magic;
496 unsigned int w = 0, h = 0;
497 double scale = 1;
498 bool littleEndian = true;
499 vp_decodeHeaderPFM(filename, fd, magic, w, h, scale, littleEndian);
500
501 if (w > w_max || h > h_max) {
502 fd.close();
503 throw(vpException(vpException::badValue, "Bad image size in \"%s\"", filename.c_str()));
504 }
505
506 unsigned int channels = (magic == magicRGB) ? 3 : 1;
507 if (h != I.getHeight() || channels * w != I.getWidth()) {
508 I.resize(h, channels * w);
509 }
510
511#ifdef VISP_LITTLE_ENDIAN
512 bool swapEndianness = !littleEndian;
513#else
514 bool swapEndianness = littleEndian;
515#endif
516 for (int i = I.getHeight() - 1; i >= 0; i--) {
517 fd.read((char *)I[i], sizeof(float) * w * channels);
518 if (swapEndianness) {
519 for (unsigned int j = 0; j < w * channels; ++j) {
520 I[i][j] = vpEndian::swapFloat(I[i][j]);
521 }
522 }
523 }
524
525 if (!fd) {
526 fd.close();
527 throw(vpImageException(vpImageException::ioError, "Read only %d bytes in file \"%s\"", fd.gcount(),
528 filename.c_str()));
529 }
530 fd.close();
531
532 if (std::fabs(scale) > 0.0f) {
533 for (unsigned int i = 0; i < I.getHeight(); ++i) {
534 for (unsigned int j = 0; j < I.getWidth(); ++j) {
535 I[i][j] *= 1.0f / static_cast<float>(std::fabs(scale));
536 }
537 }
538 }
539}
540
556void vp_readPFM_HDR(vpImage<vpRGBf> &I, const std::string &filename)
557{
558 std::ifstream fd(filename.c_str(), std::ios::binary);
559
560 // Open the filename
561 if (!fd.is_open()) {
562 throw(vpImageException(vpImageException::ioError, "Cannot open file \"%s\"", filename.c_str()));
563 }
564
565 const unsigned int w_max = 100000, h_max = 100000;
566 const std::string magicRGB("PF"), magicGray("Pf");
567 std::string magic;
568 unsigned int w = 0, h = 0;
569 double scale = 1;
570 bool littleEndian = true;
571 vp_decodeHeaderPFM(filename, fd, magic, w, h, scale, littleEndian);
572
573 if (w > w_max || h > h_max) {
574 fd.close();
575 throw(vpException(vpException::badValue, "Bad image size in \"%s\"", filename.c_str()));
576 }
577
578 unsigned int channels = (magic == magicRGB) ? 3 : 1;
579 if (magic != magicRGB) {
580 throw(vpImageException(vpImageException::ioError, "Image \"%s\" is not an RGB image!", filename.c_str()));
581 }
582 if (h != I.getHeight() || w != I.getWidth()) {
583 I.resize(h, w);
584 }
585
586#ifdef VISP_LITTLE_ENDIAN
587 bool swapEndianness = !littleEndian;
588#else
589 bool swapEndianness = littleEndian;
590#endif
591 for (int i = I.getHeight() - 1; i >= 0; i--) {
592 fd.read((char *)I[i], sizeof(float) * w * channels);
593 if (swapEndianness) {
594 for (unsigned int j = 0; j < w; ++j) {
595 I[i][j].R = vpEndian::swapFloat(I[i][j].R);
596 I[i][j].G = vpEndian::swapFloat(I[i][j].G);
597 I[i][j].B = vpEndian::swapFloat(I[i][j].B);
598 }
599 }
600 }
601
602 if (!fd) {
603 fd.close();
604 throw(vpImageException(vpImageException::ioError, "Read only %d bytes in file \"%s\"", fd.gcount(),
605 filename.c_str()));
606 }
607 fd.close();
608
609 if (std::fabs(scale) > 0.0f) {
610 for (unsigned int i = 0; i < I.getHeight(); ++i) {
611 for (unsigned int j = 0; j < I.getWidth(); ++j) {
612 I[i][j].R *= 1.0f / static_cast<float>(std::fabs(scale));
613 I[i][j].G *= 1.0f / static_cast<float>(std::fabs(scale));
614 I[i][j].B *= 1.0f / static_cast<float>(std::fabs(scale));
615 }
616 }
617 }
618}
619
634void vp_readPGM(vpImage<unsigned char> &I, const std::string &filename)
635{
636 unsigned int w = 0, h = 0, maxval = 0;
637 unsigned int w_max = 100000, h_max = 100000, maxval_max = 255;
638 std::string magic("P5");
639
640 std::ifstream fd(filename.c_str(), std::ios::binary);
641
642 // Open the filename
643 if (!fd.is_open()) {
644 throw(vpImageException(vpImageException::ioError, "Cannot open file \"%s\"", filename.c_str()));
645 }
646
647 vp_decodeHeaderPNM(filename, fd, magic, w, h, maxval);
648
649 if (w > w_max || h > h_max) {
650 fd.close();
651 throw(vpException(vpException::badValue, "Bad image size in \"%s\"", filename.c_str()));
652 }
653 if (maxval > maxval_max) {
654 fd.close();
655 throw(vpImageException(vpImageException::ioError, "Bad maxval in \"%s\"", filename.c_str()));
656 }
657
658 if ((h != I.getHeight()) || (w != I.getWidth())) {
659 I.resize(h, w);
660 }
661
662 unsigned int nbyte = I.getHeight() * I.getWidth();
663 fd.read((char *)I.bitmap, nbyte);
664 if (!fd) {
665 fd.close();
666 throw(vpImageException(vpImageException::ioError, "Read only %d of %d bytes in file \"%s\"", fd.gcount(), nbyte,
667 filename.c_str()));
668 }
669
670 fd.close();
671}
672
690void vp_readPGM(vpImage<vpRGBa> &I, const std::string &filename)
691{
693
694 vp_readPGM(Itmp, filename);
695
697}
698
699//--------------------------------------------------------------------------
700// PPM
701//--------------------------------------------------------------------------
702
718void vp_readPPM(vpImage<unsigned char> &I, const std::string &filename)
719{
720 vpImage<vpRGBa> Itmp;
721
722 vp_readPPM(Itmp, filename);
723
725}
726
738void vp_readPPM(vpImage<vpRGBa> &I, const std::string &filename)
739{
740 unsigned int w = 0, h = 0, maxval = 0;
741 unsigned int w_max = 100000, h_max = 100000, maxval_max = 255;
742 std::string magic("P6");
743
744 std::ifstream fd(filename.c_str(), std::ios::binary);
745
746 // Open the filename
747 if (!fd.is_open()) {
748 throw(vpImageException(vpImageException::ioError, "Cannot open file \"%s\"", filename.c_str()));
749 }
750
751 vp_decodeHeaderPNM(filename, fd, magic, w, h, maxval);
752
753 if (w > w_max || h > h_max) {
754 fd.close();
755 throw(vpException(vpException::badValue, "Bad image size in \"%s\"", filename.c_str()));
756 }
757 if (maxval > maxval_max) {
758 fd.close();
759 throw(vpImageException(vpImageException::ioError, "Bad maxval in \"%s\"", filename.c_str()));
760 }
761
762 if ((h != I.getHeight()) || (w != I.getWidth())) {
763 I.resize(h, w);
764 }
765
766 for (unsigned int i = 0; i < I.getHeight(); ++i) {
767 for (unsigned int j = 0; j < I.getWidth(); ++j) {
768 unsigned char rgb[3];
769 fd.read((char *)&rgb, 3);
770
771 if (!fd) {
772 fd.close();
773 throw(vpImageException(vpImageException::ioError, "Read only %d of %d bytes in file \"%s\"",
774 (i * I.getWidth() + j) * 3 + fd.gcount(), I.getSize() * 3, filename.c_str()));
775 }
776
777 I[i][j].R = rgb[0];
778 I[i][j].G = rgb[1];
779 I[i][j].B = rgb[2];
780 I[i][j].A = vpRGBa::alpha_default;
781 }
782 }
783
784 fd.close();
785}
786
795void vp_writePPM(const vpImage<unsigned char> &I, const std::string &filename)
796{
797 vpImage<vpRGBa> Itmp;
798
800
801 vp_writePPM(Itmp, filename);
802}
803
811void vp_writePPM(const vpImage<vpRGBa> &I, const std::string &filename)
812{
813 FILE *f;
814
815 // Test the filename
816 if (filename.empty()) {
817 throw(vpImageException(vpImageException::ioError, "Cannot create PPM file: filename empty"));
818 }
819
820 f = fopen(filename.c_str(), "wb");
821
822 if (f == nullptr) {
823 throw(vpImageException(vpImageException::ioError, "Cannot create PPM file \"%s\"", filename.c_str()));
824 }
825
826 fprintf(f, "P6\n"); // Magic number
827 fprintf(f, "%u %u\n", I.getWidth(), I.getHeight()); // Image size
828 fprintf(f, "%d\n", 255); // Max level
829
830 for (unsigned int i = 0; i < I.getHeight(); ++i) {
831 for (unsigned int j = 0; j < I.getWidth(); ++j) {
832 vpRGBa v = I[i][j];
833 unsigned char rgb[3];
834 rgb[0] = v.R;
835 rgb[1] = v.G;
836 rgb[2] = v.B;
837
838 size_t res = fwrite(&rgb, 1, 3, f);
839 if (res != 3) {
840 fclose(f);
841 throw(vpImageException(vpImageException::ioError, "cannot write file \"%s\"", filename.c_str()));
842 }
843 }
844 }
845
846 fflush(f);
847 fclose(f);
848}
849
850END_VISP_NAMESPACE
error that can be emitted by ViSP classes.
Definition vpException.h:60
@ badValue
Used to indicate that a value is not in the allowed range.
Definition vpException.h:73
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Error that can be emitted by the vpImage class and its derivatives.
@ ioError
Image io error.
Definition of the vpImage class member functions.
Definition vpImage.h:131
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
Definition vpImage.h:544
Type * bitmap
points toward the bitmap
Definition vpImage.h:135
unsigned int getHeight() const
Definition vpImage.h:181
static std::vector< std::string > splitChain(const std::string &chain, const std::string &sep)
@ alpha_default
Definition vpRGBa.h:76
VISP_EXPORT float swapFloat(float f)
Definition vpEndian.cpp:104