Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1332751
  • 博文数量: 436
  • 博客积分: 7854
  • 博客等级: 少将
  • 技术积分: 3225
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-18 16:30
文章分类

全部博文(436)

文章存档

2013年(2)

2012年(56)

2011年(70)

2010年(308)

分类:

2011-03-07 16:04:35

cvLoadImage返回NULL

安装最新的jpg库

apt-get install libjpeg62 libjpeg62-dev libjpeg62-dbg

cmake开启第三方库支持OPENCV_BUILD_3RDPARTY_LIBS=ON

linux下默认只支持bmp

可以用cvSaveImage函数来实现不同图像格式之间的转换。

Loads an image from a file.

Parameters:
  • filename – Name of file to be loaded.
  • flags –

    Specifies color type of the loaded image:

    • >0 the loaded image is forced to be a 3-channel color image
    • =0 the loaded image is forced to be grayscale
    • <0 the loaded image will be loaded as-is (note that in the current implementation the alpha channel, if any, is stripped from the output image, e.g. 4-channel RGBA image will be loaded as RGB ifflags\ge0 ).

The function imread loads an image from the specified file and returns it. If the image can not be read (because of missing file, improper permissions, unsupported or invalid format), the function returns empty matrix ( Mat::data==NULL).Currently, the following file formats are supported:

  • Windows bitmaps - *.bmp, *.dib (always supported)
  • JPEG files - *.jpeg, *.jpg, *.jpe (see Note2 )
  • JPEG 2000 files - *.jp2 (see Note2 )
  • Portable Network Graphics - *.png (see Note2 )
  • Portable image format - *.pbm, *.pgm, *.ppm (always supported)
  • Sun rasters - *.sr, *.ras (always supported)
  • TIFF files - *.tiff, *.tif (see Note2 )

Note1 : The function determines type of the image by the content, not by the file extension.

Note2 : On Windows and MacOSX the shipped with OpenCV image codecs (libjpeg, libpng, libtiff and libjasper) are used by default; so OpenCV can always read JPEGs, PNGs and TIFFs. On MacOSX there is also the option to use native MacOSX image readers. But beware that currently these native image loaders give images with somewhat different pixel values, because of the embedded into MacOSX color management.

On Linux, BSD flavors and other Unix-like open-source operating systems OpenCV looks for the supplied with OS image codecs. Please, install the relevant packages (do not forget the development files, e.g. “libjpeg-dev” etc. in Debian and Ubuntu) in order to get the codec support, or turn on OPENCV_BUILD_3RDPARTY_LIBS flag in CMake.

阅读(2873) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~