Class ContourDetector
-
- All Implemented Interfaces:
public final class ContourDetector extends SelfDisposable
Performs contour detection.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enum
ContourDetector.Type
The type of the ContourDetector. ML_BASED is the default implementation.
-
Constructor Summary
Constructors Constructor Description ContourDetector(ContourDetector.Type contourDetectorType)
-
Method Summary
Modifier and Type Method Description final DetectionResult
detect(ByteArray nv21, Integer width, Integer height)
Tries to detect a polygon from the given image. final DetectionResult
detect(ByteArray data)
Tries to detect a polygon from the given image. final DetectionResult
detect(String fileName)
Tries to detect a polygon from the given file. final DetectionResult
detect(Bitmap bitmap)
Tries to detect a polygon from the given image. final Unit
setAcceptedAngleScore(Double acceptedAngleScore)
The minimum score in percent (0 - 100) of the perspective distortion to accept a detected document. final Unit
setAcceptedSizeScore(Double acceptedSizeScore)
The minimum size in percent (0 - 100) of the screen size to accept a detected document. final Unit
setRequiredAspectRatios(List<AspectRatio> requiredPageAspectRatios)
Set required AspectRatios. final Unit
setRectOfInterest(RectF rectOfInterest)
Set rect od interest sizes. final Unit
resetPolygonHistory()
Calling this method will reset the polygon smoothing history. final static Bitmap
createBitmapFromEncodedData(ByteArray data)
Creates a ARGB_8888
Bitmap from an in-memory JPEG.final static Bitmap
createBitmapFromEncodedFile(String fileName)
Creates a ARGB_8888
Bitmap from encoded JPEG on file system-
-
Constructor Detail
-
ContourDetector
ContourDetector(ContourDetector.Type contourDetectorType)
- Parameters:
contourDetectorType
- type of the document detector to use
-
-
Method Detail
-
detect
@Synchronized() final DetectionResult detect(ByteArray nv21, Integer width, Integer height)
Tries to detect a polygon from the given image.
- Parameters:
nv21
- NV21 encoded camera imagewidth
- Width of the image pixelsheight
- Height of the image in pixels
-
detect
@Synchronized() final DetectionResult detect(ByteArray data)
Tries to detect a polygon from the given image.
- Parameters:
data
- Encoded image (e.g.
-
detect
@Synchronized() final DetectionResult detect(String fileName)
Tries to detect a polygon from the given file.
- Parameters:
fileName
- Encoded file path (e.g.
-
detect
@Synchronized() final DetectionResult detect(Bitmap bitmap)
Tries to detect a polygon from the given image.
- Parameters:
bitmap
- The image
-
setAcceptedAngleScore
@Synchronized() final Unit setAcceptedAngleScore(Double acceptedAngleScore)
The minimum score in percent (0 - 100) of the perspective distortion to accept a detected document. Default is 75.0. Set lower values to accept more perspective distortion.
Warning: Lower values result in more blurred document images.
-
setAcceptedSizeScore
@Synchronized() final Unit setAcceptedSizeScore(Double acceptedSizeScore)
The minimum size in percent (0 - 100) of the screen size to accept a detected document. It is sufficient that height or width match the score. Default is 80.0.
Warning: Lower values result in low resolution document images.
-
setRequiredAspectRatios
@Synchronized() final Unit setRequiredAspectRatios(List<AspectRatio> requiredPageAspectRatios)
Set required AspectRatios.
-
setRectOfInterest
@Synchronized() final Unit setRectOfInterest(RectF rectOfInterest)
Set rect od interest sizes.
- Parameters:
rectOfInterest
- RectF
-
resetPolygonHistory
@Synchronized() final Unit resetPolygonHistory()
Calling this method will reset the polygon smoothing history.
-
createBitmapFromEncodedData
final static Bitmap createBitmapFromEncodedData(ByteArray data)
Creates a
ARGB_8888
Bitmap from an in-memory JPEG.- Parameters:
data
- JPEG data.
-
createBitmapFromEncodedFile
final static Bitmap createBitmapFromEncodedFile(String fileName)
Creates a
ARGB_8888
Bitmap from encoded JPEG on file system- Parameters:
fileName
- path to JPEG file
-
-
-
-