How to delete [ WARN:0] message in python opencv ?

asked 2019-10-07 10:13:25 -0500


I try to open a list of TIFF images with opencv-python (cv2.imread) but there's always an issue with binary images. I have this warning message :

[ WARN:0] global C:\projects\opencv-python\opencv\modules\imgcodecs\src\grfmt_tiff.cpp (271) cv::TiffDecoder::readHeader OpenCV TIFF(line 271): failed TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric) imread_('1729.tif'): can't read header: OpenCV(4.1.1) C:\projects\opencv-python\opencv\modules\imgcodecs\src\grfmt_tiff.cpp:271: error: (-2:Unspecified error) OpenCV TIFF: failed TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric) in function 'cv::TiffDecoder::readHeader'

So, to open these binary images, I use PIL and convert images into numpy arrays. But I test before with opencv and consequently, the warning messages still appear in command line.

How to delete them ? I try to add this line but nothing happens: warnings.filterwarnings("ignore")

edit retag flag offensive close merge delete


this is deep out of libtiff. you can't do anything from opencv, save even python.

berak gravatar imageberak ( 2019-10-07 11:49:48 -0500 )edit