public class opencv_imgcodecs extends opencv_imgcodecs
| Modifier and Type | Field and Description |
|---|---|
static int |
CV_CVTIMG_FLIP
enum
|
static int |
CV_CVTIMG_SWAP_RB
enum
|
static int |
CV_IMWRITE_JPEG_CHROMA_QUALITY
enum
|
static int |
CV_IMWRITE_JPEG_LUMA_QUALITY
enum
|
static int |
CV_IMWRITE_JPEG_OPTIMIZE
enum
|
static int |
CV_IMWRITE_JPEG_PROGRESSIVE
enum
|
static int |
CV_IMWRITE_JPEG_QUALITY
enum
|
static int |
CV_IMWRITE_JPEG_RST_INTERVAL
enum
|
static int |
CV_IMWRITE_PNG_BILEVEL
enum
|
static int |
CV_IMWRITE_PNG_COMPRESSION
enum
|
static int |
CV_IMWRITE_PNG_STRATEGY
enum
|
static int |
CV_IMWRITE_PNG_STRATEGY_DEFAULT
enum
|
static int |
CV_IMWRITE_PNG_STRATEGY_FILTERED
enum
|
static int |
CV_IMWRITE_PNG_STRATEGY_FIXED
enum
|
static int |
CV_IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY
enum
|
static int |
CV_IMWRITE_PNG_STRATEGY_RLE
enum
|
static int |
CV_IMWRITE_PXM_BINARY
enum
|
static int |
CV_IMWRITE_WEBP_QUALITY
enum
|
static int |
CV_LOAD_IMAGE_ANYCOLOR
enum
|
static int |
CV_LOAD_IMAGE_ANYDEPTH
enum
|
static int |
CV_LOAD_IMAGE_COLOR
enum
|
static int |
CV_LOAD_IMAGE_GRAYSCALE
enum
|
static int |
CV_LOAD_IMAGE_UNCHANGED
enum
|
static int |
IMREAD_ANYCOLOR
enum cv::ImreadModes
|
static int |
IMREAD_ANYDEPTH
enum cv::ImreadModes
|
static int |
IMREAD_COLOR
enum cv::ImreadModes
|
static int |
IMREAD_GRAYSCALE
enum cv::ImreadModes
|
static int |
IMREAD_LOAD_GDAL
enum cv::ImreadModes
|
static int |
IMREAD_REDUCED_COLOR_2
enum cv::ImreadModes
|
static int |
IMREAD_REDUCED_COLOR_4
enum cv::ImreadModes
|
static int |
IMREAD_REDUCED_COLOR_8
enum cv::ImreadModes
|
static int |
IMREAD_REDUCED_GRAYSCALE_2
enum cv::ImreadModes
|
static int |
IMREAD_REDUCED_GRAYSCALE_4
enum cv::ImreadModes
|
static int |
IMREAD_REDUCED_GRAYSCALE_8
enum cv::ImreadModes
|
static int |
IMREAD_UNCHANGED
enum cv::ImreadModes
|
static int |
IMWRITE_JPEG_CHROMA_QUALITY
enum cv::ImwriteFlags
|
static int |
IMWRITE_JPEG_LUMA_QUALITY
enum cv::ImwriteFlags
|
static int |
IMWRITE_JPEG_OPTIMIZE
enum cv::ImwriteFlags
|
static int |
IMWRITE_JPEG_PROGRESSIVE
enum cv::ImwriteFlags
|
static int |
IMWRITE_JPEG_QUALITY
enum cv::ImwriteFlags
|
static int |
IMWRITE_JPEG_RST_INTERVAL
enum cv::ImwriteFlags
|
static int |
IMWRITE_PNG_BILEVEL
enum cv::ImwriteFlags
|
static int |
IMWRITE_PNG_COMPRESSION
enum cv::ImwriteFlags
|
static int |
IMWRITE_PNG_STRATEGY
enum cv::ImwriteFlags
|
static int |
IMWRITE_PNG_STRATEGY_DEFAULT
enum cv::ImwritePNGFlags
|
static int |
IMWRITE_PNG_STRATEGY_FILTERED
enum cv::ImwritePNGFlags
|
static int |
IMWRITE_PNG_STRATEGY_FIXED
enum cv::ImwritePNGFlags
|
static int |
IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY
enum cv::ImwritePNGFlags
|
static int |
IMWRITE_PNG_STRATEGY_RLE
enum cv::ImwritePNGFlags
|
static int |
IMWRITE_PXM_BINARY
enum cv::ImwriteFlags
|
static int |
IMWRITE_WEBP_QUALITY
enum cv::ImwriteFlags
|
| Constructor and Description |
|---|
opencv_imgcodecs() |
cvLoadImageBGRA, cvLoadImageRGBAmappublic static final int CV_LOAD_IMAGE_UNCHANGED
public static final int CV_LOAD_IMAGE_GRAYSCALE
public static final int CV_LOAD_IMAGE_COLOR
public static final int CV_LOAD_IMAGE_ANYDEPTH
public static final int CV_LOAD_IMAGE_ANYCOLOR
public static final int CV_IMWRITE_JPEG_QUALITY
public static final int CV_IMWRITE_JPEG_PROGRESSIVE
public static final int CV_IMWRITE_JPEG_OPTIMIZE
public static final int CV_IMWRITE_JPEG_RST_INTERVAL
public static final int CV_IMWRITE_JPEG_LUMA_QUALITY
public static final int CV_IMWRITE_JPEG_CHROMA_QUALITY
public static final int CV_IMWRITE_PNG_COMPRESSION
public static final int CV_IMWRITE_PNG_STRATEGY
public static final int CV_IMWRITE_PNG_BILEVEL
public static final int CV_IMWRITE_PNG_STRATEGY_DEFAULT
public static final int CV_IMWRITE_PNG_STRATEGY_FILTERED
public static final int CV_IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY
public static final int CV_IMWRITE_PNG_STRATEGY_RLE
public static final int CV_IMWRITE_PNG_STRATEGY_FIXED
public static final int CV_IMWRITE_PXM_BINARY
public static final int CV_IMWRITE_WEBP_QUALITY
public static final int CV_CVTIMG_FLIP
public static final int CV_CVTIMG_SWAP_RB
public static final int IMREAD_UNCHANGED
public static final int IMREAD_GRAYSCALE
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 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_PNG_COMPRESSION
public static final int IMWRITE_PNG_STRATEGY
public static final int IMWRITE_PNG_BILEVEL
public static final int IMWRITE_PXM_BINARY
public static final int IMWRITE_WEBP_QUALITY
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 opencv_core.IplImage cvLoadImage(@Cast(value="const char*") BytePointer filename, int iscolor)
public static opencv_core.IplImage cvLoadImage(@Cast(value="const char*") BytePointer filename)
public static opencv_core.IplImage cvLoadImage(String filename, int iscolor)
public static opencv_core.IplImage cvLoadImage(String filename)
public static opencv_core.CvMat cvLoadImageM(@Cast(value="const char*") BytePointer filename, int iscolor)
public static opencv_core.CvMat cvLoadImageM(@Cast(value="const char*") BytePointer filename)
public static opencv_core.CvMat cvLoadImageM(String filename, int iscolor)
public static opencv_core.CvMat cvLoadImageM(String filename)
public static int cvSaveImage(@Cast(value="const char*") BytePointer filename, @Const opencv_core.CvArr image, @Const IntPointer params)
public static int cvSaveImage(@Cast(value="const char*") BytePointer filename, @Const opencv_core.CvArr image)
public static int cvSaveImage(String filename, @Const opencv_core.CvArr image, @Const IntBuffer params)
public static int cvSaveImage(String filename, @Const opencv_core.CvArr image)
public static int cvSaveImage(@Cast(value="const char*") BytePointer filename, @Const opencv_core.CvArr image, @Const int[] params)
public static int cvSaveImage(String filename, @Const opencv_core.CvArr image, @Const IntPointer params)
public static int cvSaveImage(@Cast(value="const char*") BytePointer filename, @Const opencv_core.CvArr image, @Const IntBuffer params)
public static int cvSaveImage(String filename, @Const opencv_core.CvArr image, @Const int[] params)
public static opencv_core.IplImage cvDecodeImage(@Const opencv_core.CvMat buf, int iscolor)
public static opencv_core.IplImage cvDecodeImage(@Const opencv_core.CvMat buf)
public static opencv_core.CvMat cvDecodeImageM(@Const opencv_core.CvMat buf, int iscolor)
public static opencv_core.CvMat cvDecodeImageM(@Const opencv_core.CvMat buf)
public static opencv_core.CvMat cvEncodeImage(@Cast(value="const char*") BytePointer ext, @Const opencv_core.CvArr image, @Const IntPointer params)
public static opencv_core.CvMat cvEncodeImage(@Cast(value="const char*") BytePointer ext, @Const opencv_core.CvArr image)
public static opencv_core.CvMat cvEncodeImage(String ext, @Const opencv_core.CvArr image, @Const IntBuffer params)
public static opencv_core.CvMat cvEncodeImage(String ext, @Const opencv_core.CvArr image)
public static opencv_core.CvMat cvEncodeImage(@Cast(value="const char*") BytePointer ext, @Const opencv_core.CvArr image, @Const int[] params)
public static opencv_core.CvMat cvEncodeImage(String ext, @Const opencv_core.CvArr image, @Const IntPointer params)
public static opencv_core.CvMat cvEncodeImage(@Cast(value="const char*") BytePointer ext, @Const opencv_core.CvArr image, @Const IntBuffer params)
public static opencv_core.CvMat cvEncodeImage(String ext, @Const opencv_core.CvArr image, @Const int[] params)
public static void cvConvertImage(@Const opencv_core.CvArr src, opencv_core.CvArr dst, int flags)
public static void cvConvertImage(@Const opencv_core.CvArr src, opencv_core.CvArr dst)
public static int cvHaveImageReader(@Cast(value="const char*") BytePointer filename)
public static int cvHaveImageReader(String filename)
public static int cvHaveImageWriter(@Cast(value="const char*") BytePointer filename)
public static int cvHaveImageWriter(String filename)
public static opencv_core.IplImage cvvLoadImage(@Cast(value="const char*") BytePointer name)
public static opencv_core.IplImage cvvLoadImage(String name)
public static int cvvSaveImage(@Cast(value="const char*") BytePointer arg1, opencv_core.CvArr arg2, IntPointer arg3)
public static int cvvSaveImage(String arg1, opencv_core.CvArr arg2, IntBuffer arg3)
public static int cvvSaveImage(@Cast(value="const char*") BytePointer arg1, opencv_core.CvArr arg2, int[] arg3)
public static int cvvSaveImage(String arg1, opencv_core.CvArr arg2, IntPointer arg3)
public static int cvvSaveImage(@Cast(value="const char*") BytePointer arg1, opencv_core.CvArr arg2, IntBuffer arg3)
public static int cvvSaveImage(String arg1, opencv_core.CvArr arg2, int[] arg3)
public static void cvvConvertImage(opencv_core.CvArr arg1, opencv_core.CvArr arg2, int arg3)
@Namespace(value="cv") @ByVal public static opencv_core.Mat imread(@opencv_core.Str BytePointer filename, int flags)
\anchor imread
The function imread loads an image from the specified file and returns it. If the image cannot be read (because of missing file, improper permissions, unsupported or invalid format), the function returns an empty matrix ( Mat::data==NULL ).
Currently, the following file formats are supported:
- Windows bitmaps - \*.bmp, \*.dib (always supported) - JPEG files - \*.jpeg, \*.jpg, \*.jpe (see the *Notes* section) - JPEG 2000 files - \*.jp2 (see the *Notes* section) - Portable Network Graphics - \*.png (see the *Notes* section) - WebP - \*.webp (see the *Notes* section) - Portable image format - \*.pbm, \*.pgm, \*.ppm \*.pxm, \*.pnm (always supported) - Sun rasters - \*.sr, \*.ras (always supported) - TIFF files - \*.tiff, \*.tif (see the *Notes* section) - OpenEXR Image files - \*.exr (see the *Notes* section) - Radiance HDR - \*.hdr, \*.pic (always supported) - Raster and Vector geospatial data supported by Gdal (see the *Notes* section)
\note
- The function determines the type of an image by the 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. - On Microsoft Windows\* OS and MacOSX\*, the codecs shipped with an OpenCV image (libjpeg, libpng, libtiff, and libjasper) are used by default. So, OpenCV can always read JPEGs, PNGs, and TIFFs. On MacOSX, there is also an option to use native MacOSX image readers. But beware that currently these native image loaders give images with different pixel values because of the color management embedded into MacOSX. - On Linux\*, BSD flavors and other Unix-like open-source operating systems, OpenCV looks for codecs supplied with an OS image. Install the relevant packages (do not forget the development files, for example, "libjpeg-dev", in Debian\* and Ubuntu\*) to get the codec support or turn on the OPENCV_BUILD_3RDPARTY_LIBS flag in CMake. - In the case you set *WITH_GDAL* flag to true in CMake and \ref IMREAD_LOAD_GDAL to load the image, then [GDAL](http://www.gdal.org) driver will be used in order to decode the image by supporting the following formats: [Raster](http://www.gdal.org/formats_list.html), [Vector](http://www.gdal.org/ogr_formats.html).
filename - Name of file to be loaded.flags - Flag that can take values of cv::ImreadModes@Namespace(value="cv") @ByVal public static opencv_core.Mat imread(@opencv_core.Str BytePointer filename)
@Namespace(value="cv") @ByVal public static opencv_core.Mat imread(@opencv_core.Str String filename, int flags)
@Namespace(value="cv") @ByVal public static opencv_core.Mat imread(@opencv_core.Str String filename)
@Namespace(value="cv") @Cast(value="bool") public static boolean imreadmulti(@opencv_core.Str BytePointer filename, @ByRef opencv_core.MatVector mats, int flags)
The function imreadmulti loads a multi-page image from the specified file into a vector of Mat objects.
filename - Name of file to be loaded.flags - Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR.mats - A vector of Mat objects holding each page, if more than one.
\sa cv::imread@Namespace(value="cv") @Cast(value="bool") public static boolean imreadmulti(@opencv_core.Str BytePointer filename, @ByRef opencv_core.MatVector mats)
@Namespace(value="cv") @Cast(value="bool") public static boolean imreadmulti(@opencv_core.Str String filename, @ByRef opencv_core.MatVector mats, int flags)
@Namespace(value="cv") @Cast(value="bool") public static boolean imreadmulti(@opencv_core.Str String filename, @ByRef opencv_core.MatVector mats)
@Namespace(value="cv") @Cast(value="bool") public static boolean imwrite(@opencv_core.Str BytePointer filename, @ByVal opencv_core.Mat img, @StdVector IntPointer params)
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). Only 8-bit (or 16-bit unsigned (CV_16U) in case of PNG, JPEG 2000, and TIFF) single-channel or 3-channel (with 'BGR' channel order) images can be saved using this function. 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.
It is possible to store PNG images with an alpha channel using this function. To do this, create 8-bit (or 16-bit) 4-channel image BGRA, where the alpha channel goes last. Fully transparent pixels should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535.
The sample below shows how to create such a BGRA image and store to PNG file. It also demonstrates how to set custom compression parameters :
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
void createAlphaMat(Mat &mat)
{
CV_Assert(mat.channels() == 4);
for (int i = 0; i < mat.rows; ++i) {
for (int j = 0; j < mat.cols; ++j) {
Vec4b& bgra = mat.at<Vec4b>(i, j);
bgra[0] = UCHAR_MAX; // Blue
bgra[1] = saturate_cast<uchar>((float (mat.cols - j)) / ((float)mat.cols) * UCHAR_MAX); // Green
bgra[2] = saturate_cast<uchar>((float (mat.rows - i)) / ((float)mat.rows) * UCHAR_MAX); // Red
bgra[3] = saturate_cast<uchar>(0.5 * (bgra[1] + bgra[2])); // Alpha
}
}
}
int main(int argv, char **argc)
{
// Create mat with alpha channel
Mat mat(480, 640, CV_8UC4);
createAlphaMat(mat);
vector<int> compression_params;
compression_params.push_back(IMWRITE_PNG_COMPRESSION);
compression_params.push_back(9);
try {
imwrite("alpha.png", mat, compression_params);
}
catch (cv::Exception& ex) {
fprintf(stderr, "Exception converting image to PNG format: %s\n", ex.what());
return 1;
}
fprintf(stdout, "Saved PNG file with alpha data.\n");
return 0;
}
filename - Name of the file.img - Image to be saved.params - Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::ImwriteFlags@Namespace(value="cv") @Cast(value="bool") public static boolean imwrite(@opencv_core.Str BytePointer filename, @ByVal opencv_core.Mat img)
@Namespace(value="cv") @Cast(value="bool") public static boolean imwrite(@opencv_core.Str String filename, @ByVal opencv_core.Mat img, @StdVector IntBuffer params)
@Namespace(value="cv") @Cast(value="bool") public static boolean imwrite(@opencv_core.Str String filename, @ByVal opencv_core.Mat img)
@Namespace(value="cv") @Cast(value="bool") public static boolean imwrite(@opencv_core.Str BytePointer filename, @ByVal opencv_core.Mat img, @StdVector int[] params)
@Namespace(value="cv") @Cast(value="bool") public static boolean imwrite(@opencv_core.Str String filename, @ByVal opencv_core.Mat img, @StdVector IntPointer params)
@Namespace(value="cv") @Cast(value="bool") public static boolean imwrite(@opencv_core.Str BytePointer filename, @ByVal opencv_core.Mat img, @StdVector IntBuffer params)
@Namespace(value="cv") @Cast(value="bool") public static boolean imwrite(@opencv_core.Str String filename, @ByVal opencv_core.Mat img, @StdVector int[] params)
@Namespace(value="cv") @ByVal public static opencv_core.Mat imdecode(@ByVal opencv_core.Mat buf, int flags)
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.
buf - Input array or vector of bytes.flags - The same flags as in cv::imread, see cv::ImreadModes.@Namespace(value="cv") @ByVal public static opencv_core.Mat imdecode(@ByVal opencv_core.Mat buf, int flags, opencv_core.Mat dst)
buf - flags - dst - The optional output placeholder for the decoded matrix. It can save the image
reallocations when the function is called repeatedly for images of the same size.@Namespace(value="cv") @Cast(value="bool") public static boolean imencode(@opencv_core.Str BytePointer ext, @ByVal opencv_core.Mat img, @Cast(value="uchar*")@StdVector BytePointer buf, @StdVector IntPointer params)
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.
ext - File extension that defines the output format.img - Image to be written.buf - Output buffer resized to fit the compressed image.params - Format-specific parameters. See cv::imwrite and cv::ImwriteFlags.@Namespace(value="cv") @Cast(value="bool") public static boolean imencode(@opencv_core.Str BytePointer ext, @ByVal opencv_core.Mat img, @Cast(value="uchar*")@StdVector BytePointer buf)
@Namespace(value="cv") @Cast(value="bool") public static boolean imencode(@opencv_core.Str String ext, @ByVal opencv_core.Mat img, @Cast(value="uchar*")@StdVector ByteBuffer buf, @StdVector IntBuffer params)
@Namespace(value="cv") @Cast(value="bool") public static boolean imencode(@opencv_core.Str String ext, @ByVal opencv_core.Mat img, @Cast(value="uchar*")@StdVector ByteBuffer buf)
@Namespace(value="cv") @Cast(value="bool") public static boolean imencode(@opencv_core.Str BytePointer ext, @ByVal opencv_core.Mat img, @Cast(value="uchar*")@StdVector byte[] buf, @StdVector int[] params)
@Namespace(value="cv") @Cast(value="bool") public static boolean imencode(@opencv_core.Str BytePointer ext, @ByVal opencv_core.Mat img, @Cast(value="uchar*")@StdVector byte[] buf)
@Namespace(value="cv") @Cast(value="bool") public static boolean imencode(@opencv_core.Str String ext, @ByVal opencv_core.Mat img, @Cast(value="uchar*")@StdVector BytePointer buf, @StdVector IntPointer params)
@Namespace(value="cv") @Cast(value="bool") public static boolean imencode(@opencv_core.Str String ext, @ByVal opencv_core.Mat img, @Cast(value="uchar*")@StdVector BytePointer buf)
@Namespace(value="cv") @Cast(value="bool") public static boolean imencode(@opencv_core.Str BytePointer ext, @ByVal opencv_core.Mat img, @Cast(value="uchar*")@StdVector ByteBuffer buf, @StdVector IntBuffer params)
@Namespace(value="cv") @Cast(value="bool") public static boolean imencode(@opencv_core.Str BytePointer ext, @ByVal opencv_core.Mat img, @Cast(value="uchar*")@StdVector ByteBuffer buf)
@Namespace(value="cv") @Cast(value="bool") public static boolean imencode(@opencv_core.Str String ext, @ByVal opencv_core.Mat img, @Cast(value="uchar*")@StdVector byte[] buf, @StdVector int[] params)
@Namespace(value="cv") @Cast(value="bool") public static boolean imencode(@opencv_core.Str String ext, @ByVal opencv_core.Mat img, @Cast(value="uchar*")@StdVector byte[] buf)
Copyright © 2016. All rights reserved.