public class Imgcodecs extends Object
| Constructor and Description |
|---|
Imgcodecs() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
haveImageReader(String filename)
Checks if the specified image file can be decoded by OpenCV.
|
static boolean |
haveImageWriter(String filename)
Checks if the specified image file or specified file extension can be encoded by OpenCV.
|
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.
|
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.
|
static Mat |
imdecode(Mat buf,
int flags)
Reads an image from a buffer in memory.
|
static boolean |
imdecodeanimation(Mat buf,
Animation animation)
Loads frames from an animated image buffer into an Animation structure.
|
static boolean |
imdecodeanimation(Mat buf,
Animation animation,
int start)
Loads frames from an animated image buffer into an Animation structure.
|
static boolean |
imdecodeanimation(Mat buf,
Animation animation,
int start,
int count)
Loads frames from an animated image buffer into an Animation structure.
|
static boolean |
imdecodemulti(Mat buf,
int flags,
List<Mat> mats)
Reads a multi-page image from a buffer in memory.
|
static boolean |
imdecodemulti(Mat buf,
int flags,
List<Mat> mats,
Range range)
Reads a multi-page image from a buffer in memory.
|
static Mat |
imdecodeWithMetadata(Mat buf,
MatOfInt metadataTypes,
List<Mat> metadata)
Reads an image from a memory buffer and extracts associated metadata.
|
static Mat |
imdecodeWithMetadata(Mat buf,
MatOfInt metadataTypes,
List<Mat> metadata,
int flags)
Reads an image from a memory buffer and extracts associated metadata.
|
static boolean |
imencode(String ext,
Mat img,
MatOfByte buf)
Encodes an image into a memory buffer.
|
static boolean |
imencode(String ext,
Mat img,
MatOfByte buf,
MatOfInt params)
Encodes an image into a memory buffer.
|
static boolean |
imencodeanimation(String ext,
Animation animation,
MatOfByte buf)
Encodes an Animation to a memory buffer.
|
static boolean |
imencodeanimation(String ext,
Animation animation,
MatOfByte buf,
MatOfInt params)
Encodes an Animation to a memory buffer.
|
static boolean |
imencodemulti(String ext,
List<Mat> imgs,
MatOfByte buf)
Encodes array of images into a memory buffer.
|
static boolean |
imencodemulti(String ext,
List<Mat> imgs,
MatOfByte buf,
MatOfInt params)
Encodes array of images into a memory buffer.
|
static boolean |
imencodeWithMetadata(String ext,
Mat img,
MatOfInt metadataTypes,
List<Mat> metadata,
MatOfByte buf)
Encodes an image into a memory buffer.
|
static boolean |
imencodeWithMetadata(String ext,
Mat img,
MatOfInt metadataTypes,
List<Mat> metadata,
MatOfByte buf,
MatOfInt params)
Encodes an image into a memory buffer.
|
static Mat |
imread(String filename)
Loads an image from a file.
|
static Mat |
imread(String filename,
int flags)
Loads an image from a file.
|
static void |
imread(String filename,
Mat dst)
Loads an image from a file.
|
static void |
imread(String filename,
Mat dst,
int flags)
Loads an image from a file.
|
static boolean |
imreadanimation(String filename,
Animation animation)
Loads frames from an animated image file into an Animation structure.
|
static boolean |
imreadanimation(String filename,
Animation animation,
int start)
Loads frames from an animated image file into an Animation structure.
|
static boolean |
imreadanimation(String filename,
Animation animation,
int start,
int count)
Loads frames from an animated image file into an Animation structure.
|
static boolean |
imreadmulti(String filename,
List<Mat> mats)
Loads a multi-page image from a file.
|
static boolean |
imreadmulti(String filename,
List<Mat> mats,
int flags)
Loads a multi-page image from a file.
|
static boolean |
imreadmulti(String filename,
List<Mat> mats,
int start,
int count)
Loads images of a multi-page image from a file.
|
static boolean |
imreadmulti(String filename,
List<Mat> mats,
int start,
int count,
int flags)
Loads images of a multi-page image from a file.
|
static Mat |
imreadWithMetadata(String filename,
MatOfInt metadataTypes,
List<Mat> metadata)
Reads an image from a file along with associated metadata.
|
static Mat |
imreadWithMetadata(String filename,
MatOfInt metadataTypes,
List<Mat> metadata,
int flags)
Reads an image from a file along with associated metadata.
|
static boolean |
imwrite(String filename,
Mat img)
Saves an image to a specified file.
|
static boolean |
imwrite(String filename,
Mat img,
MatOfInt params)
Saves an image to a specified file.
|
static boolean |
imwriteanimation(String filename,
Animation animation)
Saves an Animation to a specified file.
|
static boolean |
imwriteanimation(String filename,
Animation animation,
MatOfInt params)
Saves an Animation to a specified file.
|
static boolean |
imwritemulti(String filename,
List<Mat> img) |
static boolean |
imwritemulti(String filename,
List<Mat> img,
MatOfInt params) |
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.
|
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.
|
public static final int IMAGE_METADATA_UNKNOWN
public static final int IMAGE_METADATA_EXIF
public static final int IMAGE_METADATA_XMP
public static final int IMAGE_METADATA_ICCP
public static final int IMAGE_METADATA_CICP
public static final int IMAGE_METADATA_MAX
public static final int IMREAD_UNCHANGED
public static final int IMREAD_GRAYSCALE
public static final int IMREAD_COLOR_BGR
public static final int IMREAD_COLOR
public static final int IMREAD_ANYDEPTH
public static final int IMREAD_ANYCOLOR
public static final int IMREAD_LOAD_GDAL
public static final int IMREAD_REDUCED_GRAYSCALE_2
public static final int IMREAD_REDUCED_COLOR_2
public static final int IMREAD_REDUCED_GRAYSCALE_4
public static final int IMREAD_REDUCED_COLOR_4
public static final int IMREAD_REDUCED_GRAYSCALE_8
public static final int IMREAD_REDUCED_COLOR_8
public static final int IMREAD_IGNORE_ORIENTATION
public static final int IMREAD_COLOR_RGB
public static final int IMWRITE_BMP_COMPRESSION_RGB
public static final int IMWRITE_BMP_COMPRESSION_BITFIELDS
public static final int IMWRITE_EXR_COMPRESSION_NO
public static final int IMWRITE_EXR_COMPRESSION_RLE
public static final int IMWRITE_EXR_COMPRESSION_ZIPS
public static final int IMWRITE_EXR_COMPRESSION_ZIP
public static final int IMWRITE_EXR_COMPRESSION_PIZ
public static final int IMWRITE_EXR_COMPRESSION_PXR24
public static final int IMWRITE_EXR_COMPRESSION_B44
public static final int IMWRITE_EXR_COMPRESSION_B44A
public static final int IMWRITE_EXR_COMPRESSION_DWAA
public static final int IMWRITE_EXR_COMPRESSION_DWAB
public static final int IMWRITE_EXR_TYPE_HALF
public static final int IMWRITE_EXR_TYPE_FLOAT
public static final int IMWRITE_JPEG_QUALITY
public static final int IMWRITE_JPEG_PROGRESSIVE
public static final int IMWRITE_JPEG_OPTIMIZE
public static final int IMWRITE_JPEG_RST_INTERVAL
public static final int IMWRITE_JPEG_LUMA_QUALITY
public static final int IMWRITE_JPEG_CHROMA_QUALITY
public static final int IMWRITE_JPEG_SAMPLING_FACTOR
public static final int IMWRITE_PNG_COMPRESSION
public static final int IMWRITE_PNG_STRATEGY
public static final int IMWRITE_PNG_BILEVEL
public static final int IMWRITE_PNG_FILTER
public static final int IMWRITE_PNG_ZLIBBUFFER_SIZE
public static final int IMWRITE_PXM_BINARY
public static final int IMWRITE_EXR_TYPE
public static final int IMWRITE_EXR_COMPRESSION
public static final int IMWRITE_EXR_DWA_COMPRESSION_LEVEL
public static final int IMWRITE_WEBP_QUALITY
public static final int IMWRITE_HDR_COMPRESSION
public static final int IMWRITE_PAM_TUPLETYPE
public static final int IMWRITE_TIFF_RESUNIT
public static final int IMWRITE_TIFF_XDPI
public static final int IMWRITE_TIFF_YDPI
public static final int IMWRITE_TIFF_COMPRESSION
public static final int IMWRITE_TIFF_ROWSPERSTRIP
public static final int IMWRITE_TIFF_PREDICTOR
public static final int IMWRITE_JPEG2000_COMPRESSION_X1000
public static final int IMWRITE_AVIF_QUALITY
public static final int IMWRITE_AVIF_DEPTH
public static final int IMWRITE_AVIF_SPEED
public static final int IMWRITE_JPEGXL_QUALITY
public static final int IMWRITE_JPEGXL_EFFORT
public static final int IMWRITE_JPEGXL_DISTANCE
public static final int IMWRITE_JPEGXL_DECODING_SPEED
public static final int IMWRITE_BMP_COMPRESSION
public static final int IMWRITE_GIF_LOOP
public static final int IMWRITE_GIF_SPEED
public static final int IMWRITE_GIF_QUALITY
public static final int IMWRITE_GIF_DITHER
public static final int IMWRITE_GIF_TRANSPARENCY
public static final int IMWRITE_GIF_COLORTABLE
public static final int IMWRITE_GIF_FAST_NO_DITHER
public static final int IMWRITE_GIF_FAST_FLOYD_DITHER
public static final int IMWRITE_GIF_COLORTABLE_SIZE_8
public static final int IMWRITE_GIF_COLORTABLE_SIZE_16
public static final int IMWRITE_GIF_COLORTABLE_SIZE_32
public static final int IMWRITE_GIF_COLORTABLE_SIZE_64
public static final int IMWRITE_GIF_COLORTABLE_SIZE_128
public static final int IMWRITE_GIF_COLORTABLE_SIZE_256
public static final int IMWRITE_HDR_COMPRESSION_NONE
public static final int IMWRITE_HDR_COMPRESSION_RLE
public static final int IMWRITE_JPEG_SAMPLING_FACTOR_411
public static final int IMWRITE_JPEG_SAMPLING_FACTOR_420
public static final int IMWRITE_JPEG_SAMPLING_FACTOR_422
public static final int IMWRITE_JPEG_SAMPLING_FACTOR_440
public static final int IMWRITE_JPEG_SAMPLING_FACTOR_444
public static final int IMWRITE_PAM_FORMAT_NULL
public static final int IMWRITE_PAM_FORMAT_BLACKANDWHITE
public static final int IMWRITE_PAM_FORMAT_GRAYSCALE
public static final int IMWRITE_PAM_FORMAT_GRAYSCALE_ALPHA
public static final int IMWRITE_PAM_FORMAT_RGB
public static final int IMWRITE_PAM_FORMAT_RGB_ALPHA
public static final int IMWRITE_PNG_FILTER_NONE
public static final int IMWRITE_PNG_FILTER_SUB
public static final int IMWRITE_PNG_FILTER_UP
public static final int IMWRITE_PNG_FILTER_AVG
public static final int IMWRITE_PNG_FILTER_PAETH
public static final int IMWRITE_PNG_FAST_FILTERS
public static final int IMWRITE_PNG_ALL_FILTERS
public static final int IMWRITE_PNG_STRATEGY_DEFAULT
public static final int IMWRITE_PNG_STRATEGY_FILTERED
public static final int IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY
public static final int IMWRITE_PNG_STRATEGY_RLE
public static final int IMWRITE_PNG_STRATEGY_FIXED
public static final int IMWRITE_TIFF_COMPRESSION_NONE
public static final int IMWRITE_TIFF_COMPRESSION_CCITTRLE
public static final int IMWRITE_TIFF_COMPRESSION_CCITTFAX3
public static final int IMWRITE_TIFF_COMPRESSION_CCITT_T4
public static final int IMWRITE_TIFF_COMPRESSION_CCITTFAX4
public static final int IMWRITE_TIFF_COMPRESSION_CCITT_T6
public static final int IMWRITE_TIFF_COMPRESSION_LZW
public static final int IMWRITE_TIFF_COMPRESSION_OJPEG
public static final int IMWRITE_TIFF_COMPRESSION_JPEG
public static final int IMWRITE_TIFF_COMPRESSION_T85
public static final int IMWRITE_TIFF_COMPRESSION_T43
public static final int IMWRITE_TIFF_COMPRESSION_NEXT
public static final int IMWRITE_TIFF_COMPRESSION_CCITTRLEW
public static final int IMWRITE_TIFF_COMPRESSION_PACKBITS
public static final int IMWRITE_TIFF_COMPRESSION_THUNDERSCAN
public static final int IMWRITE_TIFF_COMPRESSION_IT8CTPAD
public static final int IMWRITE_TIFF_COMPRESSION_IT8LW
public static final int IMWRITE_TIFF_COMPRESSION_IT8MP
public static final int IMWRITE_TIFF_COMPRESSION_IT8BL
public static final int IMWRITE_TIFF_COMPRESSION_PIXARFILM
public static final int IMWRITE_TIFF_COMPRESSION_PIXARLOG
public static final int IMWRITE_TIFF_COMPRESSION_DEFLATE
public static final int IMWRITE_TIFF_COMPRESSION_ADOBE_DEFLATE
public static final int IMWRITE_TIFF_COMPRESSION_DCS
public static final int IMWRITE_TIFF_COMPRESSION_JBIG
public static final int IMWRITE_TIFF_COMPRESSION_SGILOG
public static final int IMWRITE_TIFF_COMPRESSION_SGILOG24
public static final int IMWRITE_TIFF_COMPRESSION_JP2000
public static final int IMWRITE_TIFF_COMPRESSION_LERC
public static final int IMWRITE_TIFF_COMPRESSION_LZMA
public static final int IMWRITE_TIFF_COMPRESSION_ZSTD
public static final int IMWRITE_TIFF_COMPRESSION_WEBP
public static final int IMWRITE_TIFF_COMPRESSION_JXL
public static final int IMWRITE_TIFF_PREDICTOR_NONE
public static final int IMWRITE_TIFF_PREDICTOR_HORIZONTAL
public static final int IMWRITE_TIFF_PREDICTOR_FLOATINGPOINT
public static final int IMWRITE_TIFF_RESOLUTION_UNIT_NONE
public static final int IMWRITE_TIFF_RESOLUTION_UNIT_INCH
public static final int IMWRITE_TIFF_RESOLUTION_UNIT_CENTIMETER
public static Mat imread(String filename, int flags)
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:
OPENCV_IO_MAX_IMAGE_PIXELS. See REF: tutorial_env_reference.
filename - Name of the file to be loaded.flags - Flag that can take values of cv::ImreadModes, default with cv::IMREAD_COLOR_BGR.public static Mat imread(String filename)
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:
OPENCV_IO_MAX_IMAGE_PIXELS. See REF: tutorial_env_reference.
filename - Name of the file to be loaded.public static void imread(String filename, Mat dst, int flags)
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, default with cv::IMREAD_COLOR_BGR.
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.public static void imread(String filename, Mat dst)
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.public static Mat imreadWithMetadata(String filename, MatOfInt metadataTypes, List<Mat> metadata, int flags)
filename - Name of the file to be loaded.metadataTypes - Output vector with types of metadata chunks 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, default with cv::IMREAD_ANYCOLOR.public static Mat imreadWithMetadata(String filename, MatOfInt metadataTypes, List<Mat> metadata)
filename - Name of the file to be loaded.metadataTypes - Output vector with types of metadata chunks returned in metadata, see ImageMetadataType.metadata - Output vector of vectors or vector of matrices to store the retrieved metadata.public static boolean imreadmulti(String filename, List<Mat> mats, int flags)
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::imreadpublic static boolean imreadmulti(String filename, List<Mat> mats)
filename - Name of file to be loaded.mats - A vector of Mat objects holding each page.
SEE: cv::imreadpublic static boolean imreadmulti(String filename, List<Mat> mats, int start, int count, int flags)
filename - Name of file to be loaded.mats - A vector of Mat objects holding each page.start - Start index of the image to loadcount - Count number of images to loadflags - Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR.
SEE: cv::imreadpublic static boolean imreadmulti(String filename, List<Mat> mats, int start, int count)
filename - Name of file to be loaded.mats - A vector of Mat objects holding each page.start - Start index of the image to loadcount - Count number of images to load
SEE: cv::imreadpublic static boolean imreadanimation(String filename, Animation animation, int start, int count)
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.public static boolean imreadanimation(String filename, Animation animation, int start)
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.public static boolean imreadanimation(String filename, Animation animation)
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.public static boolean imdecodeanimation(Mat buf, Animation animation, int start, int count)
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.public static boolean imdecodeanimation(Mat buf, Animation animation, int start)
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.public static boolean imdecodeanimation(Mat buf, Animation animation)
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.public static boolean imwriteanimation(String filename, Animation animation, MatOfInt params)
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.public static boolean imwriteanimation(String filename, Animation animation)
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.public static boolean imencodeanimation(String ext, Animation animation, MatOfByte buf, MatOfInt params)
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.public static boolean imencodeanimation(String ext, Animation animation, MatOfByte buf)
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.public static long imcount(String filename, int flags)
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.public static long imcount(String filename)
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.public static boolean imwrite(String filename, Mat img, MatOfInt params)
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::ImwriteFlagspublic static boolean imwrite(String filename, Mat img)
filename - Name of the file.img - (Mat or vector of Mat) Image or Images to be saved.public static boolean imwriteWithMetadata(String filename, Mat img, MatOfInt metadataTypes, List<Mat> metadata, MatOfInt params)
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 fileparams - Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::ImwriteFlagspublic static boolean imwriteWithMetadata(String filename, Mat img, MatOfInt metadataTypes, List<Mat> metadata)
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 filepublic static Mat imdecode(Mat buf, int flags)
buf - Input array or vector of bytes.flags - Flag that can take values of cv::ImreadModes.public static Mat imdecodeWithMetadata(Mat buf, MatOfInt metadataTypes, List<Mat> metadata, int flags)
buf - Input array or vector of bytes containing the encoded image data.metadataTypes - Output vector with types of metadata chucks returned in metadata, see cv::ImageMetadataTypemetadata - Output vector of vectors or vector of matrices to store the retrieved metadataflags - Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR.public static Mat imdecodeWithMetadata(Mat buf, MatOfInt metadataTypes, List<Mat> metadata)
buf - Input array or vector of bytes containing the encoded image data.metadataTypes - Output vector with types of metadata chucks returned in metadata, see cv::ImageMetadataTypemetadata - Output vector of vectors or vector of matrices to store the retrieved metadatapublic static boolean imdecodemulti(Mat buf, int flags, List<Mat> mats, Range range)
buf - Input array or vector of bytes.flags - Flag that can take values of cv::ImreadModes.mats - A vector of Mat objects holding each page, if more than one.range - A continuous selection of pages.public static boolean imdecodemulti(Mat buf, int flags, List<Mat> mats)
buf - Input array or vector of bytes.flags - Flag that can take values of cv::ImreadModes.mats - A vector of Mat objects holding each page, if more than one.public static boolean imencode(String ext, Mat img, MatOfByte buf, MatOfInt params)
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.public static boolean imencode(String ext, Mat img, MatOfByte buf)
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.public static boolean imencodeWithMetadata(String ext, Mat img, MatOfInt metadataTypes, List<Mat> metadata, MatOfByte buf, MatOfInt params)
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 filebuf - Output buffer resized to fit the compressed image.params - Format-specific parameters. See cv::imwrite and cv::ImwriteFlags.public static boolean imencodeWithMetadata(String ext, Mat img, MatOfInt metadataTypes, List<Mat> metadata, MatOfByte buf)
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 filebuf - Output buffer resized to fit the compressed image.public static boolean imencodemulti(String ext, List<Mat> imgs, MatOfByte buf, MatOfInt params)
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.public static boolean imencodemulti(String ext, List<Mat> imgs, MatOfByte buf)
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.public static boolean haveImageReader(String filename)
filename - The name of the file to be checked.public static boolean haveImageWriter(String filename)
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.Copyright © 2026. All rights reserved.