public class Image
extends java.lang.Object
implements java.lang.AutoCloseable, java.io.Serializable
| Constructor and Description |
|---|
Image()
Creates a new instance of the Image class.
|
Image(long handle)
Creates a new instance of the Image class.
|
| Modifier and Type | Method and Description |
|---|---|
Image |
clone()
Creates a copy of the Image object.
|
void |
close()
Releases all resources used by this Image.
|
float |
compare(Image cmpImage)
Computes the difference with another image.
|
void |
correctGamma(int contrast,
int brightness,
float gamma)
Applies a gamma correction to the image.
|
Image |
crop(int left,
int top,
int width,
int height)
Crop a rectangular region of interest in the image according to the given bounds.
|
float |
downscale(int maxSize)
Downscales the image in-place so that its maximum dimension is equal to the given maximum size, while preserving the aspect ratio.
|
float |
downscaleTo(Image dstImage,
int maxSize)
Downscales the image so that its maximum dimension equals the given maximum size, while preserving the aspect ratio.
|
Image |
extractRoi(Rectangle bounds)
Extracts a region of interest in the image according to the given bounds.
|
Image |
extractRoiWithColor(Rectangle bounds,
int colorRed,
int colorGreen,
int colorBlue)
Extracts a region of interest in the image according to the given bounds.
|
protected void |
finalize()
Finalizer for this class.
|
void |
flip(boolean flipHorizontally,
boolean flipVertically)
Flips the image in-place.
|
void |
flipTo(boolean flipHorizontally,
boolean flipVertically,
Image dstImage)
Flips the image.
|
static Image |
fromBuffer(byte[] data,
PixelFormat pixelFormat)
Creates an Image from the specified data buffer.
|
static Image |
fromFile(java.lang.String filepath,
PixelFormat pixelFormat)
Creates an Image from the specified file.
|
static Image |
fromRawBuffer(byte[] pixels,
int width,
int height,
int stride,
PixelFormat srcPixelFormat,
PixelFormat dstPixelFormat)
Creates an Image from the specified raw data buffer.
|
static Image |
fromYuvPlanes(byte[] yPlane,
byte[] uPlane,
byte[] vPlane,
int yWidth,
int yHeight,
int uvPixelStride,
int uvRowStride,
PixelFormat dstPixelFormat)
Creates an Image from the specified YUV planes.
|
byte[] |
getData()
Gets the raw data buffer of the image.
|
long |
getHandle()
Gets the native handle.
|
int |
getHeight()
Gets the height in pixels.
|
int |
getPixelDepth()
Gets the pixel depth.
|
PixelFormat |
getPixelFormat()
Gets the pixel format.
|
int |
getStride()
Gets the stride in bytes.
|
int |
getWidth()
Gets the width in pixels.
|
void |
pad(int top,
int left,
int bottom,
int right,
int colorRed,
int colorGreen,
int colorBlue)
Add padding around the image
Only works for BGR 24 bits, RGB 24 bits and Grayscale 8bits images.
|
void |
reallocate(int width,
int height,
PixelFormat pixelFormat)
Reallocates the internal memory of the Image from parameters.
|
void |
resize(int width,
int height)
Resizes the image in-place to the required width and height.
|
void |
resizeTo(int width,
int height,
Image dstImage)
Resizes the image to the specified width and height.
|
void |
rotate(int angle)
Rotates the image in-place to the specified angle.
|
void |
rotateTo(int angle,
Image dstImage)
Rotates the image to the specified angle.
|
byte[] |
toBuffer(ImageFormat imageFormat,
float compressionLevel)
Exports the image to a buffer.
|
void |
toBufferObject(ImageFormat imageFormat,
float compressionLevel,
ImageBuffer buffer)
Copies the image to a buffer in the specified format.
|
void |
toFile(java.lang.String filepath,
float compressionLevel)
Saves the image to the specified file.
|
void |
toRawBuffer(PixelFormat pixelFormat,
ImageBuffer buffer)
Copies image pixels in the specified format into a buffer.
|
void |
transpose()
Transposes the image object.
|
public Image()
throws FaceException
FaceException - An error has occurred during Face Library execution.public Image(long handle)
throws FaceException
handle - Handle to the Image.FaceException - An error has occurred during Face Library execution.public void close()
close in interface java.lang.AutoCloseableprotected void finalize()
finalize in class java.lang.Objectpublic long getHandle()
public Image clone() throws FaceException
clone in class java.lang.ObjectFaceException - An error has occurred during Face Library execution.public byte[] getData()
throws FaceException
FaceException - An error has occurred during Face Library execution.public int getHeight()
throws FaceException
FaceException - An error has occurred during Face Library execution.public int getPixelDepth()
throws FaceException
FaceException - An error has occurred during Face Library execution.public PixelFormat getPixelFormat() throws FaceException
FaceException - An error has occurred during Face Library execution.public int getStride()
throws FaceException
FaceException - An error has occurred during Face Library execution.public int getWidth()
throws FaceException
FaceException - An error has occurred during Face Library execution.public float compare(Image cmpImage) throws FaceException
cmpImage - The image to compare.FaceException - An error has occurred during Face Library execution.public void correctGamma(int contrast,
int brightness,
float gamma)
throws FaceException
contrast - Contrast coefficient, from -255 to 255, to be applied to the image.brightness - Brightness coefficient, from -255 to 255, to be applid to the image.gamma - Gamma coefficient, from 0.25 to 2.50, to be applied to the image.FaceException - An error has occurred during Face Library execution.public Image crop(int left, int top, int width, int height) throws FaceException
left - Left bound of the crop to extract.top - Top bound of the crop to extract.width - Width of the crop to extract.height - Height of the crop to extract.FaceException - An error has occurred during Face Library execution.public float downscale(int maxSize)
throws FaceException
maxSize - Maximum image size, in pixels. The value must be greater than 0.FaceException - An error has occurred during Face Library execution.public float downscaleTo(Image dstImage, int maxSize) throws FaceException
dstImage - Destination image.maxSize - Maximum image size, in pixels. The value must be greater than 0.FaceException - An error has occurred during Face Library execution.public Image extractRoi(Rectangle bounds) throws FaceException
bounds - Bounds of the crop to extract.FaceException - An error has occurred during Face Library execution.public Image extractRoiWithColor(Rectangle bounds, int colorRed, int colorGreen, int colorBlue) throws FaceException
bounds - Bounds of the crop to extract.colorRed - Background color red (from 0 to 255)colorGreen - Background color green (from 0 to 255)colorBlue - Background color blue (from 0 to 255)FaceException - An error has occurred during Face Library execution.public void flip(boolean flipHorizontally,
boolean flipVertically)
throws FaceException
flipHorizontally - Value indicating whether the image should be flipped horizontally.flipVertically - Value indicating whether the image should be flipped vertically.FaceException - An error has occurred during Face Library execution.public void flipTo(boolean flipHorizontally,
boolean flipVertically,
Image dstImage)
throws FaceException
flipHorizontally - Value indicating whether the image should be flipped horizontally.flipVertically - Value indicating whether the image should be flipped vertically.dstImage - The destination Image object that receives the flipped image.FaceException - An error has occurred during Face Library execution.public static Image fromBuffer(byte[] data, PixelFormat pixelFormat) throws FaceException
data - A buffer that contains the image data.pixelFormat - The destination pixel format to convert the input to.FaceException - An error has occurred during Face Library execution.public static Image fromFile(java.lang.String filepath, PixelFormat pixelFormat) throws FaceException
filepath - A string that contains the name of the file from which to create the Image.pixelFormat - The pixel format into which to convert the input image.FaceException - An error has occurred during Face Library execution.public static Image fromRawBuffer(byte[] pixels, int width, int height, int stride, PixelFormat srcPixelFormat, PixelFormat dstPixelFormat) throws FaceException
pixels - A buffer that contains image pixels.width - The width, in pixels, of the image.height - The height, in pixels, of the image.stride - The stride, in pixels, of the image.srcPixelFormat - The pixel format of the input image.dstPixelFormat - The pixel format into which to convert the input image.FaceException - An error has occurred during Face Library execution.public static Image fromYuvPlanes(byte[] yPlane, byte[] uPlane, byte[] vPlane, int yWidth, int yHeight, int uvPixelStride, int uvRowStride, PixelFormat dstPixelFormat) throws FaceException
yPlane - A buffer that contains the Y plane.uPlane - A buffer that contains the U plane.vPlane - A buffer that contains the V plane.yWidth - The width, in pixels, of the Y plane.yHeight - The height, in pixels, of the Y plane.uvPixelStride - The pixel-level stride, in pixels, of the U and V planes.uvRowStride - The row-level stride, in pixels, of the U and V planes.dstPixelFormat - The pixel format into which to convert the input image.FaceException - An error has occurred during Face Library execution.public void pad(int top,
int left,
int bottom,
int right,
int colorRed,
int colorGreen,
int colorBlue)
throws FaceException
top - Padding on top.left - Padding on left.bottom - Padding on bottom.right - Padding on right.colorRed - Padding color red (from 0 to 255)colorGreen - Padding color green (from 0 to 255)colorBlue - Padding color blue (from 0 to 255)FaceException - An error has occurred during Face Library execution.public void reallocate(int width,
int height,
PixelFormat pixelFormat)
throws FaceException
width - The new width, in pixels.height - The new height, in pixels.pixelFormat - The new pixel format.FaceException - An error has occurred during Face Library execution.public void resize(int width,
int height)
throws FaceException
width - The new width, in pixels.height - The new height, in pixels.FaceException - An error has occurred during Face Library execution.public void resizeTo(int width,
int height,
Image dstImage)
throws FaceException
width - The new width, in pixels.height - The new height, in pixels.dstImage - The destination image that receives the resized image.FaceException - An error has occurred during Face Library execution.public void rotate(int angle)
throws FaceException
angle - The rotation angle, in degree. Supported values are [0, 90, 180, 270].FaceException - An error has occurred during Face Library execution.public void rotateTo(int angle,
Image dstImage)
throws FaceException
angle - The rotation angle, in degree. Supported values are [0, 90, 180, 270].dstImage - The destination Image that receives the rotated image.FaceException - An error has occurred during Face Library execution.public byte[] toBuffer(ImageFormat imageFormat, float compressionLevel) throws FaceException
imageFormat - The image format to export the image to.compressionLevel - The compression level to be applied.FaceException - An error has occurred during Face Library execution.public void toBufferObject(ImageFormat imageFormat, float compressionLevel, ImageBuffer buffer) throws FaceException
imageFormat - The output image format.compressionLevel - The compression level to be applied.buffer - The image buffer that receives the image data.FaceException - An error has occurred during Face Library execution.public void toFile(java.lang.String filepath,
float compressionLevel)
throws FaceException
filepath - A string that contains the name of the file to which to save the image.compressionLevel - The compression level to be applied.FaceException - An error has occurred during Face Library execution.public void toRawBuffer(PixelFormat pixelFormat, ImageBuffer buffer) throws FaceException
pixelFormat - The pixel format.buffer - Buffer that receives the raw image data.FaceException - An error has occurred during Face Library execution.public void transpose()
throws FaceException
FaceException - An error has occurred during Face Library execution.Copyright © id3 Technologies. All rights reserved. eu.id3.face