Ask Your Question
0

Reading 8-bit JPEG in OpenCV [closed]

asked 2017-02-07 07:46:52 -0600

Humam Helfawi gravatar image

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 ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by berak
close date 2017-02-08 00:53:04.343781

Comments

3

if i try to download it, i get a .gif ?

(well, that would explain, why imread() does not like it)

berak gravatar imageberak ( 2017-02-07 08:35:14 -0600 )edit

You should download it via the download button not saving it as image.. I have just tried to download it and I got JPEG file with 8 bit depth

Humam Helfawi gravatar imageHumam Helfawi ( 2017-02-07 11:54:53 -0600 )edit
1

Why do you mean by "I have got a jpeg" ? I have download it I have got a jpg extension but when I open file using notepad++ file begin is :

GIF89aÄLp  !ù
LBerger gravatar imageLBerger ( 2017-02-07 12:02:31 -0600 )edit
1

if you're on linux, try a :

head -c 100 imagefile.whatever

again, work hypothesis is: this is not a jpg file, but a mislabelled gif

( also see magic )

berak gravatar imageberak ( 2017-02-07 12:44:11 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2017-02-08 00:33:46 -0600

Humam Helfawi gravatar image

Thank you very much. Yes you are totally right it a GIF not a JPEG and that is why I am getting problem.. Thanks again

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-02-07 07:46:52 -0600

Seen: 485 times

Last updated: Feb 07 '17