Class Imgcodecs

java.lang.Object
org.opencv.imgcodecs.Imgcodecs

public class Imgcodecs extends Object
  • Field Details

    • IMAGE_METADATA_UNKNOWN

      public static final int IMAGE_METADATA_UNKNOWN
      See Also:
    • IMAGE_METADATA_EXIF

      public static final int IMAGE_METADATA_EXIF
      See Also:
    • IMAGE_METADATA_XMP

      public static final int IMAGE_METADATA_XMP
      See Also:
    • IMAGE_METADATA_ICCP

      public static final int IMAGE_METADATA_ICCP
      See Also:
    • IMAGE_METADATA_MAX

      public static final int IMAGE_METADATA_MAX
      See Also:
    • IMREAD_UNCHANGED

      public static final int IMREAD_UNCHANGED
      See Also:
    • IMREAD_GRAYSCALE

      public static final int IMREAD_GRAYSCALE
      See Also:
    • IMREAD_COLOR_BGR

      public static final int IMREAD_COLOR_BGR
      See Also:
    • IMREAD_COLOR

      public static final int IMREAD_COLOR
      See Also:
    • IMREAD_ANYDEPTH

      public static final int IMREAD_ANYDEPTH
      See Also:
    • IMREAD_ANYCOLOR

      public static final int IMREAD_ANYCOLOR
      See Also:
    • IMREAD_LOAD_GDAL

      public static final int IMREAD_LOAD_GDAL
      See Also:
    • IMREAD_REDUCED_GRAYSCALE_2

      public static final int IMREAD_REDUCED_GRAYSCALE_2
      See Also:
    • IMREAD_REDUCED_COLOR_2

      public static final int IMREAD_REDUCED_COLOR_2
      See Also:
    • IMREAD_REDUCED_GRAYSCALE_4

      public static final int IMREAD_REDUCED_GRAYSCALE_4
      See Also:
    • IMREAD_REDUCED_COLOR_4

      public static final int IMREAD_REDUCED_COLOR_4
      See Also:
    • IMREAD_REDUCED_GRAYSCALE_8

      public static final int IMREAD_REDUCED_GRAYSCALE_8
      See Also:
    • IMREAD_REDUCED_COLOR_8

      public static final int IMREAD_REDUCED_COLOR_8
      See Also:
    • IMREAD_IGNORE_ORIENTATION

      public static final int IMREAD_IGNORE_ORIENTATION
      See Also:
    • IMREAD_COLOR_RGB

      public static final int IMREAD_COLOR_RGB
      See Also:
    • IMWRITE_EXR_COMPRESSION_NO

      public static final int IMWRITE_EXR_COMPRESSION_NO
      See Also:
    • IMWRITE_EXR_COMPRESSION_RLE

      public static final int IMWRITE_EXR_COMPRESSION_RLE
      See Also:
    • IMWRITE_EXR_COMPRESSION_ZIPS

      public static final int IMWRITE_EXR_COMPRESSION_ZIPS
      See Also:
    • IMWRITE_EXR_COMPRESSION_ZIP

      public static final int IMWRITE_EXR_COMPRESSION_ZIP
      See Also:
    • IMWRITE_EXR_COMPRESSION_PIZ

      public static final int IMWRITE_EXR_COMPRESSION_PIZ
      See Also:
    • IMWRITE_EXR_COMPRESSION_PXR24

      public static final int IMWRITE_EXR_COMPRESSION_PXR24
      See Also:
    • IMWRITE_EXR_COMPRESSION_B44

      public static final int IMWRITE_EXR_COMPRESSION_B44
      See Also:
    • IMWRITE_EXR_COMPRESSION_B44A

      public static final int IMWRITE_EXR_COMPRESSION_B44A
      See Also:
    • IMWRITE_EXR_COMPRESSION_DWAA

      public static final int IMWRITE_EXR_COMPRESSION_DWAA
      See Also:
    • IMWRITE_EXR_COMPRESSION_DWAB

      public static final int IMWRITE_EXR_COMPRESSION_DWAB
      See Also:
    • IMWRITE_EXR_TYPE_HALF

      public static final int IMWRITE_EXR_TYPE_HALF
      See Also:
    • IMWRITE_EXR_TYPE_FLOAT

      public static final int IMWRITE_EXR_TYPE_FLOAT
      See Also:
    • IMWRITE_JPEG_QUALITY

      public static final int IMWRITE_JPEG_QUALITY
      See Also:
    • IMWRITE_JPEG_PROGRESSIVE

      public static final int IMWRITE_JPEG_PROGRESSIVE
      See Also:
    • IMWRITE_JPEG_OPTIMIZE

      public static final int IMWRITE_JPEG_OPTIMIZE
      See Also:
    • IMWRITE_JPEG_RST_INTERVAL

      public static final int IMWRITE_JPEG_RST_INTERVAL
      See Also:
    • IMWRITE_JPEG_LUMA_QUALITY

      public static final int IMWRITE_JPEG_LUMA_QUALITY
      See Also:
    • IMWRITE_JPEG_CHROMA_QUALITY

      public static final int IMWRITE_JPEG_CHROMA_QUALITY
      See Also:
    • IMWRITE_JPEG_SAMPLING_FACTOR

      public static final int IMWRITE_JPEG_SAMPLING_FACTOR
      See Also:
    • IMWRITE_PNG_COMPRESSION

      public static final int IMWRITE_PNG_COMPRESSION
      See Also:
    • IMWRITE_PNG_STRATEGY

      public static final int IMWRITE_PNG_STRATEGY
      See Also:
    • IMWRITE_PNG_BILEVEL

      public static final int IMWRITE_PNG_BILEVEL
      See Also:
    • IMWRITE_PNG_FILTER

      public static final int IMWRITE_PNG_FILTER
      See Also:
    • IMWRITE_PXM_BINARY

      public static final int IMWRITE_PXM_BINARY
      See Also:
    • IMWRITE_EXR_TYPE

      public static final int IMWRITE_EXR_TYPE
      See Also:
    • IMWRITE_EXR_COMPRESSION

      public static final int IMWRITE_EXR_COMPRESSION
      See Also:
    • IMWRITE_EXR_DWA_COMPRESSION_LEVEL

      public static final int IMWRITE_EXR_DWA_COMPRESSION_LEVEL
      See Also:
    • IMWRITE_WEBP_QUALITY

      public static final int IMWRITE_WEBP_QUALITY
      See Also:
    • IMWRITE_HDR_COMPRESSION

      public static final int IMWRITE_HDR_COMPRESSION
      See Also:
    • IMWRITE_PAM_TUPLETYPE

      public static final int IMWRITE_PAM_TUPLETYPE
      See Also:
    • IMWRITE_TIFF_RESUNIT

      public static final int IMWRITE_TIFF_RESUNIT
      See Also:
    • IMWRITE_TIFF_XDPI

      public static final int IMWRITE_TIFF_XDPI
      See Also:
    • IMWRITE_TIFF_YDPI

      public static final int IMWRITE_TIFF_YDPI
      See Also:
    • IMWRITE_TIFF_COMPRESSION

      public static final int IMWRITE_TIFF_COMPRESSION
      See Also:
    • IMWRITE_TIFF_ROWSPERSTRIP

      public static final int IMWRITE_TIFF_ROWSPERSTRIP
      See Also:
    • IMWRITE_TIFF_PREDICTOR

      public static final int IMWRITE_TIFF_PREDICTOR
      See Also:
    • IMWRITE_JPEG2000_COMPRESSION_X1000

      public static final int IMWRITE_JPEG2000_COMPRESSION_X1000
      See Also:
    • IMWRITE_AVIF_QUALITY

      public static final int IMWRITE_AVIF_QUALITY
      See Also:
    • IMWRITE_AVIF_DEPTH

      public static final int IMWRITE_AVIF_DEPTH
      See Also:
    • IMWRITE_AVIF_SPEED

      public static final int IMWRITE_AVIF_SPEED
      See Also:
    • IMWRITE_JPEGXL_QUALITY

      public static final int IMWRITE_JPEGXL_QUALITY
      See Also:
    • IMWRITE_JPEGXL_EFFORT

      public static final int IMWRITE_JPEGXL_EFFORT
      See Also:
    • IMWRITE_JPEGXL_DISTANCE

      public static final int IMWRITE_JPEGXL_DISTANCE
      See Also:
    • IMWRITE_JPEGXL_DECODING_SPEED

      public static final int IMWRITE_JPEGXL_DECODING_SPEED
      See Also:
    • IMWRITE_GIF_LOOP

      public static final int IMWRITE_GIF_LOOP
      See Also:
    • IMWRITE_GIF_SPEED

      public static final int IMWRITE_GIF_SPEED
      See Also:
    • IMWRITE_GIF_QUALITY

      public static final int IMWRITE_GIF_QUALITY
      See Also:
    • IMWRITE_GIF_DITHER

      public static final int IMWRITE_GIF_DITHER
      See Also:
    • IMWRITE_GIF_TRANSPARENCY

      public static final int IMWRITE_GIF_TRANSPARENCY
      See Also:
    • IMWRITE_GIF_COLORTABLE

      public static final int IMWRITE_GIF_COLORTABLE
      See Also:
    • IMWRITE_GIF_FAST_NO_DITHER

      public static final int IMWRITE_GIF_FAST_NO_DITHER
      See Also:
    • IMWRITE_GIF_FAST_FLOYD_DITHER

      public static final int IMWRITE_GIF_FAST_FLOYD_DITHER
      See Also:
    • IMWRITE_GIF_COLORTABLE_SIZE_8

      public static final int IMWRITE_GIF_COLORTABLE_SIZE_8
      See Also:
    • IMWRITE_GIF_COLORTABLE_SIZE_16

      public static final int IMWRITE_GIF_COLORTABLE_SIZE_16
      See Also:
    • IMWRITE_GIF_COLORTABLE_SIZE_32

      public static final int IMWRITE_GIF_COLORTABLE_SIZE_32
      See Also:
    • IMWRITE_GIF_COLORTABLE_SIZE_64

      public static final int IMWRITE_GIF_COLORTABLE_SIZE_64
      See Also:
    • IMWRITE_GIF_COLORTABLE_SIZE_128

      public static final int IMWRITE_GIF_COLORTABLE_SIZE_128
      See Also:
    • IMWRITE_GIF_COLORTABLE_SIZE_256

      public static final int IMWRITE_GIF_COLORTABLE_SIZE_256
      See Also:
    • IMWRITE_HDR_COMPRESSION_NONE

      public static final int IMWRITE_HDR_COMPRESSION_NONE
      See Also:
    • IMWRITE_HDR_COMPRESSION_RLE

      public static final int IMWRITE_HDR_COMPRESSION_RLE
      See Also:
    • IMWRITE_JPEG_SAMPLING_FACTOR_411

      public static final int IMWRITE_JPEG_SAMPLING_FACTOR_411
      See Also:
    • IMWRITE_JPEG_SAMPLING_FACTOR_420

      public static final int IMWRITE_JPEG_SAMPLING_FACTOR_420
      See Also:
    • IMWRITE_JPEG_SAMPLING_FACTOR_422

      public static final int IMWRITE_JPEG_SAMPLING_FACTOR_422
      See Also:
    • IMWRITE_JPEG_SAMPLING_FACTOR_440

      public static final int IMWRITE_JPEG_SAMPLING_FACTOR_440
      See Also:
    • IMWRITE_JPEG_SAMPLING_FACTOR_444

      public static final int IMWRITE_JPEG_SAMPLING_FACTOR_444
      See Also:
    • IMWRITE_PAM_FORMAT_NULL

      public static final int IMWRITE_PAM_FORMAT_NULL
      See Also:
    • IMWRITE_PAM_FORMAT_BLACKANDWHITE

      public static final int IMWRITE_PAM_FORMAT_BLACKANDWHITE
      See Also:
    • IMWRITE_PAM_FORMAT_GRAYSCALE

      public static final int IMWRITE_PAM_FORMAT_GRAYSCALE
      See Also:
    • IMWRITE_PAM_FORMAT_GRAYSCALE_ALPHA

      public static final int IMWRITE_PAM_FORMAT_GRAYSCALE_ALPHA
      See Also:
    • IMWRITE_PAM_FORMAT_RGB

      public static final int IMWRITE_PAM_FORMAT_RGB
      See Also:
    • IMWRITE_PAM_FORMAT_RGB_ALPHA

      public static final int IMWRITE_PAM_FORMAT_RGB_ALPHA
      See Also:
    • IMWRITE_PNG_FILTER_NONE

      public static final int IMWRITE_PNG_FILTER_NONE
      See Also:
    • IMWRITE_PNG_FILTER_SUB

      public static final int IMWRITE_PNG_FILTER_SUB
      See Also:
    • IMWRITE_PNG_FILTER_UP

      public static final int IMWRITE_PNG_FILTER_UP
      See Also:
    • IMWRITE_PNG_FILTER_AVG

      public static final int IMWRITE_PNG_FILTER_AVG
      See Also:
    • IMWRITE_PNG_FILTER_PAETH

      public static final int IMWRITE_PNG_FILTER_PAETH
      See Also:
    • IMWRITE_PNG_FAST_FILTERS

      public static final int IMWRITE_PNG_FAST_FILTERS
      See Also:
    • IMWRITE_PNG_ALL_FILTERS

      public static final int IMWRITE_PNG_ALL_FILTERS
      See Also:
    • IMWRITE_PNG_STRATEGY_DEFAULT

      public static final int IMWRITE_PNG_STRATEGY_DEFAULT
      See Also:
    • IMWRITE_PNG_STRATEGY_FILTERED

      public static final int IMWRITE_PNG_STRATEGY_FILTERED
      See Also:
    • IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY

      public static final int IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY
      See Also:
    • IMWRITE_PNG_STRATEGY_RLE

      public static final int IMWRITE_PNG_STRATEGY_RLE
      See Also:
    • IMWRITE_PNG_STRATEGY_FIXED

      public static final int IMWRITE_PNG_STRATEGY_FIXED
      See Also:
    • IMWRITE_TIFF_COMPRESSION_NONE

      public static final int IMWRITE_TIFF_COMPRESSION_NONE
      See Also:
    • IMWRITE_TIFF_COMPRESSION_CCITTRLE

      public static final int IMWRITE_TIFF_COMPRESSION_CCITTRLE
      See Also:
    • IMWRITE_TIFF_COMPRESSION_CCITTFAX3

      public static final int IMWRITE_TIFF_COMPRESSION_CCITTFAX3
      See Also:
    • IMWRITE_TIFF_COMPRESSION_CCITT_T4

      public static final int IMWRITE_TIFF_COMPRESSION_CCITT_T4
      See Also:
    • IMWRITE_TIFF_COMPRESSION_CCITTFAX4

      public static final int IMWRITE_TIFF_COMPRESSION_CCITTFAX4
      See Also:
    • IMWRITE_TIFF_COMPRESSION_CCITT_T6

      public static final int IMWRITE_TIFF_COMPRESSION_CCITT_T6
      See Also:
    • IMWRITE_TIFF_COMPRESSION_LZW

      public static final int IMWRITE_TIFF_COMPRESSION_LZW
      See Also:
    • IMWRITE_TIFF_COMPRESSION_OJPEG

      public static final int IMWRITE_TIFF_COMPRESSION_OJPEG
      See Also:
    • IMWRITE_TIFF_COMPRESSION_JPEG

      public static final int IMWRITE_TIFF_COMPRESSION_JPEG
      See Also:
    • IMWRITE_TIFF_COMPRESSION_T85

      public static final int IMWRITE_TIFF_COMPRESSION_T85
      See Also:
    • IMWRITE_TIFF_COMPRESSION_T43

      public static final int IMWRITE_TIFF_COMPRESSION_T43
      See Also:
    • IMWRITE_TIFF_COMPRESSION_NEXT

      public static final int IMWRITE_TIFF_COMPRESSION_NEXT
      See Also:
    • IMWRITE_TIFF_COMPRESSION_CCITTRLEW

      public static final int IMWRITE_TIFF_COMPRESSION_CCITTRLEW
      See Also:
    • IMWRITE_TIFF_COMPRESSION_PACKBITS

      public static final int IMWRITE_TIFF_COMPRESSION_PACKBITS
      See Also:
    • IMWRITE_TIFF_COMPRESSION_THUNDERSCAN

      public static final int IMWRITE_TIFF_COMPRESSION_THUNDERSCAN
      See Also:
    • IMWRITE_TIFF_COMPRESSION_IT8CTPAD

      public static final int IMWRITE_TIFF_COMPRESSION_IT8CTPAD
      See Also:
    • IMWRITE_TIFF_COMPRESSION_IT8LW

      public static final int IMWRITE_TIFF_COMPRESSION_IT8LW
      See Also:
    • IMWRITE_TIFF_COMPRESSION_IT8MP

      public static final int IMWRITE_TIFF_COMPRESSION_IT8MP
      See Also:
    • IMWRITE_TIFF_COMPRESSION_IT8BL

      public static final int IMWRITE_TIFF_COMPRESSION_IT8BL
      See Also:
    • IMWRITE_TIFF_COMPRESSION_PIXARFILM

      public static final int IMWRITE_TIFF_COMPRESSION_PIXARFILM
      See Also:
    • IMWRITE_TIFF_COMPRESSION_PIXARLOG

      public static final int IMWRITE_TIFF_COMPRESSION_PIXARLOG
      See Also:
    • IMWRITE_TIFF_COMPRESSION_DEFLATE

      public static final int IMWRITE_TIFF_COMPRESSION_DEFLATE
      See Also:
    • IMWRITE_TIFF_COMPRESSION_ADOBE_DEFLATE

      public static final int IMWRITE_TIFF_COMPRESSION_ADOBE_DEFLATE
      See Also:
    • IMWRITE_TIFF_COMPRESSION_DCS

      public static final int IMWRITE_TIFF_COMPRESSION_DCS
      See Also:
    • IMWRITE_TIFF_COMPRESSION_JBIG

      public static final int IMWRITE_TIFF_COMPRESSION_JBIG
      See Also:
    • IMWRITE_TIFF_COMPRESSION_SGILOG

      public static final int IMWRITE_TIFF_COMPRESSION_SGILOG
      See Also:
    • IMWRITE_TIFF_COMPRESSION_SGILOG24

      public static final int IMWRITE_TIFF_COMPRESSION_SGILOG24
      See Also:
    • IMWRITE_TIFF_COMPRESSION_JP2000

      public static final int IMWRITE_TIFF_COMPRESSION_JP2000
      See Also:
    • IMWRITE_TIFF_COMPRESSION_LERC

      public static final int IMWRITE_TIFF_COMPRESSION_LERC
      See Also:
    • IMWRITE_TIFF_COMPRESSION_LZMA

      public static final int IMWRITE_TIFF_COMPRESSION_LZMA
      See Also:
    • IMWRITE_TIFF_COMPRESSION_ZSTD

      public static final int IMWRITE_TIFF_COMPRESSION_ZSTD
      See Also:
    • IMWRITE_TIFF_COMPRESSION_WEBP

      public static final int IMWRITE_TIFF_COMPRESSION_WEBP
      See Also:
    • IMWRITE_TIFF_COMPRESSION_JXL

      public static final int IMWRITE_TIFF_COMPRESSION_JXL
      See Also:
    • IMWRITE_TIFF_PREDICTOR_NONE

      public static final int IMWRITE_TIFF_PREDICTOR_NONE
      See Also:
    • IMWRITE_TIFF_PREDICTOR_HORIZONTAL

      public static final int IMWRITE_TIFF_PREDICTOR_HORIZONTAL
      See Also:
    • IMWRITE_TIFF_PREDICTOR_FLOATINGPOINT

      public static final int IMWRITE_TIFF_PREDICTOR_FLOATINGPOINT
      See Also:
  • Constructor Details

    • Imgcodecs

      public Imgcodecs()
  • Method Details

    • imread

      public static Mat imread(String filename, int flags)
      Loads an image from a file. imread The imread function loads an image from the specified file and returns OpenCV matrix. If the image cannot be read (because of a missing file, improper permissions, or unsupported/invalid format), the function returns an empty matrix. Currently, the following file formats are supported:
      • Windows bitmaps - \*.bmp, \*.dib (always supported)
      • GIF files - \*.gif (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)
      • AVIF - \*.avif (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)
      Note:
      • The function determines the type of an image by its content, not by the file extension.
      • In the case of color images, the decoded images will have the channels stored in B G R order.
      • When using IMREAD_GRAYSCALE, the codec's internal grayscale conversion will be used, if available. Results may differ from the output of cvtColor().
      • On Microsoft Windows\* and Mac OS\*, the codecs shipped with OpenCV (libjpeg, libpng, libtiff, and libjasper) are used by default. So, OpenCV can always read JPEGs, PNGs, and TIFFs. On Mac OS, there is also an option to use native Mac OS image readers. However, beware that currently these native image loaders give images with different pixel values because of the color management embedded into Mac OS.
      • On Linux\*, BSD flavors, and other Unix-like open-source operating systems, OpenCV looks for codecs supplied with the OS. Ensure the relevant packages are installed (including development files, such as "libjpeg-dev" in Debian\* and Ubuntu\*) to get codec support, or turn on the OPENCV_BUILD_3RDPARTY_LIBS flag in CMake.
      • If the *WITH_GDAL* flag is set to true in CMake and REF: IMREAD_LOAD_GDAL is used to load the image, the [GDAL](http://www.gdal.org) driver will be used to decode the image, supporting [Raster](http://www.gdal.org/formats_list.html) and [Vector](http://www.gdal.org/ogr_formats.html) formats.
      • If EXIF information is embedded in the image file, the EXIF orientation will be taken into account, and thus the image will be rotated accordingly unless the flags REF: IMREAD_IGNORE_ORIENTATION or REF: IMREAD_UNCHANGED are passed.
      • Use the IMREAD_UNCHANGED flag to preserve the floating-point values from PFM images.
      • By default, the number of pixels must be less than 2^30. This limit can be changed by setting the environment variable OPENCV_IO_MAX_IMAGE_PIXELS. See REF: tutorial_env_reference.
      Parameters:
      filename - Name of the file to be loaded.
      flags - Flag that can take values of cv::ImreadModes.
      Returns:
      automatically generated
    • imread

      public static Mat imread(String filename)
      Loads an image from a file. imread The imread function loads an image from the specified file and returns OpenCV matrix. If the image cannot be read (because of a missing file, improper permissions, or unsupported/invalid format), the function returns an empty matrix. Currently, the following file formats are supported:
      • Windows bitmaps - \*.bmp, \*.dib (always supported)
      • GIF files - \*.gif (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)
      • AVIF - \*.avif (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)
      Note:
      • The function determines the type of an image by its content, not by the file extension.
      • In the case of color images, the decoded images will have the channels stored in B G R order.
      • When using IMREAD_GRAYSCALE, the codec's internal grayscale conversion will be used, if available. Results may differ from the output of cvtColor().
      • On Microsoft Windows\* and Mac OS\*, the codecs shipped with OpenCV (libjpeg, libpng, libtiff, and libjasper) are used by default. So, OpenCV can always read JPEGs, PNGs, and TIFFs. On Mac OS, there is also an option to use native Mac OS image readers. However, beware that currently these native image loaders give images with different pixel values because of the color management embedded into Mac OS.
      • On Linux\*, BSD flavors, and other Unix-like open-source operating systems, OpenCV looks for codecs supplied with the OS. Ensure the relevant packages are installed (including development files, such as "libjpeg-dev" in Debian\* and Ubuntu\*) to get codec support, or turn on the OPENCV_BUILD_3RDPARTY_LIBS flag in CMake.
      • If the *WITH_GDAL* flag is set to true in CMake and REF: IMREAD_LOAD_GDAL is used to load the image, the [GDAL](http://www.gdal.org) driver will be used to decode the image, supporting [Raster](http://www.gdal.org/formats_list.html) and [Vector](http://www.gdal.org/ogr_formats.html) formats.
      • If EXIF information is embedded in the image file, the EXIF orientation will be taken into account, and thus the image will be rotated accordingly unless the flags REF: IMREAD_IGNORE_ORIENTATION or REF: IMREAD_UNCHANGED are passed.
      • Use the IMREAD_UNCHANGED flag to preserve the floating-point values from PFM images.
      • By default, the number of pixels must be less than 2^30. This limit can be changed by setting the environment variable OPENCV_IO_MAX_IMAGE_PIXELS. See REF: tutorial_env_reference.
      Parameters:
      filename - Name of the file to be loaded.
      Returns:
      automatically generated
    • imread

      public static void imread(String filename, Mat dst, int flags)
      Loads an image from a file. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts and the return value.
      Parameters:
      filename - Name of file to be loaded.
      dst - object in which the image will be loaded.
      flags - Flag that can take values of cv::ImreadModes Note: The image passing through the img parameter can be pre-allocated. The memory is reused if the shape and the type match with the load image.
    • imread

      public static void imread(String filename, Mat dst)
      Loads an image from a file. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts and the return value.
      Parameters:
      filename - Name of file to be loaded.
      dst - object in which the image will be loaded. Note: The image passing through the img parameter can be pre-allocated. The memory is reused if the shape and the type match with the load image.
    • imreadWithMetadata

      public static Mat imreadWithMetadata(String filename, MatOfInt metadataTypes, List<Mat> metadata, int flags)
      Reads an image from a file together with associated metadata. The function imreadWithMetadata reads image from the specified file. It does the same thing as imread, but additionally reads metadata if the corresponding file contains any.
      Parameters:
      filename - Name of the file to be loaded.
      metadataTypes - Output vector with types of metadata chucks returned in metadata, see ImageMetadataType.
      metadata - Output vector of vectors or vector of matrices to store the retrieved metadata
      flags - Flag that can take values of cv::ImreadModes
      Returns:
      automatically generated
    • imreadWithMetadata

      public static Mat imreadWithMetadata(String filename, MatOfInt metadataTypes, List<Mat> metadata)
      Reads an image from a file together with associated metadata. The function imreadWithMetadata reads image from the specified file. It does the same thing as imread, but additionally reads metadata if the corresponding file contains any.
      Parameters:
      filename - Name of the file to be loaded.
      metadataTypes - Output vector with types of metadata chucks returned in metadata, see ImageMetadataType.
      metadata - Output vector of vectors or vector of matrices to store the retrieved metadata
      Returns:
      automatically generated
    • imreadmulti

      public static boolean imreadmulti(String filename, List<Mat> mats, int flags)
      Loads a multi-page image from a file. The function imreadmulti loads a multi-page image from the specified file into a vector of Mat objects.
      Parameters:
      filename - Name of file to be loaded.
      mats - A vector of Mat objects holding each page.
      flags - Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR. SEE: cv::imread
      Returns:
      automatically generated
    • imreadmulti

      public static boolean imreadmulti(String filename, List<Mat> mats)
      Loads a multi-page image from a file. The function imreadmulti loads a multi-page image from the specified file into a vector of Mat objects.
      Parameters:
      filename - Name of file to be loaded.
      mats - A vector of Mat objects holding each page. SEE: cv::imread
      Returns:
      automatically generated
    • imreadmulti

      public static boolean imreadmulti(String filename, List<Mat> mats, int start, int count, int flags)
      Loads images of a multi-page image from a file. The function imreadmulti loads a specified range from a multi-page image from the specified file into a vector of Mat objects.
      Parameters:
      filename - Name of file to be loaded.
      mats - A vector of Mat objects holding each page.
      start - Start index of the image to load
      count - Count number of images to load
      flags - Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR. SEE: cv::imread
      Returns:
      automatically generated
    • imreadmulti

      public static boolean imreadmulti(String filename, List<Mat> mats, int start, int count)
      Loads images of a multi-page image from a file. The function imreadmulti loads a specified range from a multi-page image from the specified file into a vector of Mat objects.
      Parameters:
      filename - Name of file to be loaded.
      mats - A vector of Mat objects holding each page.
      start - Start index of the image to load
      count - Count number of images to load SEE: cv::imread
      Returns:
      automatically generated
    • imreadanimation

      public static boolean imreadanimation(String filename, Animation animation, int start, int count)
      Loads frames from an animated image file into an Animation structure. The function imreadanimation loads frames from an animated image file (e.g., GIF, AVIF, APNG, WEBP) into the provided Animation struct.
      Parameters:
      filename - A string containing the path to the file.
      animation - A reference to an Animation structure where the loaded frames will be stored. It should be initialized before the function is called.
      start - The index of the first frame to load. This is optional and defaults to 0.
      count - The number of frames to load. This is optional and defaults to 32767.
      Returns:
      Returns true if the file was successfully loaded and frames were extracted; returns false otherwise.
    • imreadanimation

      public static boolean imreadanimation(String filename, Animation animation, int start)
      Loads frames from an animated image file into an Animation structure. The function imreadanimation loads frames from an animated image file (e.g., GIF, AVIF, APNG, WEBP) into the provided Animation struct.
      Parameters:
      filename - A string containing the path to the file.
      animation - A reference to an Animation structure where the loaded frames will be stored. It should be initialized before the function is called.
      start - The index of the first frame to load. This is optional and defaults to 0.
      Returns:
      Returns true if the file was successfully loaded and frames were extracted; returns false otherwise.
    • imreadanimation

      public static boolean imreadanimation(String filename, Animation animation)
      Loads frames from an animated image file into an Animation structure. The function imreadanimation loads frames from an animated image file (e.g., GIF, AVIF, APNG, WEBP) into the provided Animation struct.
      Parameters:
      filename - A string containing the path to the file.
      animation - A reference to an Animation structure where the loaded frames will be stored. It should be initialized before the function is called.
      Returns:
      Returns true if the file was successfully loaded and frames were extracted; returns false otherwise.
    • imdecodeanimation

      public static boolean imdecodeanimation(Mat buf, Animation animation, int start, int count)
      Loads frames from an animated image buffer into an Animation structure. The function imdecodeanimation loads frames from an animated image buffer (e.g., GIF, AVIF, APNG, WEBP) into the provided Animation struct.
      Parameters:
      buf - A reference to an InputArray containing the image buffer.
      animation - A reference to an Animation structure where the loaded frames will be stored. It should be initialized before the function is called.
      start - The index of the first frame to load. This is optional and defaults to 0.
      count - The number of frames to load. This is optional and defaults to 32767.
      Returns:
      Returns true if the buffer was successfully loaded and frames were extracted; returns false otherwise.
    • imdecodeanimation

      public static boolean imdecodeanimation(Mat buf, Animation animation, int start)
      Loads frames from an animated image buffer into an Animation structure. The function imdecodeanimation loads frames from an animated image buffer (e.g., GIF, AVIF, APNG, WEBP) into the provided Animation struct.
      Parameters:
      buf - A reference to an InputArray containing the image buffer.
      animation - A reference to an Animation structure where the loaded frames will be stored. It should be initialized before the function is called.
      start - The index of the first frame to load. This is optional and defaults to 0.
      Returns:
      Returns true if the buffer was successfully loaded and frames were extracted; returns false otherwise.
    • imdecodeanimation

      public static boolean imdecodeanimation(Mat buf, Animation animation)
      Loads frames from an animated image buffer into an Animation structure. The function imdecodeanimation loads frames from an animated image buffer (e.g., GIF, AVIF, APNG, WEBP) into the provided Animation struct.
      Parameters:
      buf - A reference to an InputArray containing the image buffer.
      animation - A reference to an Animation structure where the loaded frames will be stored. It should be initialized before the function is called.
      Returns:
      Returns true if the buffer was successfully loaded and frames were extracted; returns false otherwise.
    • imwriteanimation

      public static boolean imwriteanimation(String filename, Animation animation, MatOfInt params)
      Saves an Animation to a specified file. The function imwriteanimation saves the provided Animation data to the specified file in an animated format. Supported formats depend on the implementation and may include formats like GIF, AVIF, APNG, or WEBP.
      Parameters:
      filename - The name of the file where the animation will be saved. The file extension determines the format.
      animation - A constant reference to an Animation struct containing the frames and metadata to be saved.
      params - Optional format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...). These parameters are used to specify additional options for the encoding process. Refer to cv::ImwriteFlags for details on possible parameters.
      Returns:
      Returns true if the animation was successfully saved; returns false otherwise.
    • imwriteanimation

      public static boolean imwriteanimation(String filename, Animation animation)
      Saves an Animation to a specified file. The function imwriteanimation saves the provided Animation data to the specified file in an animated format. Supported formats depend on the implementation and may include formats like GIF, AVIF, APNG, or WEBP.
      Parameters:
      filename - The name of the file where the animation will be saved. The file extension determines the format.
      animation - A constant reference to an Animation struct containing the frames and metadata to be saved. These parameters are used to specify additional options for the encoding process. Refer to cv::ImwriteFlags for details on possible parameters.
      Returns:
      Returns true if the animation was successfully saved; returns false otherwise.
    • imencodeanimation

      public static boolean imencodeanimation(String ext, Animation animation, MatOfByte buf, MatOfInt params)
      Encodes an Animation to a memory buffer. The function imencodeanimation encodes the provided Animation data into a memory buffer in an animated format. Supported formats depend on the implementation and may include formats like GIF, AVIF, APNG, or WEBP.
      Parameters:
      ext - The file extension that determines the format of the encoded data.
      animation - A constant reference to an Animation struct containing the frames and metadata to be encoded.
      buf - A reference to a vector of unsigned chars where the encoded data will be stored.
      params - Optional format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...). These parameters are used to specify additional options for the encoding process. Refer to cv::ImwriteFlags for details on possible parameters.
      Returns:
      Returns true if the animation was successfully encoded; returns false otherwise.
    • imencodeanimation

      public static boolean imencodeanimation(String ext, Animation animation, MatOfByte buf)
      Encodes an Animation to a memory buffer. The function imencodeanimation encodes the provided Animation data into a memory buffer in an animated format. Supported formats depend on the implementation and may include formats like GIF, AVIF, APNG, or WEBP.
      Parameters:
      ext - The file extension that determines the format of the encoded data.
      animation - A constant reference to an Animation struct containing the frames and metadata to be encoded.
      buf - A reference to a vector of unsigned chars where the encoded data will be stored. paramValue_1, paramId_2, paramValue_2, ...). These parameters are used to specify additional options for the encoding process. Refer to cv::ImwriteFlags for details on possible parameters.
      Returns:
      Returns true if the animation was successfully encoded; returns false otherwise.
    • imcount

      public static long imcount(String filename, int flags)
      Returns the number of images inside the given file The function imcount returns the number of pages in a multi-page image (e.g. TIFF), the number of frames in an animation (e.g. AVIF), and 1 otherwise. If the image cannot be decoded, 0 is returned.
      Parameters:
      filename - Name of file to be loaded.
      flags - Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR. TODO: when cv::IMREAD_LOAD_GDAL flag used the return value will be 0 or 1 because OpenCV's GDAL decoder doesn't support multi-page reading yet.
      Returns:
      automatically generated
    • imcount

      public static long imcount(String filename)
      Returns the number of images inside the given file The function imcount returns the number of pages in a multi-page image (e.g. TIFF), the number of frames in an animation (e.g. AVIF), and 1 otherwise. If the image cannot be decoded, 0 is returned.
      Parameters:
      filename - Name of file to be loaded. TODO: when cv::IMREAD_LOAD_GDAL flag used the return value will be 0 or 1 because OpenCV's GDAL decoder doesn't support multi-page reading yet.
      Returns:
      automatically generated
    • imwrite

      public static boolean imwrite(String filename, Mat img, MatOfInt params)
      Saves an image to a specified file. The function imwrite saves the image to the specified file. The image format is chosen based on the filename extension (see cv::imread for the list of extensions). In general, only 8-bit unsigned (CV_8U) single-channel or 3-channel (with 'BGR' channel order) images can be saved using this function, with these exceptions:
      • With OpenEXR encoder, only 32-bit float (CV_32F) images can be saved.
        • 8-bit unsigned (CV_8U) images are not supported.
      • With Radiance HDR encoder, non 64-bit float (CV_64F) images can be saved.
        • All images will be converted to 32-bit float (CV_32F).
      • With JPEG 2000 encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
      • With JPEG XL encoder, 8-bit unsigned (CV_8U), 16-bit unsigned (CV_16U) and 32-bit float(CV_32F) images can be saved.
        • JPEG XL images with an alpha channel can be saved using this function. To achieve this, create an 8-bit 4-channel (CV_8UC4) / 16-bit 4-channel (CV_16UC4) / 32-bit float 4-channel (CV_32FC4) BGRA image, ensuring the alpha channel is the last component. Fully transparent pixels should have an alpha value of 0, while fully opaque pixels should have an alpha value of 255/65535/1.0.
      • With PAM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
      • With PNG encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
        • PNG images with an alpha channel can be saved using this function. To achieve this, create an 8-bit 4-channel (CV_8UC4) / 16-bit 4-channel (CV_16UC4) BGRA image, ensuring the alpha channel is the last component. Fully transparent pixels should have an alpha value of 0, while fully opaque pixels should have an alpha value of 255/65535(see the code sample below).
      • With PGM/PPM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
      • With TIFF encoder, 8-bit unsigned (CV_8U), 8-bit signed (CV_8S), 16-bit unsigned (CV_16U), 16-bit signed (CV_16S), 32-bit signed (CV_32S), 32-bit float (CV_32F) and 64-bit float (CV_64F) images can be saved.
        • Multiple images (vector of Mat) can be saved in TIFF format (see the code sample below).
        • 32-bit float 3-channel (CV_32FC3) TIFF images will be saved using the LogLuv high dynamic range encoding (4 bytes per pixel)
      • With GIF encoder, 8-bit unsigned (CV_8U) images can be saved.
        • GIF images with an alpha channel can be saved using this function. To achieve this, create an 8-bit 4-channel (CV_8UC4) BGRA image, ensuring the alpha channel is the last component. Fully transparent pixels should have an alpha value of 0, while fully opaque pixels should have an alpha value of 255.
        • 8-bit single-channel images (CV_8UC1) are not supported due to GIF's limitation to indexed color formats.
        If the image format is not supported, the image will be converted to 8-bit unsigned (CV_8U) and saved that way.
      If the format, depth or channel order is different, use Mat::convertTo and cv::cvtColor to convert it before saving. Or, use the universal FileStorage I/O functions to save the image to XML or YAML format. The sample below shows how to create a BGRA image, how to set custom compression parameters and save it to a PNG file. It also demonstrates how to save multiple images in a TIFF file: INCLUDE: snippets/imgcodecs_imwrite.cpp
      Parameters:
      filename - Name of the file.
      img - (Mat or vector of Mat) Image or Images to be saved.
      params - Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::ImwriteFlags
      Returns:
      automatically generated
    • imwrite

      public static boolean imwrite(String filename, Mat img)
      Saves an image to a specified file. The function imwrite saves the image to the specified file. The image format is chosen based on the filename extension (see cv::imread for the list of extensions). In general, only 8-bit unsigned (CV_8U) single-channel or 3-channel (with 'BGR' channel order) images can be saved using this function, with these exceptions:
      • With OpenEXR encoder, only 32-bit float (CV_32F) images can be saved.
        • 8-bit unsigned (CV_8U) images are not supported.
      • With Radiance HDR encoder, non 64-bit float (CV_64F) images can be saved.
        • All images will be converted to 32-bit float (CV_32F).
      • With JPEG 2000 encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
      • With JPEG XL encoder, 8-bit unsigned (CV_8U), 16-bit unsigned (CV_16U) and 32-bit float(CV_32F) images can be saved.
        • JPEG XL images with an alpha channel can be saved using this function. To achieve this, create an 8-bit 4-channel (CV_8UC4) / 16-bit 4-channel (CV_16UC4) / 32-bit float 4-channel (CV_32FC4) BGRA image, ensuring the alpha channel is the last component. Fully transparent pixels should have an alpha value of 0, while fully opaque pixels should have an alpha value of 255/65535/1.0.
      • With PAM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
      • With PNG encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
        • PNG images with an alpha channel can be saved using this function. To achieve this, create an 8-bit 4-channel (CV_8UC4) / 16-bit 4-channel (CV_16UC4) BGRA image, ensuring the alpha channel is the last component. Fully transparent pixels should have an alpha value of 0, while fully opaque pixels should have an alpha value of 255/65535(see the code sample below).
      • With PGM/PPM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
      • With TIFF encoder, 8-bit unsigned (CV_8U), 8-bit signed (CV_8S), 16-bit unsigned (CV_16U), 16-bit signed (CV_16S), 32-bit signed (CV_32S), 32-bit float (CV_32F) and 64-bit float (CV_64F) images can be saved.
        • Multiple images (vector of Mat) can be saved in TIFF format (see the code sample below).
        • 32-bit float 3-channel (CV_32FC3) TIFF images will be saved using the LogLuv high dynamic range encoding (4 bytes per pixel)
      • With GIF encoder, 8-bit unsigned (CV_8U) images can be saved.
        • GIF images with an alpha channel can be saved using this function. To achieve this, create an 8-bit 4-channel (CV_8UC4) BGRA image, ensuring the alpha channel is the last component. Fully transparent pixels should have an alpha value of 0, while fully opaque pixels should have an alpha value of 255.
        • 8-bit single-channel images (CV_8UC1) are not supported due to GIF's limitation to indexed color formats.
        If the image format is not supported, the image will be converted to 8-bit unsigned (CV_8U) and saved that way.
      If the format, depth or channel order is different, use Mat::convertTo and cv::cvtColor to convert it before saving. Or, use the universal FileStorage I/O functions to save the image to XML or YAML format. The sample below shows how to create a BGRA image, how to set custom compression parameters and save it to a PNG file. It also demonstrates how to save multiple images in a TIFF file: INCLUDE: snippets/imgcodecs_imwrite.cpp
      Parameters:
      filename - Name of the file.
      img - (Mat or vector of Mat) Image or Images to be saved.
      Returns:
      automatically generated
    • imwriteWithMetadata

      public static boolean imwriteWithMetadata(String filename, Mat img, MatOfInt metadataTypes, List<Mat> metadata, MatOfInt params)
      Saves an image to a specified file with metadata The function imwriteWithMetadata saves the image to the specified file. It does the same thing as imwrite, but additionally writes metadata if the corresponding format supports it.
      Parameters:
      filename - Name of the file. As with imwrite, image format is determined by the file extension.
      img - (Mat or vector of Mat) Image or Images to be saved.
      metadataTypes - Vector with types of metadata chucks stored in metadata to write, see ImageMetadataType.
      metadata - Vector of vectors or vector of matrices with chunks of metadata to store into the file
      params - Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::ImwriteFlags
      Returns:
      automatically generated
    • imwriteWithMetadata

      public static boolean imwriteWithMetadata(String filename, Mat img, MatOfInt metadataTypes, List<Mat> metadata)
      Saves an image to a specified file with metadata The function imwriteWithMetadata saves the image to the specified file. It does the same thing as imwrite, but additionally writes metadata if the corresponding format supports it.
      Parameters:
      filename - Name of the file. As with imwrite, image format is determined by the file extension.
      img - (Mat or vector of Mat) Image or Images to be saved.
      metadataTypes - Vector with types of metadata chucks stored in metadata to write, see ImageMetadataType.
      metadata - Vector of vectors or vector of matrices with chunks of metadata to store into the file
      Returns:
      automatically generated
    • imwritemulti

      public static boolean imwritemulti(String filename, List<Mat> img, MatOfInt params)
    • imwritemulti

      public static boolean imwritemulti(String filename, List<Mat> img)
    • imdecode

      public static Mat imdecode(Mat buf, int flags)
      Reads an image from a buffer in memory. The function imdecode reads an image from the specified buffer in the memory. If the buffer is too short or contains invalid data, the function returns an empty matrix ( Mat::data==NULL ). See cv::imread for the list of supported formats and flags description. Note: In the case of color images, the decoded images will have the channels stored in B G R order.
      Parameters:
      buf - Input array or vector of bytes.
      flags - The same flags as in cv::imread, see cv::ImreadModes.
      Returns:
      automatically generated
    • imdecodeWithMetadata

      public static Mat imdecodeWithMetadata(Mat buf, MatOfInt metadataTypes, List<Mat> metadata, int flags)
      Reads an image from a buffer in memory together with associated metadata. The function imdecode reads an image from the specified buffer in the memory. If the buffer is too short or contains invalid data, the function returns an empty matrix ( Mat::data==NULL ). See cv::imread for the list of supported formats and flags description. Note: In the case of color images, the decoded images will have the channels stored in B G R order.
      Parameters:
      buf - Input array or vector of bytes.
      metadataTypes - Output vector with types of metadata chucks returned in metadata, see ImageMetadataType.
      metadata - Output vector of vectors or vector of matrices to store the retrieved metadata
      flags - The same flags as in cv::imread, see cv::ImreadModes.
      Returns:
      automatically generated
    • imdecodeWithMetadata

      public static Mat imdecodeWithMetadata(Mat buf, MatOfInt metadataTypes, List<Mat> metadata)
      Reads an image from a buffer in memory together with associated metadata. The function imdecode reads an image from the specified buffer in the memory. If the buffer is too short or contains invalid data, the function returns an empty matrix ( Mat::data==NULL ). See cv::imread for the list of supported formats and flags description. Note: In the case of color images, the decoded images will have the channels stored in B G R order.
      Parameters:
      buf - Input array or vector of bytes.
      metadataTypes - Output vector with types of metadata chucks returned in metadata, see ImageMetadataType.
      metadata - Output vector of vectors or vector of matrices to store the retrieved metadata
      Returns:
      automatically generated
    • imdecodemulti

      public static boolean imdecodemulti(Mat buf, int flags, List<Mat> mats, Range range)
      Reads a multi-page image from a buffer in memory. The function imdecodemulti reads a multi-page image from the specified buffer in the memory. If the buffer is too short or contains invalid data, the function returns false. See cv::imreadmulti for the list of supported formats and flags description. Note: In the case of color images, the decoded images will have the channels stored in B G R order.
      Parameters:
      buf - Input array or vector of bytes.
      flags - The same flags as in cv::imread, see cv::ImreadModes.
      mats - A vector of Mat objects holding each page, if more than one.
      range - A continuous selection of pages.
      Returns:
      automatically generated
    • imdecodemulti

      public static boolean imdecodemulti(Mat buf, int flags, List<Mat> mats)
      Reads a multi-page image from a buffer in memory. The function imdecodemulti reads a multi-page image from the specified buffer in the memory. If the buffer is too short or contains invalid data, the function returns false. See cv::imreadmulti for the list of supported formats and flags description. Note: In the case of color images, the decoded images will have the channels stored in B G R order.
      Parameters:
      buf - Input array or vector of bytes.
      flags - The same flags as in cv::imread, see cv::ImreadModes.
      mats - A vector of Mat objects holding each page, if more than one.
      Returns:
      automatically generated
    • imencode

      public static boolean imencode(String ext, Mat img, MatOfByte buf, MatOfInt params)
      Encodes an image into a memory buffer. The function imencode compresses the image and stores it in the memory buffer that is resized to fit the result. See cv::imwrite for the list of supported formats and flags description.
      Parameters:
      ext - File extension that defines the output format. Must include a leading period.
      img - Image to be compressed.
      buf - Output buffer resized to fit the compressed image.
      params - Format-specific parameters. See cv::imwrite and cv::ImwriteFlags.
      Returns:
      automatically generated
    • imencode

      public static boolean imencode(String ext, Mat img, MatOfByte buf)
      Encodes an image into a memory buffer. The function imencode compresses the image and stores it in the memory buffer that is resized to fit the result. See cv::imwrite for the list of supported formats and flags description.
      Parameters:
      ext - File extension that defines the output format. Must include a leading period.
      img - Image to be compressed.
      buf - Output buffer resized to fit the compressed image.
      Returns:
      automatically generated
    • imencodeWithMetadata

      public static boolean imencodeWithMetadata(String ext, Mat img, MatOfInt metadataTypes, List<Mat> metadata, MatOfByte buf, MatOfInt params)
      Encodes an image into a memory buffer. The function imencode compresses the image and stores it in the memory buffer that is resized to fit the result. See cv::imwrite for the list of supported formats and flags description.
      Parameters:
      ext - File extension that defines the output format. Must include a leading period.
      img - Image to be compressed.
      metadataTypes - Vector with types of metadata chucks stored in metadata to write, see ImageMetadataType.
      metadata - Vector of vectors or vector of matrices with chunks of metadata to store into the file
      buf - Output buffer resized to fit the compressed image.
      params - Format-specific parameters. See cv::imwrite and cv::ImwriteFlags.
      Returns:
      automatically generated
    • imencodeWithMetadata

      public static boolean imencodeWithMetadata(String ext, Mat img, MatOfInt metadataTypes, List<Mat> metadata, MatOfByte buf)
      Encodes an image into a memory buffer. The function imencode compresses the image and stores it in the memory buffer that is resized to fit the result. See cv::imwrite for the list of supported formats and flags description.
      Parameters:
      ext - File extension that defines the output format. Must include a leading period.
      img - Image to be compressed.
      metadataTypes - Vector with types of metadata chucks stored in metadata to write, see ImageMetadataType.
      metadata - Vector of vectors or vector of matrices with chunks of metadata to store into the file
      buf - Output buffer resized to fit the compressed image.
      Returns:
      automatically generated
    • imencodemulti

      public static boolean imencodemulti(String ext, List<Mat> imgs, MatOfByte buf, MatOfInt params)
      Encodes array of images into a memory buffer. The function is analog to cv::imencode for in-memory multi-page image compression. See cv::imwrite for the list of supported formats and flags description.
      Parameters:
      ext - File extension that defines the output format. Must include a leading period.
      imgs - Vector of images to be written.
      buf - Output buffer resized to fit the compressed data.
      params - Format-specific parameters. See cv::imwrite and cv::ImwriteFlags.
      Returns:
      automatically generated
    • imencodemulti

      public static boolean imencodemulti(String ext, List<Mat> imgs, MatOfByte buf)
      Encodes array of images into a memory buffer. The function is analog to cv::imencode for in-memory multi-page image compression. See cv::imwrite for the list of supported formats and flags description.
      Parameters:
      ext - File extension that defines the output format. Must include a leading period.
      imgs - Vector of images to be written.
      buf - Output buffer resized to fit the compressed data.
      Returns:
      automatically generated
    • haveImageReader

      public static boolean haveImageReader(String filename)
      Checks if the specified image file can be decoded by OpenCV. The function haveImageReader checks if OpenCV is capable of reading the specified file. This can be useful for verifying support for a given image format before attempting to load an image.
      Parameters:
      filename - The name of the file to be checked.
      Returns:
      true if an image reader for the specified file is available and the file can be opened, false otherwise. Note: The function checks the availability of image codecs that are either built into OpenCV or dynamically loaded. It does not load the image codec implementation and decode data, but uses signature check. If the file cannot be opened or the format is unsupported, the function will return false. SEE: cv::haveImageWriter, cv::imread, cv::imdecode
    • haveImageWriter

      public static boolean haveImageWriter(String filename)
      Checks if the specified image file or specified file extension can be encoded by OpenCV. The function haveImageWriter checks if OpenCV is capable of writing images with the specified file extension. This can be useful for verifying support for a given image format before attempting to save an image.
      Parameters:
      filename - The name of the file or the file extension (e.g., ".jpg", ".png"). It is recommended to provide the file extension rather than the full file name.
      Returns:
      true if an image writer for the specified extension is available, false otherwise. Note: The function checks the availability of image codecs that are either built into OpenCV or dynamically loaded. It does not check for the actual existence of the file but rather the ability to write files of the given type. SEE: cv::haveImageReader, cv::imwrite, cv::imencode