tags:

views:

1522

answers:

3

I am trying to load a JPEG image using the cvLoadImage function and it fails. I get the output "image not loaded" (see the code below). However a window appears but no picture. When trying to load png pictures the cvLoadImage operation is successful, i.e. the picture is presented in a window. Is there a package that I might be missing or what am I doing wrong?

I am using openCV on Ubuntu.

IplImage* img = NULL;

if( argc > 1 )
    img = cvLoadImage(argv[1], 1);

if(img == 0)
    printf("image not loaded \n")
+1  A: 

Jpeg's load fine under OpenCv, I just checked it. Check to see that you got

  1. the path correct
  2. that the image you are loading is actually jpeg (or some kind of format actually supported by opencv.)
ldog
A: 

Actually the path is correct. I do not know if it is the way that I am building OpenCV that is incorrect:

General configuration ================================================

CXX:                      g++
CXXCPP:                   g++ -E
CPPFLAGS:                 
CXXFLAGS:                 
LDFLAGS:                  

Install path:             /usr/local

Debug flags                
Optimization flags        -DNDEBUG -O3 -g -march=pentium4 -ffast-math -fomit-frame-pointer
MMX/SSE/SSE2/SSE3:         -mmmx -msse -msse2 -msse3
OpenMP support:           -fopenmp
External BLAS & LAPACK:   no

HighGUI configuration ================================================

Windowing system --------------
Use Carbon / Mac OS X:    no
Use gtk+ 2.x:             yes
Use gthread:              yes

Image I/O ---------------------
Use ImageIO / Mac OS X:   no
Use libjpeg:              yes
Use zlib:                 yes
Use libpng:               yes
Use libtiff:              no
Use libjasper:            no
Use libIlmImf/OpenEXR:    no

Video I/O ---------------------
Use QuickTime / Mac OS X: no
Use xine:                 no
Use gstreamer:            no
Use ffmpeg:               no
Use dc1394 & raw1394:     no
Use v4l:                  yes
Use v4l2:                 yes
Use unicap:               no

Wrappers for other languages =========================================

SWIG                      
Python                    no
Octave                    no

Additional build settings ============================================

Build demo apps           yes

Now run make ...

A: 

I have rebuilt openCV as well as changed to root user when doing it instead of typing sudo. Now the jpg files can be opened. I might have lost the sudo 'somewhere in the installation of openCV procedure earlier on, which lead to some mismatch.