Linux cvLoadImage()在加载*.jpg时失败

Linux cvLoadImage()在加载*.jpg时失败,linux,opencv,jpeg,Linux,Opencv,Jpeg,我试图使用cvLoadImage函数加载JPEG图像,但失败。我得到输出“图像未加载”(见下面的代码)。但是,会出现一个窗口,但没有图片。 尝试加载png图片时,cvLoadImage操作成功,即图片显示在窗口中。是否有我可能丢失的包或我做错了什么 我在Ubuntu上使用openCV IplImage* img = NULL; if( argc > 1 ) img = cvLoadImage(argv[1], 1); if(img == 0) printf("image

我试图使用
cvLoadImage
函数加载JPEG图像,但失败。我得到输出“图像未加载”(见下面的代码)。但是,会出现一个窗口,但没有图片。 尝试加载png图片时,
cvLoadImage
操作成功,即图片显示在窗口中。是否有我可能丢失的包或我做错了什么

我在Ubuntu上使用openCV

IplImage* img = NULL;

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

if(img == 0)
    printf("image not loaded \n")

Jpeg在OpenCv下加载良好,我刚刚检查过。看看你有没有

  • 这条路是正确的
  • 您正在加载的图像实际上是jpeg(或opencv实际支持的某种格式)

  • Jpeg在OpenCv下加载良好,我刚刚检查过。看看你有没有

  • 这条路是正确的
  • 您正在加载的图像实际上是jpeg(或opencv实际支持的某种格式)

  • 实际上,这条路是正确的。我不知道我构建OpenCV的方式是否不正确:

    一般配置================================================

    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
    
    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
    
    SWIG                      
    Python                    no
    Octave                    no
    
    Build demo apps           yes
    
    HighGUI配置================================================

    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
    
    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
    
    SWIG                      
    Python                    no
    Octave                    no
    
    Build demo apps           yes
    
    其他语言的包装器=========================================

    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
    
    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
    
    SWIG                      
    Python                    no
    Octave                    no
    
    Build demo apps           yes
    
    其他生成设置============================================

    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
    
    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
    
    SWIG                      
    Python                    no
    Octave                    no
    
    Build demo apps           yes
    

    现在运行make…

    实际上路径是正确的。我不知道我构建OpenCV的方式是否不正确:

    一般配置================================================

    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
    
    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
    
    SWIG                      
    Python                    no
    Octave                    no
    
    Build demo apps           yes
    
    HighGUI配置================================================

    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
    
    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
    
    SWIG                      
    Python                    no
    Octave                    no
    
    Build demo apps           yes
    
    其他语言的包装器=========================================

    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
    
    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
    
    SWIG                      
    Python                    no
    Octave                    no
    
    Build demo apps           yes
    
    其他生成设置============================================

    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
    
    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
    
    SWIG                      
    Python                    no
    Octave                    no
    
    Build demo apps           yes
    

    现在运行make…

    我重新构建了openCV,并在执行此操作时改为root用户,而不是键入sudo。现在可以打开jpg文件了。我可能在早些时候的openCV安装过程中丢失了sudo,这导致了一些不匹配。

    我重建了openCV,并在执行时改为root用户,而不是键入sudo。现在可以打开jpg文件了。我可能在早些时候的openCV安装过程中丢失了sudo,这导致了一些不匹配