Windows bitmaps - *.bmp, *.dib (always supported)
JPEG files - *.jpeg, *.jpg, *.jpe (see the Note section)
JPEG 2000 files - *.jp2 (see the Note section)
Portable Network Graphics - *.png (see the Note section)
WebP - *.webp (see the Note section)
Portable image format - *.pbm, *.pgm, *.ppm *.pxm, *.pnm (always supported)
PFM files - *.pfm (see the Note section)
Sun rasters - *.sr, *.ras (always supported)
TIFF files - *.tiff, *.tif (see the Note section)
OpenEXR Image files - *.exr (see the Note section)
Radiance HDR - *.hdr, *.pic (always supported)
Raster and Vector geospatial data supported by GDAL (see the Note section)
Parameters
filename: Name of file to be loaded.
flags: Flag that can take values of cv::ImreadModes
C++ default parameters
flags: IMREAD_COLOR
Getting OpenCV
Linux
You have several options of getting the OpenCV library:install it from the repository, make sure to install -dev packages because they contain headers necessary for the crate build (also check that your package contains pkg_config files).build OpenCV manually and set up the following environment variables prior to building the project with opencv crate:PKG_CONFIG_PATH for the location of *.pc files
LD_LIBRARY_PATH for where to lookfor the installed *.so files during runtime
Windows package
Installing OpenCV is easy through the following sources:from chocolatey, also install llvm package, it's required for building:choco install llvm opencv
also set OPENCV_LINK_LIBS, OPENCV_LINK_PATHS and OPENCV_INCLUDE_PATHS environment variables (see below for details).from vcpkg, also install llvm package, necessary for building:vcpkg install llvm opencv4[contrib,nonfree]
macOS package
Get OpenCV from homebrew:homebrew, be sure to also install llvm and pkg-config that are required for building:
brew install llvm pkg-config opencv
Manual build
You can of course always compile OpenCV of the version you prefer manually. This is also supported, but it requires some additional configuration.You need to set up the following environment variables to point to the installed files of your OpenCV build: OPENCV_LINK_LIBS, OPENCV_LINK_PATHS and OPENCV_INCLUDE_PATHS (see below for details).