Ask Your Question

Revision history [back]

OpenCV 3.4.3 imread not able to load tiff image

Hey there,

I just compiled OpenCV 3.4.3 on Kubuntu 18.04, which worked like a charm.

Unfortunately I am not able to load a tif file. The minimal example

#include <iostream>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
using namespace std;
using namespace cv;
int main(int argc, char** argv)
  if(argc < 2)
    cout<<"usage: "<<argv[0]<<" [options] imageFileIn "<<endl;
    return 1;
  const char* input_filepath  = argv[1];
  Mat img = imread(input_filepath);
    cerr << "Could not load image file \""<<input_filepath<<"\"."<<endl;
    return 1;
  return 0;

always returns "Could not load... ", jpeg or png files are not affected.

My question: can anyone replicate this problem -- or is there an obvious mistake ? I also tried to build the unittests in


and started


which resulted into

[----------] 6 tests from Imgcodecs_Tiff
[ RUN      ] Imgcodecs_Tiff.decode_tile16384x16384
[       OK ] Imgcodecs_Tiff.decode_tile16384x16384 (4584 ms)
[ RUN      ] Imgcodecs_Tiff.write_read_16bit_big_little_endian
[       OK ] Imgcodecs_Tiff.write_read_16bit_big_little_endian (0 ms)
[ RUN      ] Imgcodecs_Tiff.decode_tile_remainder
/home/stefan/clibs/src/opencv-3.4.3/modules/imgcodecs/test/test_tiff.cpp:107: Failure
Value of: img.empty()
  Actual: true
Expected: false
[  FAILED  ] Imgcodecs_Tiff.decode_tile_remainder (0 ms)
[ RUN      ] Imgcodecs_Tiff.decode_infinite_rowsperstrip
[       OK ] Imgcodecs_Tiff.decode_infinite_rowsperstrip (1 ms)
[ RUN      ] Imgcodecs_Tiff.readWrite_32FC1
/home/stefan/clibs/src/opencv-3.4.3/modules/imgcodecs/test/test_tiff.cpp:156: Failure
Value of: img.empty()
  Actual: true
Expected: false
[  FAILED  ] Imgcodecs_Tiff.readWrite_32FC1 (0 ms)
[ RUN      ] Imgcodecs_Tiff.imdecode_no_exception_temporary_file_removed
/home/stefan/clibs/src/opencv-3.4.3/modules/imgcodecs/test/test_tiff.cpp:248: Failure
Value of: img.empty()
  Actual: true
Expected: false
[  FAILED  ] Imgcodecs_Tiff.imdecode_no_exception_temporary_file_removed (0 ms)
[----------] 6 tests from Imgcodecs_Tiff (4585 ms total)

[----------] 1 test from Imgcodecs_Tiff_Modes
[ RUN      ] Imgcodecs_Tiff_Modes.write_multipage
Speicherzugriffsfehler (Speicherabzug geschrieben)

An example image is C:\fakepath\loremA.tiff

The output of my cv::getBuildInformation() is

General configuration for OpenCV 3.4.3 =====================================
  Version control:               unknown

  Extra modules:
    Location (extra):            /home/stefan/clibs/src/opencv_contrib-3.4.3/modules
    Version control (extra):     unknown

    Timestamp:                   2018-10-16T16:05:05Z
    Host:                        Linux 4.15.0-36-generic x86_64
    CMake:                       3.10.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3
      requested:                 SSE3
    Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_1 (5 files):          + SSSE3 SSE4_1
      SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (2 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (6 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (11 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
      AVX512_SKX (1 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_SKX

    Built as dynamic libs?:      YES
    C++11:                       YES
    C++ Compiler:                /usr/bin/c++  (ver 7.3.0)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wimplicit-fallthrough=3 -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wimplicit-fallthrough=3 -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      
    Linker flags (Debug):        
    ccache:                      YES
    Precompiled headers:         NO
    Extra dependencies:          dl m pthread rt
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dpm face features2d flann freetype fuzzy hdf hfs highgui img_hash imgcodecs imgproc java_bindings_generator line_descriptor ml objdetect optflow phase_unwrapping photo plot python_bindings_generator reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab world xfeatures2d ximgproc xobjdetect xphoto
    Disabled:                    js
    Disabled by dependency:      -
    Unavailable:                 cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv java matlab ovis python2 python3 viz
    Applications:                tests perf_tests apps
    Documentation:               NO
    Non-free algorithms:         NO

    GTK+:                        YES (ver 3.22.30)
      GThread :                  YES (ver 2.56.2)
      GtkGlExt:                  NO
    VTK support:                 NO

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/ (ver 1.2.11)
    JPEG:                        /usr/lib/x86_64-linux-gnu/ (ver 80)
    WEBP:                        /usr/lib/x86_64-linux-gnu/ (ver encoder: 0x020e)
    PNG:                         /usr/lib/x86_64-linux-gnu/ (ver 1.6.34)
    TIFF:                        /usr/lib/x86_64-linux-gnu/ (ver 42 / 4.0.9)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ (ver 2.2.0)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES

  Video I/O:
    DC1394:                      NO
    FFMPEG:                      YES
      avcodec:                   YES (ver 57.107.100)
      avformat:                  YES (ver 57.83.100)
      avutil:                    YES (ver 55.78.100)
      swscale:                   YES (ver 4.8.100)
      avresample:                YES (ver 3.7.0)
    GStreamer:                   NO
    libv4l/libv4l2:              NO
    v4l/v4l2:                    linux/videodev2.h

  Parallel framework:            pthreads

  Trace:                         YES (with Intel ITT)

  Other third-party libraries:
    Intel IPP:                   2017.0.3 [2017.0.3]
           at:                   /home/stefan/clibs/src/opencv-3.4.3/build/3rdparty/ippicv/ippicv_lnx
    Intel IPP IW:                sources (2017.0.3)
              at:                /home/stefan/clibs/src/opencv-3.4.3/build/3rdparty/ippicv/ippiw_lnx
    Lapack:                      NO
    Eigen:                       YES (ver 3.3.4)
    Custom HAL:                  NO
    Protobuf:                    build (3.5.1)

  Python (for build):            /usr/bin/python2.7

    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Matlab:                        NO

  Install to:                    /home/stefan/clibs/opencv_unstable