Problem with grfmt_tiff.cpp

asked 2020-02-27 03:11:45 -0600

NL37 gravatar image

updated 2020-10-24 04:04:01 -0600

Hello,

Actually, I need to save .tiff without any compression. For that, I installed libtiff, and to save without compression. The idea of my code is :

#include "libtiff/tiff.h
... 
std::vector<int> tags = {TIFFTAG_COMPRESSION, COMPRESSION_NONE};
cv::Mat Image_Process = cv::Mat::zeros(height, width, CV_32FC1);
...
code and operation on Image_Process *
...
cv::imwrite(path, Image_Process, tags);

The code worked. I launch the program to write 150 images. At the 80th images, the following message appears :

TIFFAppendToStrip . Write error at scanline 652
[ WARN:0 ] global /home[...]/grfmt_tiff.cpp (954) writeLibTiff OpenCV TIFF (line  954): failed TIFFWriteScanline/tiff, buffer, y, 0) == 1
TIFFWriteDirectoryTagData: IO error writing tag data.
imwrite_(path): can´t write data : OpenCV(4.1.1) /home[...]/grfmt_tiff.cpp :954: error: (-2:Unspecified error) OpenCV TIFF: failed TIFFWriteScanline(tiff, buffer, y, 0)==1 in function 'writeLibTiff'
path: Error writing TIFF header

How can I solve that problem ? My code worked perfectly .. Moreother, I can save .tiff with an other exteension (CV_8UC1). Thank you ! Regards

edit retag flag offensive close merge delete

Comments

1

iirc, tiff cannot write CV_32FC1 images

berak gravatar imageberak ( 2020-02-27 04:42:58 -0600 )edit

I need some explanations, because it worked ... And I tried to change the path, and it works again. So apparently, tiff can write CV_32FC1.

Assuming that tiff cannot write CV_32FC1, is there an alternative ?

Thank you

NL37 gravatar imageNL37 ( 2020-02-27 04:52:12 -0600 )edit