public class ContourDetectorFrameHandler extends java.lang.Object implements PreviewBuffer.FrameHandler
ContourDetectorFrameHandler.ResultHandler
(addResultHandler(ResultHandler)).
Preview frame considered intercepted if at least one
ContourDetectorFrameHandler.ResultHandler returns true from
net.doo.snap.camera.ContourDetectorFrameHandler.ResultHandler#handleResult(DetectedFrame)
PreviewBuffer| Modifier and Type | Class and Description |
|---|---|
static class |
ContourDetectorFrameHandler.DetectedFrame
Contour detection results alongside with information about frame
|
static interface |
ContourDetectorFrameHandler.ResultHandler
Continiously notified about contour detection results.
|
| Constructor and Description |
|---|
ContourDetectorFrameHandler(android.content.Context context) |
| Modifier and Type | Method and Description |
|---|---|
void |
addResultHandler(ContourDetectorFrameHandler.ResultHandler handler)
Registers result handler which will be notified about contour detection results.
|
static ContourDetectorFrameHandler |
attach(ScanbotCameraView cameraView)
Convenience method for creating new
ContourDetectorFrameHandler and adding it
as PreviewBuffer.FrameHandler to given camera view. |
boolean |
handleFrame(byte[] frame,
int width,
int height,
int frameOrientation)
Invoked for every new camera preview frame
|
boolean |
isEnabled() |
void |
removeResultHandler(ContourDetectorFrameHandler.ResultHandler handler)
Unregisters handler.
|
void |
setEnabled(boolean enabled) |
public ContourDetectorFrameHandler(android.content.Context context)
public static ContourDetectorFrameHandler attach(ScanbotCameraView cameraView)
ContourDetectorFrameHandler and adding it
as PreviewBuffer.FrameHandler to given camera view.cameraView - camera view to which new contour detector will be attachedContourDetectorFrameHandlerpublic boolean handleFrame(byte[] frame,
int width,
int height,
int frameOrientation)
PreviewBuffer.FrameHandlerhandleFrame in interface PreviewBuffer.FrameHandlerframe - image in NV21 formatwidth - width of the imageheight - height of the imageframeOrientation - orientation of the image (in degrees)true if frame should be considered as "intercepted", i.e. no further
processing should be performed on it. false to allow other frame handlers to
process this frame.public void addResultHandler(ContourDetectorFrameHandler.ResultHandler handler)
Results are coming on the worker thread. Don't forget to move execution to main thread before updating UI.
handler - handler to register. Must not be null. If handler was already
registered, nothing happens.public void removeResultHandler(ContourDetectorFrameHandler.ResultHandler handler)
handler - handler to unregister. If it was not registered before, nothing happens.public boolean isEnabled()
true if contour detection is enabled. false if contour detection
is disabled, i.e. incoming frames are skipped.public void setEnabled(boolean enabled)
enabled - true to enable contour detection. false to disable
contour detection.