org.opencv.highgui
public class Highgui extends java.lang.Object
Constructor and Description |
---|
Highgui() |
Modifier and Type | Method and Description |
---|---|
static Mat |
imdecode(Mat buf,
int flags)
Reads an image from a buffer in memory.
|
static boolean |
imencode(java.lang.String ext,
Mat img,
MatOfByte buf)
Encodes an image into a memory buffer.
|
static boolean |
imencode(java.lang.String ext,
Mat img,
MatOfByte buf,
MatOfInt params)
Encodes an image into a memory buffer.
|
static Mat |
imread(java.lang.String filename)
Loads an image from a file.
|
static Mat |
imread(java.lang.String filename,
int flags)
Loads an image from a file.
|
static boolean |
imwrite(java.lang.String filename,
Mat img)
Saves an image to a specified file.
|
static boolean |
imwrite(java.lang.String filename,
Mat img,
MatOfInt params)
Saves an image to a specified file.
|
public static final int CV_CAP_ANDROID
public static final int CV_CAP_ANDROID_ANTIBANDING_50HZ
public static final int CV_CAP_ANDROID_ANTIBANDING_60HZ
public static final int CV_CAP_ANDROID_ANTIBANDING_AUTO
public static final int CV_CAP_ANDROID_ANTIBANDING_OFF
public static final int CV_CAP_ANDROID_BACK
public static final int CV_CAP_ANDROID_COLOR_FRAME
public static final int CV_CAP_ANDROID_COLOR_FRAME_BGR
public static final int CV_CAP_ANDROID_COLOR_FRAME_BGRA
public static final int CV_CAP_ANDROID_COLOR_FRAME_RGB
public static final int CV_CAP_ANDROID_COLOR_FRAME_RGBA
public static final int CV_CAP_ANDROID_FLASH_MODE_AUTO
public static final int CV_CAP_ANDROID_FLASH_MODE_OFF
public static final int CV_CAP_ANDROID_FLASH_MODE_ON
public static final int CV_CAP_ANDROID_FLASH_MODE_RED_EYE
public static final int CV_CAP_ANDROID_FLASH_MODE_TORCH
public static final int CV_CAP_ANDROID_FOCUS_MODE_AUTO
public static final int CV_CAP_ANDROID_FOCUS_MODE_CONTINUOUS_PICTURE
public static final int CV_CAP_ANDROID_FOCUS_MODE_CONTINUOUS_VIDEO
public static final int CV_CAP_ANDROID_FOCUS_MODE_EDOF
public static final int CV_CAP_ANDROID_FOCUS_MODE_FIXED
public static final int CV_CAP_ANDROID_FOCUS_MODE_INFINITY
public static final int CV_CAP_ANDROID_FOCUS_MODE_MACRO
public static final int CV_CAP_ANDROID_FRONT
public static final int CV_CAP_ANDROID_GREY_FRAME
public static final int CV_CAP_ANDROID_WHITE_BALANCE_AUTO
public static final int CV_CAP_ANDROID_WHITE_BALANCE_CLOUDY_DAYLIGHT
public static final int CV_CAP_ANDROID_WHITE_BALANCE_DAYLIGHT
public static final int CV_CAP_ANDROID_WHITE_BALANCE_FLUORESCENT
public static final int CV_CAP_ANDROID_WHITE_BALANCE_INCANDESCENT
public static final int CV_CAP_ANDROID_WHITE_BALANCE_SHADE
public static final int CV_CAP_ANDROID_WHITE_BALANCE_TWILIGHT
public static final int CV_CAP_ANDROID_WHITE_BALANCE_WARM_FLUORESCENT
public static final int CV_CAP_AVFOUNDATION
public static final int CV_CAP_GIGANETIX
public static final int CV_CAP_MSMF
public static final int CV_CAP_PROP_ANDROID_ANTIBANDING
public static final int CV_CAP_PROP_ANDROID_EXPOSE_LOCK
public static final int CV_CAP_PROP_ANDROID_FLASH_MODE
public static final int CV_CAP_PROP_ANDROID_FOCAL_LENGTH
public static final int CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_FAR
public static final int CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_NEAR
public static final int CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_OPTIMAL
public static final int CV_CAP_PROP_ANDROID_FOCUS_MODE
public static final int CV_CAP_PROP_ANDROID_WHITE_BALANCE
public static final int CV_CAP_PROP_ANDROID_WHITEBALANCE_LOCK
public static final int CV_CAP_PROP_AUTOGRAB
public static final int CV_CAP_PROP_BACKLIGHT
public static final int CV_CAP_PROP_FOCUS
public static final int CV_CAP_PROP_FRAME_HEIGHT
public static final int CV_CAP_PROP_FRAME_WIDTH
public static final int CV_CAP_PROP_GIGA_FRAME_HEIGH_MAX
public static final int CV_CAP_PROP_GIGA_FRAME_OFFSET_X
public static final int CV_CAP_PROP_GIGA_FRAME_OFFSET_Y
public static final int CV_CAP_PROP_GIGA_FRAME_SENS_HEIGH
public static final int CV_CAP_PROP_GIGA_FRAME_SENS_WIDTH
public static final int CV_CAP_PROP_GIGA_FRAME_WIDTH_MAX
public static final int CV_CAP_PROP_GUID
public static final int CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD
public static final int CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ
public static final int CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT
public static final int CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE
public static final int CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE
public static final int CV_CAP_PROP_INTELPERC_PROFILE_COUNT
public static final int CV_CAP_PROP_INTELPERC_PROFILE_IDX
public static final int CV_CAP_PROP_IOS_DEVICE_EXPOSURE
public static final int CV_CAP_PROP_IOS_DEVICE_FLASH
public static final int CV_CAP_PROP_IOS_DEVICE_FOCUS
public static final int CV_CAP_PROP_IOS_DEVICE_TORCH
public static final int CV_CAP_PROP_IOS_DEVICE_WHITEBALANCE
public static final int CV_CAP_PROP_IRIS
public static final int CV_CAP_PROP_ISO_SPEED
public static final int CV_CAP_PROP_PAN
public static final int CV_CAP_PROP_PREVIEW_FORMAT
public static final int CV_CAP_PROP_ROLL
public static final int CV_CAP_PROP_SETTINGS
public static final int CV_CAP_PROP_TILT
public static final int CV_CAP_PROP_XI_AE_MAX_LIMIT
public static final int CV_CAP_PROP_XI_AEAG
public static final int CV_CAP_PROP_XI_AEAG_LEVEL
public static final int CV_CAP_PROP_XI_AG_MAX_LIMIT
public static final int CV_CAP_PROP_XI_AUTO_WB
public static final int CV_CAP_PROP_XI_DATA_FORMAT
public static final int CV_CAP_PROP_XI_DOWNSAMPLING
public static final int CV_CAP_PROP_XI_EXP_PRIORITY
public static final int CV_CAP_PROP_XI_GPI_LEVEL
public static final int CV_CAP_PROP_XI_GPI_MODE
public static final int CV_CAP_PROP_XI_GPI_SELECTOR
public static final int CV_CAP_PROP_XI_GPO_MODE
public static final int CV_CAP_PROP_XI_GPO_SELECTOR
public static final int CV_CAP_PROP_XI_LED_MODE
public static final int CV_CAP_PROP_XI_LED_SELECTOR
public static final int CV_CAP_PROP_XI_MANUAL_WB
public static final int CV_CAP_PROP_XI_OFFSET_X
public static final int CV_CAP_PROP_XI_OFFSET_Y
public static final int CV_CAP_PROP_XI_TIMEOUT
public static final int CV_CAP_PROP_XI_TRG_SOFTWARE
public static final int CV_CAP_PROP_XI_TRG_SOURCE
public static final int CV_CAP_PROP_ZOOM
public static final int CV_CAP_XIAPI
public static final int CV_CVTIMG_FLIP
public static final int CV_CVTIMG_SWAP_RB
public static final int CV_FONT_BLACK
public static final int CV_FONT_BOLD
public static final int CV_FONT_DEMIBOLD
public static final int CV_FONT_LIGHT
public static final int CV_FONT_NORMAL
public static final int CV_IMWRITE_JPEG_QUALITY
public static final int CV_IMWRITE_PNG_BILEVEL
public static final int CV_IMWRITE_PNG_COMPRESSION
public static final int CV_IMWRITE_PNG_STRATEGY
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_FIXED
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_PXM_BINARY
public static final int CV_LOAD_IMAGE_ANYCOLOR
public static final int CV_LOAD_IMAGE_ANYDEPTH
public static final int CV_LOAD_IMAGE_COLOR
public static final int CV_LOAD_IMAGE_GRAYSCALE
public static final int CV_LOAD_IMAGE_UNCHANGED
public static final int CV_STYLE_ITALIC
public static final int CV_STYLE_NORMAL
public static final int CV_STYLE_OBLIQUE
public static final int IMREAD_ANYCOLOR
public static final int IMREAD_ANYDEPTH
public static final int IMREAD_COLOR
public static final int IMREAD_GRAYSCALE
public static final int IMREAD_UNCHANGED
public static final int IMWRITE_JPEG_QUALITY
public static final int IMWRITE_PNG_BILEVEL
public static final int IMWRITE_PNG_COMPRESSION
public static final int IMWRITE_PNG_STRATEGY
public static final int IMWRITE_PNG_STRATEGY_DEFAULT
public static final int IMWRITE_PNG_STRATEGY_FILTERED
public static final int IMWRITE_PNG_STRATEGY_FIXED
public static final int IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY
public static final int IMWRITE_PNG_STRATEGY_RLE
public static final int IMWRITE_PXM_BINARY
public static Mat imdecode(Mat buf, int flags)
Reads an image from a buffer in memory.
The function reads an image from the specified buffer in the memory. If the buffer is too short or contains invalid data, the empty matrix/image is returned.
See "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 "imread".public static boolean imencode(java.lang.String ext, Mat img, MatOfByte buf)
Encodes an image into a memory buffer.
The function compresses the image and stores it in the memory buffer that is resized to fit the result. See "imwrite" for the list of supported formats and flags description.
Note: cvEncodeImage
returns single-row matrix of type
CV_8UC1
that contains encoded image as array of bytes.
ext
- File extension that defines the output format.img
- Image to be written.buf
- Output buffer resized to fit the compressed image.public static boolean imencode(java.lang.String ext, Mat img, MatOfByte buf, MatOfInt params)
Encodes an image into a memory buffer.
The function compresses the image and stores it in the memory buffer that is resized to fit the result. See "imwrite" for the list of supported formats and flags description.
Note: cvEncodeImage
returns single-row matrix of type
CV_8UC1
that contains encoded image as array of bytes.
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 "imwrite".public static Mat imread(java.lang.String filename)
Loads an image from a file.
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:
*.bmp, *.dib
(always supported)
*.jpeg, *.jpg, *.jpe
(see the *Notes*
section)
*.jp2
(see the *Notes* section)
*.png
(see the *Notes*
section)
*.pbm, *.pgm, *.ppm
(always
supported)
*.sr, *.ras
(always supported)
*.tiff, *.tif
(see the *Notes* section)
Note:
OPENCV_BUILD_3RDPARTY_LIBS
flag in CMake.
Note: In the case of color images, the decoded images will have the channels
stored in B G R
order.
filename
- Name of file to be loaded.public static Mat imread(java.lang.String filename, int flags)
Loads an image from a file.
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:
*.bmp, *.dib
(always supported)
*.jpeg, *.jpg, *.jpe
(see the *Notes*
section)
*.jp2
(see the *Notes* section)
*.png
(see the *Notes*
section)
*.pbm, *.pgm, *.ppm
(always
supported)
*.sr, *.ras
(always supported)
*.tiff, *.tif
(see the *Notes* section)
Note:
OPENCV_BUILD_3RDPARTY_LIBS
flag in CMake.
Note: In the case of color images, the decoded images will have the channels
stored in B G R
order.
filename
- Name of file to be loaded.flags
- Flags specifying the color type of a loaded image:
Note: In the current implementation the alpha channel, if any, is stripped from the output image. Use negative value if you need the alpha channel.
public static boolean imwrite(java.lang.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
"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
"cvtColor" to convert it before saving. Or, use the universal XML 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
// C++ code:
#include
#include
#include
using namespace cv;
using namespace std;
void createAlphaMat(Mat &mat)
for (int i = 0; i < mat.rows; ++i) {
for (int j = 0; j < mat.cols; ++j) {
Vec4b& rgba = mat.at
rgba[0] = UCHAR_MAX;
rgba[1] = saturate_cast
rgba[2] = saturate_cast
rgba[3] = saturate_cast
int main(int argv, char argc)
// Create mat with alpha channel
Mat mat(480, 640, CV_8UC4);
createAlphaMat(mat);
vector
compression_params.push_back(CV_IMWRITE_PNG_COMPRESSION);
compression_params.push_back(9);
try {
imwrite("alpha.png", mat, compression_params);
catch (runtime_error& ex) {
fprintf(stderr, "Exception converting image to PNG format: %sn", ex.what());
return 1;
fprintf(stdout, "Saved PNG file with alpha data.n");
return 0;
filename
- Name of the file.img
- a imgpublic static boolean imwrite(java.lang.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
"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
"cvtColor" to convert it before saving. Or, use the universal XML 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
// C++ code:
#include
#include
#include
using namespace cv;
using namespace std;
void createAlphaMat(Mat &mat)
for (int i = 0; i < mat.rows; ++i) {
for (int j = 0; j < mat.cols; ++j) {
Vec4b& rgba = mat.at
rgba[0] = UCHAR_MAX;
rgba[1] = saturate_cast
rgba[2] = saturate_cast
rgba[3] = saturate_cast
int main(int argv, char argc)
// Create mat with alpha channel
Mat mat(480, 640, CV_8UC4);
createAlphaMat(mat);
vector
compression_params.push_back(CV_IMWRITE_PNG_COMPRESSION);
compression_params.push_back(9);
try {
imwrite("alpha.png", mat, compression_params);
catch (runtime_error& ex) {
fprintf(stderr, "Exception converting image to PNG format: %sn", ex.what());
return 1;
fprintf(stdout, "Saved PNG file with alpha data.n");
return 0;
filename
- Name of the file.img
- a imgparams
- Format-specific save parameters encoded as pairs
paramId_1, paramValue_1, paramId_2, paramValue_2,...
. The
following parameters are currently supported:
CV_IMWRITE_JPEG_QUALITY
)
from 0 to 100 (the higher is the better). Default value is 95.
CV_IMWRITE_PNG_COMPRESSION
)
from 0 to 9. A higher value means a smaller size and longer compression time.
Default value is 3.
CV_IMWRITE_PXM_BINARY
),
0 or 1. Default value is 1.