Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Reading 8-bit JPEG in OpenCV

I have 8-bit colorful JPEG image that Windows Image Viewer can show it correctly. I tried to read it from OpenCV but it failed (returns empty cv::Mat). This is the reading code:

auto img= cv::imread("c:/1.jpg"); // I tried also with cv::IMREAD_ANYDEPTH
//img.empty() == true
cv::imshow("img", img);
cv::waitKey();

JPEG file properties:

enter image description here

What did I miss?

Edit (Build Info):

General configuration for OpenCV 3.1.0 =====================================
  Version control:               1.4.79-1573-gc6780c3-dirty

  Platform:
    Host:                        Windows 10.0.10586 AMD64
    CMake:                       3.4.2
    CMake generator:             Visual Studio 12 2013 Win64
    CMake build tool:            C:/Program Files (x86)/MSBuild/12.0/bin/MSBuild.exe
    MSVC:                        1800

  C/C++:
    Built as dynamic libs?:      NO
    C++ Compiler:                C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/x86_amd64/cl.exe  (ver 18.0.40629.0)
    C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /wd4251 /wd4324 /wd4275 /wd4589 /MP8  /MD /O2 /Ob2 /D NDEBUG  /Zi
    C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /wd4251 /wd4324 /wd4275 /wd4589 /MP8  /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
    C Compiler:                  C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/x86_amd64/cl.exe
    C flags (Release):           /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi    /MP8  /MD /O2 /Ob2 /D NDEBUG  /Zi
    C flags (Debug):             /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi    /MP8  /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
    Linker flags (Release):      /machine:x64  /INCREMENTAL:NO  /debug
    Linker flags (Debug):        /machine:x64  /debug /INCREMENTAL
    Precompiled headers:         YES
    Extra dependencies:          comctl32 gdi32 ole32 setupapi ws2_32 ZLIB::zlib JPEG::jpeg PNG::png vfw32
    3rdparty dependencies:       libwebp libjasper IlmImf libprotobuf ippicv

  OpenCV modules:
    To be built:                 core flann imgproc ml photo reg surface_matching video dnn fuzzy imgcodecs shape videoio highgui objdetect plot superres xobjdetect xphoto bgsegm bioinspired dpm face features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo structured_light tracking videostab xfeatures2d ximgproc aruco optflow stitching
    Disabled:                    java world contrib_world
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev python2 python3 ts viz cvv hdf matlab sfm

  Windows RT support:            NO

  GUI:
    QT:                          NO
    Win32 UI:                    YES
    OpenGL support:              NO
    VTK support:                 NO

  Media I/O:
    ZLib:                        ZLIB::zlib (ver 1.2.8)
    JPEG:                        JPEG::jpeg (ver 90)
    WEBP:                        build (ver 0.3.1)
    PNG:                         PNG::png (ver ..)
    TIFF:                        NO
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)
    GDAL:                        NO

  Video I/O:
    Video for Windows:           YES
    DC1394 1.x:                  NO
    DC1394 2.x:                  NO
    FFMPEG:                      NO
      codec:                     NO
      format:                    NO
      util:                      NO
      swscale:                   NO
      resample:                  NO
      gentoo-style:              NO
    GStreamer:                   NO
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    OpenNI2:                     NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    DirectShow:                  YES
    Media Foundation:            NO
    XIMEA:                       NO
    Intel PerC:                  NO

  Parallel framework:            Concurrency

  Other third-party libraries:
    Use IPP:                     9.0.1 [9.0.1]
         at:                     D:/hunter/_Base/xxxxxxx/1fbd0c5/1378dcd/Build/OpenCV/Source/3rdparty/ippicv/unpack/ippicv_win
    Use IPP Async:               NO
    Use Eigen:                   YES (ver 3.2.4)
    Use Cuda:                    NO
    Use OpenCL:                  NO
    Use custom HAL:              NO

  Python 2:
    Interpreter:                 C:/Python27/python.exe (ver 2.7.13)

  Python 3:
    Interpreter:                 C:/Users/h.helfawi/AppData/Local/Programs/Python/Python36/python.exe (ver 3.6)

  Python (for build):            C:/Python27/python.exe

  Java:
    ant:                         C:/NVPACK/apache-ant-1.8.2/bin/ant.bat (ver 1.8.2)
    JNI:                         C:/NVPACK/jdk1.8.0_77/include C:/NVPACK/jdk1.8.0_77/include/win32 C:/NVPACK/jdk1.8.0_77/include
    Java wrappers:               NO
    Java tests:                  NO

  Matlab:                        Matlab not found or implicitly disabled

  Tests and samples:
    Tests:                       NO
    Performance tests:           NO
    C/C++ Examples:              NO

  Install path:                  D:/xxxxx

  cvconfig.h is in:              D:/xxxxx

The image:

This is the image I am trying to open (I could not upload it as image to preserve the meta information) https://drive.google.com/open?id=0B2CEZBv6I5szWkhnQVFYS29ZdWc