OpenCV 3.4.3 imread not able to load tiff image

asked 2018-10-16 13:04:55 -0500

Sintun gravatar 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);
  if(! img.data)
  {
    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

/modules/imgcodecs/test/

and started

./opencv_test_imgcodecs

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

  Platform:
    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

  C/C++:
    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 ...
(more)
edit retag flag offensive close merge delete

Comments

Did you try building tiff instead of using your existing tiff lib during building opencv? In CMake there are options 'BUILD_TIFF' and 'WITH_TIFF'.

yancey gravatar imageyancey ( 2018-10-18 11:43:26 -0500 )edit

Thx, i will try that on the weekend.

Sintun gravatar imageSintun ( 2018-11-02 09:37:43 -0500 )edit