Package io.anyline2.model
Class AnylineYuvImage
-
- All Implemented Interfaces:
-
java.lang.Cloneable
public class AnylineYuvImage extends AbstractAnylineImage implements Cloneable
A helper class to deal with yuv images. (currently only NV21!!) It helps with conversion to OpenCV Mat and deals with the problem that the camera always returns a landscape image.
-
-
Constructor Summary
Constructors Constructor Description AnylineYuvImage(int format, int width, int height, int targetOrientation)
Construct a yuv image with empty data. AnylineYuvImage(int format, int width, int height, Array<byte> data, int targetOrientation, boolean isGrayOnly)
Construct a yuv image with the given byte data. AnylineYuvImage(Image image, int targetOrientation, int cropX, int cropY, int cropWidth, int cropHeight, boolean isGrayOnly)
Construct a YUV image from the given image buffer cropped to the given bounds.
-
Method Summary
Modifier and Type Method Description void
setTo(@NonNull() Array<byte> data)
Set the data of this image to the given value. AnylineYuvImage
crop(int cropX, int cropY, int cropWidth, int cropHeight, boolean isGrayOnly)
Returns a new image cropped to the given bounds. AnylineImage
toAnylineImage()
Get a new AnylineImage object from the current AbstractAnylineImage object AnylineYuvImage
clone()
-
Methods inherited from class io.anyline2.model.AbstractAnylineImage
getData, getFormat, getOriginalHeight, getOriginalWidth, getTargetHeight, getTargetOrientation, getTargetWidth, isGrayOnly
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
AnylineYuvImage
AnylineYuvImage(int format, int width, int height, int targetOrientation)
Construct a yuv image with empty data.- Parameters:
format
- the format (currently only NV21 is supported)width
- the target width of the imageheight
- the target height of the imagetargetOrientation
- the degree the raw data has to be rotated to be oriented as desired (usually what getCameraDisplayRotation returns)
-
AnylineYuvImage
AnylineYuvImage(int format, int width, int height, Array<byte> data, int targetOrientation, boolean isGrayOnly)
Construct a yuv image with the given byte data.- Parameters:
format
- the format (currently only NV21 is supported)width
- the target width of the imageheight
- the target height of the imagedata
- the image data in landscape format (like received from the camera)targetOrientation
- the degree the raw data has to be rotated to be oriented as desired (usually what getCameraDisplayRotation returns)isGrayOnly
- true if given data only contains the Y component (and therefor is gray only)
-
AnylineYuvImage
AnylineYuvImage(Image image, int targetOrientation, int cropX, int cropY, int cropWidth, int cropHeight, boolean isGrayOnly)
Construct a YUV image from the given image buffer cropped to the given bounds.- Parameters:
image
- the image to copy the data fromtargetOrientation
- the degree the raw data has to be rotated to be oriented as desired (usually what getCameraDisplayRotation returns)cropX
- the distance from the left (must be EVEN for color images)cropY
- the distance from the top (must be EVEN for color images)cropWidth
- the target width (must be EVEN for color images)cropHeight
- the target height (must be EVEN for color images)isGrayOnly
- true if a gray image is desired (faster), false if color is required too
-
-
Method Detail
-
setTo
void setTo(@NonNull() Array<byte> data)
Set the data of this image to the given value. (MUST be of same size as the current data)
- Parameters:
data
- the data to set this image to.
-
crop
AnylineYuvImage crop(int cropX, int cropY, int cropWidth, int cropHeight, boolean isGrayOnly)
Returns a new image cropped to the given bounds.
The given sizes must be EVEN for color images, because of how the YUV format stores color information.
- Parameters:
cropX
- the distance from the left in the target orientation (must be EVEN for color images)cropY
- the distance from the top in the target orientation (must be EVEN for color images)cropWidth
- the crop width in the target orientation (must be EVEN for color images)cropHeight
- the crop height in the target orientation (must be EVEN for color images)isGrayOnly
- true if a gray image is desired (faster), false if color is required too- Returns:
a new image cropped to the given bounds.
-
toAnylineImage
AnylineImage toAnylineImage()
Get a new AnylineImage object from the current AbstractAnylineImage object
-
clone
AnylineYuvImage clone()
- Returns:
a deep copy of the image
-
-
-
-