Class ContourDetectorFrameHandler
-
- All Implemented Interfaces:
public final class ContourDetectorFrameHandler extends FrameHandler
Performs contour detection on camera preview frames. Outputs results via ContourDetectorFrameHandler.ResultHandler (.addResultHandler).
Preview frame considered intercepted if at least one ContourDetectorFrameHandler.ResultHandler returns
true
from ContourDetectorFrameHandler.ResultHandler.handle (FrameHandlerResult)}
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
ContourDetectorFrameHandler.ResultHandler
Continuously notified about contour detection results.
public abstract class
ContourDetectorFrameHandler.ContourDetectorResultHandler
Successor-class needed for cross-platform implementation
public final class
ContourDetectorFrameHandler.DetectedFrame
Contour detection results alongside with information about frame
-
Constructor Summary
Constructors Constructor Description ContourDetectorFrameHandler(Context context, ContourDetector contourDetector)
-
Method Summary
Modifier and Type Method Description Boolean
handleFrame(FrameHandler.Frame previewFrame)
Invoked for every new camera preview frame. final Unit
addResultHandler(ContourDetectorFrameHandler.ResultHandler handler)
Registers result handler which will be notified about contour detection results. final Unit
removeResultHandler(ContourDetectorFrameHandler.ResultHandler handler)
Unregisters handler. final Unit
clearResultHandlers()
Unregisters all handlers. 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
setAcceptedBrightnessThreshold(Integer acceptedBrightnessThreshold)
The minimum brightness value to accept a detected document. final Unit
setRequiredAspectRatios(List<AspectRatio> requiredPageAspectRatios)
Set required PageAspectRatios. final Unit
setIgnoreBadAspectRatio(Boolean ignoreBadAspectRatio)
Flag to determine whether to treat DetectionStatus.OK_BUT_BAD_ASPECT_RATIO status as DetectionStatus.OK. final static ContourDetectorFrameHandler
attach(IScanbotCameraView cameraView, ContourDetector detector)
Convenience method for creating new ContourDetectorFrameHandler and adding it as FrameHandler to given camera view. -
-
Constructor Detail
-
ContourDetectorFrameHandler
ContourDetectorFrameHandler(Context context, ContourDetector contourDetector)
-
-
Method Detail
-
handleFrame
@Synchronized() Boolean handleFrame(FrameHandler.Frame previewFrame)
Invoked for every new camera preview frame.
- Parameters:
previewFrame
- captured preview frame data
-
addResultHandler
final Unit addResultHandler(ContourDetectorFrameHandler.ResultHandler handler)
Registers result handler which will be notified about contour detection results.
Results are coming on the worker thread. Don't forget to move execution to main thread before updating UI.
- Parameters:
handler
- handler to register.
-
removeResultHandler
final Unit removeResultHandler(ContourDetectorFrameHandler.ResultHandler handler)
Unregisters handler.
- Parameters:
handler
- handler to unregister.
-
clearResultHandlers
final Unit clearResultHandlers()
Unregisters all handlers.
-
setAcceptedAngleScore
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
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
final Unit setAcceptedBrightnessThreshold(Integer acceptedBrightnessThreshold)
The minimum brightness value to accept a detected document. Default is 50.
-
setRequiredAspectRatios
final Unit setRequiredAspectRatios(List<AspectRatio> requiredPageAspectRatios)
Set required PageAspectRatios.
-
setIgnoreBadAspectRatio
final Unit setIgnoreBadAspectRatio(Boolean ignoreBadAspectRatio)
Flag to determine whether to treat DetectionStatus.OK_BUT_BAD_ASPECT_RATIO status as DetectionStatus.OK. Default is
false
-
attach
final static ContourDetectorFrameHandler attach(IScanbotCameraView cameraView, ContourDetector detector)
Convenience method for creating new ContourDetectorFrameHandler and adding it as FrameHandler to given camera view.
- Parameters:
cameraView
- camera view to which new contour detector will be attacheddetector
- contour detector instance
-
-
-
-