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 enumContourDetector.TypeThe 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 DetectionResultdetect(ByteArray nv21, Integer width, Integer height)Tries to detect a polygon from the given image. final DetectionResultdetect(ByteArray data)Tries to detect a polygon from the given image. final DetectionResultdetect(String fileName)Tries to detect a polygon from the given file. final DetectionResultdetect(Bitmap bitmap)Tries to detect a polygon from the given image. final DetectionResultdetectInArea(ByteArray nv21, Integer width, Integer height, Integer frameOrientation, Rect finderRect)Decode the nv21 within the viewfinder rectangle, and time how long it took. final UnitsetAcceptedAngleScore(Double acceptedAngleScore)The minimum score in percent (0 - 100) of the perspective distortion to accept a detected document. final UnitsetAcceptedSizeScore(Double acceptedSizeScore)The minimum size in percent (0 - 100) of the screen size to accept a detected document. final UnitsetAcceptedBrightnessThreshold(Integer acceptedBrightnessThreshold)The minimum brightness value (0-255) to accept a detected document. final UnitsetRequiredAspectRatios(List<AspectRatio> requiredPageAspectRatios)Set required AspectRatios. final UnitsetRectOfInterest(RectF rectOfInterest)Set rect od interest sizes. final UnitresetPolygonHistory()Calling this method will reset the polygon smoothing history. final static BitmapcreateBitmapFromEncodedData(ByteArray data)Creates a ARGB_8888Bitmap from an in-memory JPEG.final static BitmapcreateBitmapFromEncodedFile(String fileName)Creates a ARGB_8888Bitmap 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
-
detectInArea
final DetectionResult detectInArea(ByteArray nv21, Integer width, Integer height, Integer frameOrientation, Rect finderRect)
Decode the nv21 within the viewfinder rectangle, and time how long it took.
For efficiency, reuse the same reader objects from one decode to the next. The barcode filters list is taken from the current state
- Parameters:
nv21- The YUV preview frame.width- The width of the preview frame.height- The height of the preview frame.frameOrientation- The frame orientation degrees.finderRect- decode area
-
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.
-
setAcceptedBrightnessThreshold
@Synchronized() final Unit setAcceptedBrightnessThreshold(Integer acceptedBrightnessThreshold)
The minimum brightness value (0-255) to accept a detected document. Default is 0.
-
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_8888Bitmap from an in-memory JPEG.- Parameters:
data- JPEG data.
-
createBitmapFromEncodedFile
final static Bitmap createBitmapFromEncodedFile(String fileName)
Creates a
ARGB_8888Bitmap from encoded JPEG on file system- Parameters:
fileName- path to JPEG file
-
-
-
-