Loading and displaying images from files

Most computer vision applications need to retrieve images from some where. In case you need to get them from files, OpenCV comes with several image file loaders. Unfortunately, some loaders depend on codecs that sometimes aren't shipped with the operating system, which might cause them not to load. From the documentation, we see that the following files are supported with some caveats:

  • Windows bitmaps: *.bmp, *.dib
  • JPEG files: *.jpeg, *.jpg, *.jpe
  • JPEG 2000 files: *.jp2
  • Portable Network Graphics: *.png
  • Portable image format: *.pbm, *.pgm, *.ppm
  • Sun rasters: *.sr, *.ras
  • TIFF files: *.tiff, *.tif

Note that Windows bitmaps, the portable image format, and sun raster formats are supported by all platforms, but the ...

Get OpenCV 3.0 Computer Vision with Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.