public class ContourDetector
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
IMAGE_FILTER_BINARIZED |
static int |
IMAGE_FILTER_COLOR_DOCUMENT |
static int |
IMAGE_FILTER_COLOR_ENHANCED |
static int |
IMAGE_FILTER_GRAY |
static int |
IMAGE_FILTER_NONE |
static int |
IMAGE_FILTER_PURE_BINARIZED |
| Constructor and Description |
|---|
ContourDetector() |
| Modifier and Type | Method and Description |
|---|---|
static android.graphics.Bitmap |
createBitmapFromEncodedData(byte[] data)
Creates a
ARGB_8888 Bitmap from an in-memory JPEG. |
static android.graphics.Bitmap |
createBitmapFromEncodedFile(java.lang.String fileName)
Creates a
ARGB_8888 Bitmap from encoded JPEG on file system |
static android.graphics.Bitmap |
createBitmapFromNV21(byte[] nv21,
int width,
int height)
Converts a NV21 encoded image into a
ARGB_8888 Bitmap (using fixed point arithmetics). |
DetectionResult |
detect(android.graphics.Bitmap bitmap)
Tries to detect a polygon from the given image.
|
DetectionResult |
detect(byte[] data)
Tries to detect a polygon from the given image.
|
DetectionResult |
detect(byte[] nv21,
int width,
int height)
Tries to detect a polygon from the given image.
|
DetectionResult |
detect(java.lang.String fileName)
Tries to detect a polygon from the given file.
|
void |
dispose()
Disposes the native resources held by this instance.
|
double |
getDetectionScore() |
java.util.List<Line2D> |
getHorizontalLines() |
java.util.List<android.graphics.Point> |
getPolygon() |
java.util.List<android.graphics.PointF> |
getPolygonF() |
java.util.List<Line2D> |
getVerticalLines() |
android.graphics.Bitmap |
processImage(android.graphics.Bitmap bitmap,
java.util.List<android.graphics.Point> polygon,
int imageFilter)
Post processes an image, applying cropping and filters.
|
android.graphics.Bitmap |
processImage(byte[] nv21,
int width,
int height,
java.util.List<android.graphics.Point> polygon,
int imageFilter)
Post processes an image, applying cropping and filters.
|
android.graphics.Bitmap |
processImage(byte[] data,
java.util.List<android.graphics.Point> polygon,
int imageFilter)
Post processes an image, applying cropping and filters.
|
android.graphics.Bitmap |
processImageAndRelease(android.graphics.Bitmap bitmap,
java.util.List<android.graphics.PointF> polygon,
int imageFilter)
Same as
processImageF(java.lang.String, java.util.List<android.graphics.PointF>, int), but it recycles the input Bitmap before creating a new one in Java heap. |
android.graphics.Bitmap |
processImageAndScale(byte[] encodedImage,
java.util.List<android.graphics.PointF> polygon,
int imageFilter,
int biggestSide)
Post processes an image (using floating point coordinates), applying cropping and filters
and then scales image to given size.
|
android.graphics.Bitmap |
processImageF(android.graphics.Bitmap bitmap,
java.util.List<android.graphics.PointF> polygon,
int imageFilter)
Post processes an image (using floating point coordinates), applying cropping and filters.
|
android.graphics.Bitmap |
processImageF(byte[] nv21,
int width,
int height,
java.util.List<android.graphics.PointF> polygon,
int imageFilter)
Post processes an image (using floating point coordinates), applying cropping and filters.
|
android.graphics.Bitmap |
processImageF(byte[] data,
java.util.List<android.graphics.PointF> polygon,
int imageFilter)
Post processes an image (using floating point coordinates), applying cropping and filters.
|
android.graphics.Bitmap |
processImageF(java.lang.String fileName,
java.util.List<android.graphics.PointF> polygon,
int imageFilter)
Post processes an image, applying cropping and filters.
|
void |
resetPolygonHistory()
Calling this method will reset the polygon smoothing history.
|
void |
setAcceptedAngleScore(double acceptedAngleScore)
The minimum score in percent (0 - 100) of the perspective distortion to accept a detected document.
|
void |
setAcceptedSizeScore(double acceptedSizeScore)
The minimum size in percent (0 - 100) of the screen size to accept a detected document.
|
public static final int IMAGE_FILTER_NONE
public static final int IMAGE_FILTER_COLOR_ENHANCED
public static final int IMAGE_FILTER_GRAY
public static final int IMAGE_FILTER_BINARIZED
public static final int IMAGE_FILTER_COLOR_DOCUMENT
public static final int IMAGE_FILTER_PURE_BINARIZED
public final DetectionResult detect(byte[] nv21, int width, int height)
nv21 - NV21 encoded camera imagewidth - Width of the image pixelsheight - Height of the image in pixelsDetectionResult that gives information about the recognition state.public final DetectionResult detect(byte[] data)
data - Encoded image (e.g. a JPEG)DetectionResult that gives information about the recognition state.public final DetectionResult detect(java.lang.String fileName) throws java.io.IOException
fileName - Encoded file path (e.g. a JPEG)DetectionResult that gives information about the recognition state.java.io.IOExceptionpublic final DetectionResult detect(android.graphics.Bitmap bitmap)
bitmap - The imageDetectionResult that gives information about the recognition state.public final android.graphics.Bitmap processImage(byte[] nv21,
int width,
int height,
java.util.List<android.graphics.Point> polygon,
int imageFilter)
nv21 - NV21 encoded camera imagewidth - Width of the image pixelsheight - Height of the image in pixelspolygon - The detected polygonimageFilter - Image filter type, one of IMAGE_FILTER_* or 0.public final android.graphics.Bitmap processImage(byte[] data,
java.util.List<android.graphics.Point> polygon,
int imageFilter)
data - Encoded image (e.g. a JPEG)polygon - The detected polygonimageFilter - Image filter type, one of IMAGE_FILTER_* or 0.public final android.graphics.Bitmap processImage(android.graphics.Bitmap bitmap,
java.util.List<android.graphics.Point> polygon,
int imageFilter)
bitmap - The image to processpolygon - The detected polygonimageFilter - Image filter type, one of IMAGE_FILTER_* or 0.public android.graphics.Bitmap processImageF(java.lang.String fileName,
java.util.List<android.graphics.PointF> polygon,
int imageFilter)
throws java.io.IOException
fileName - path to JPEG filepolygon - The detected polygonimageFilter - Image filter type, one of IMAGE_FILTER_* or 0.java.io.IOExceptionpublic final android.graphics.Bitmap processImageF(byte[] nv21,
int width,
int height,
java.util.List<android.graphics.PointF> polygon,
int imageFilter)
nv21 - NV21 encoded camera imagewidth - Width of the image pixelsheight - Height of the image in pixelspolygon - The detected polygonimageFilter - Image filter type, one of IMAGE_FILTER_* or 0.public final android.graphics.Bitmap processImageF(byte[] data,
java.util.List<android.graphics.PointF> polygon,
int imageFilter)
data - Encoded image (e.g. a JPEG)polygon - The detected polygonimageFilter - Image filter type, one of IMAGE_FILTER_* or 0.public final android.graphics.Bitmap processImageF(android.graphics.Bitmap bitmap,
java.util.List<android.graphics.PointF> polygon,
int imageFilter)
bitmap - The image to processpolygon - The detected polygonimageFilter - Image filter type, one of IMAGE_FILTER_* or 0.public final android.graphics.Bitmap processImageAndScale(byte[] encodedImage,
java.util.List<android.graphics.PointF> polygon,
int imageFilter,
int biggestSide)
encodedImage - The image to processpolygon - The detected polygonimageFilter - Image filter type, one of IMAGE_FILTER_* or 0.public final android.graphics.Bitmap processImageAndRelease(android.graphics.Bitmap bitmap,
java.util.List<android.graphics.PointF> polygon,
int imageFilter)
processImageF(java.lang.String, java.util.List<android.graphics.PointF>, int), but it recycles the input Bitmap before creating a new one in Java heap.
This helps to reduce total memory footprint on Java side and therefore avoiding OutOfMemory errors.bitmap - The image to process. Will be recycled after this method completes.polygon - The detected polygonimageFilter - Image filter type, one of IMAGE_FILTER_* or 0.public final java.util.List<android.graphics.Point> getPolygon()
public final java.util.List<android.graphics.PointF> getPolygonF()
[0.f, 1.f[.public final double getDetectionScore()
[0.0, 100.0].public final java.util.List<Line2D> getVerticalLines()
public final java.util.List<Line2D> getHorizontalLines()
public final void setAcceptedAngleScore(double acceptedAngleScore)
acceptedAngleScore - public final void setAcceptedSizeScore(double acceptedSizeScore)
acceptedSizeScore - public final void resetPolygonHistory()
public void dispose()
public static final android.graphics.Bitmap createBitmapFromEncodedData(byte[] data)
ARGB_8888 Bitmap from an in-memory JPEG.data - JPEG data.public static final android.graphics.Bitmap createBitmapFromEncodedFile(java.lang.String fileName)
throws java.io.IOException
ARGB_8888 Bitmap from encoded JPEG on file systemfileName - path to JPEG filejava.io.IOExceptionpublic static final android.graphics.Bitmap createBitmapFromNV21(byte[] nv21,
int width,
int height)
ARGB_8888 Bitmap (using fixed point arithmetics).nv21 - Bytes to decode.width - The width of the image.height - The height of the image.