Class AbstractObjectLocator
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.transformer.locateobjects.AbstractObjectLocator
-
- All Implemented Interfaces:
CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,SizeOfHandler
,Stoppable
,Serializable
- Direct Known Subclasses:
AbstractMetaObjectLocator
,BinaryContours
,CannyBinary
,CannyEdges
,PassThrough
,XScreenMaskLocator
public abstract class AbstractObjectLocator extends AbstractOptionHandler implements Stoppable, CleanUpHandler, QuickInfoSupporter
Ancestor for algorithms that locate objects in images.- Version:
- $Revision: 78 $
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Color
m_CanvasColor
the canvas color.protected int
m_CanvasHeight
the canvas height.protected int
m_CanvasWidth
the canvas width.protected boolean
m_CenterOnCanvas
whether to place the located object on a fixed size canvas.protected List<String>
m_Errors
for storing errors.protected boolean
m_Stopped
whether the execution was stopped.protected List<String>
m_Warnings
for storing warnings.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractObjectLocator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addError(String msg)
Adds the error to its internal list of errors.protected void
addWarning(String msg)
Adds the warning to its internal list of warnings.LocatedObjects
annotate(BufferedImage image)
Only annotates the objects in the image, does not output any sub-images.String
canvasColorTipText()
Returns the tip text for this property.String
canvasHeightTipText()
Returns the tip text for this property.String
canvasWidthTipText()
Returns the tip text for this property.protected BufferedImage
centerOnCanvas(BufferedImage img)
Copies the object image onto the canvas with defined dimensions and color.String
centerOnCanvasTipText()
Returns the tip text for this property.protected void
check(BufferedImage image)
Checks whether the input can be used.void
cleanUp()
Cleans up data structures, frees up memory.void
defineOptions()
Adds options to the internal list of options.void
destroy()
Frees up memory in a "destructive" non-reversible way.protected abstract LocatedObjects
doLocate(BufferedImage image, boolean annotateOnly)
Performs the actual locating of the objects.Color
getCanvasColor()
Returns the color to use for filling the canvas.int
getCanvasHeight()
Returns the height of the canvas in pixels.int
getCanvasWidth()
Returns the width of the canvas in pixels.boolean
getCenterOnCanvas()
Returns whether to center the located object on a fixed-size canvas.protected Color
getDefaultCanvasColor()
Returns the default color for the canvas.protected int
getDefaultCanvasHeight()
Returns the default height of the canvas in pixels.protected int
getDefaultCanvasWidth()
Returns the default width of the canvas in pixels.protected boolean
getDefaultCenterOnCanvas()
Returns the default for centering the located object on a canvas.List<String>
getErrors()
Returns the errors.String
getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.List<String>
getWarnings()
Returns the warnings.boolean
hasErrors()
Checks whether there are any errors recorded.boolean
hasWarnings()
Checks whether there are any warnings recorded;protected void
initialize()
Initializes the members.LocatedObjects
locate(BufferedImage image)
Locates the objects in the image.protected void
reset()
Resets the scheme.void
setCanvasColor(Color value)
Sets the color to use for filling the canvas.void
setCanvasHeight(int value)
Sets the height of the canvas in pixels.void
setCanvasWidth(int value)
Sets the width of the canvas in pixels.void
setCenterOnCanvas(boolean value)
Sets whether to center the located object on a fixed-size canvas.void
stopExecution()
Stops the execution.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_CenterOnCanvas
protected boolean m_CenterOnCanvas
whether to place the located object on a fixed size canvas.
-
m_CanvasWidth
protected int m_CanvasWidth
the canvas width.
-
m_CanvasHeight
protected int m_CanvasHeight
the canvas height.
-
m_CanvasColor
protected Color m_CanvasColor
the canvas color.
-
m_Stopped
protected boolean m_Stopped
whether the execution was stopped.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractOptionHandler
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractOptionHandler
-
reset
protected void reset()
Resets the scheme.- Overrides:
reset
in classAbstractOptionHandler
-
getDefaultCenterOnCanvas
protected boolean getDefaultCenterOnCanvas()
Returns the default for centering the located object on a canvas.- Returns:
- the default
-
setCenterOnCanvas
public void setCenterOnCanvas(boolean value)
Sets whether to center the located object on a fixed-size canvas.- Parameters:
value
- true if to center on fixed-size canvas
-
getCenterOnCanvas
public boolean getCenterOnCanvas()
Returns whether to center the located object on a fixed-size canvas.- Returns:
- true if to center on fixed-size canvas
-
centerOnCanvasTipText
public String centerOnCanvasTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getDefaultCanvasWidth
protected int getDefaultCanvasWidth()
Returns the default width of the canvas in pixels.- Returns:
- the width in pixels
-
setCanvasWidth
public void setCanvasWidth(int value)
Sets the width of the canvas in pixels.- Parameters:
value
- the width in pixels
-
getCanvasWidth
public int getCanvasWidth()
Returns the width of the canvas in pixels.- Returns:
- the width in pixels
-
canvasWidthTipText
public String canvasWidthTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getDefaultCanvasHeight
protected int getDefaultCanvasHeight()
Returns the default height of the canvas in pixels.- Returns:
- the height in pixels
-
setCanvasHeight
public void setCanvasHeight(int value)
Sets the height of the canvas in pixels.- Parameters:
value
- the height in pixels
-
getCanvasHeight
public int getCanvasHeight()
Returns the height of the canvas in pixels.- Returns:
- the height in pixels
-
canvasHeightTipText
public String canvasHeightTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getDefaultCanvasColor
protected Color getDefaultCanvasColor()
Returns the default color for the canvas.- Returns:
- the color
-
setCanvasColor
public void setCanvasColor(Color value)
Sets the color to use for filling the canvas.- Parameters:
value
- the color
-
getCanvasColor
public Color getCanvasColor()
Returns the color to use for filling the canvas.- Returns:
- the color
-
canvasColorTipText
public String canvasColorTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.
Default implementation returns null.- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Returns:
- null if no info available, otherwise short string
-
hasErrors
public boolean hasErrors()
Checks whether there are any errors recorded.- Returns:
- true if at least one error recorded
-
addError
protected void addError(String msg)
Adds the error to its internal list of errors.- Parameters:
msg
- the error message to add
-
hasWarnings
public boolean hasWarnings()
Checks whether there are any warnings recorded;- Returns:
- true if at least one error recorded
-
addWarning
protected void addWarning(String msg)
Adds the warning to its internal list of warnings.- Parameters:
msg
- the warnings message to add
-
check
protected void check(BufferedImage image)
Checks whether the input can be used.
Default implementation only checks whether image is not null.- Parameters:
image
- the image to check
-
centerOnCanvas
protected BufferedImage centerOnCanvas(BufferedImage img)
Copies the object image onto the canvas with defined dimensions and color. In case the image is too large for the canvas, the- Parameters:
img
- the located object- Returns:
- the new image with the located image centered
-
doLocate
protected abstract LocatedObjects doLocate(BufferedImage image, boolean annotateOnly)
Performs the actual locating of the objects.- Parameters:
image
- the image to processannotateOnly
- whether to annotate only- Returns:
- the containers of located objects
-
locate
public LocatedObjects locate(BufferedImage image)
Locates the objects in the image.- Parameters:
image
- the image to process- Returns:
- the containers of located objects
-
annotate
public LocatedObjects annotate(BufferedImage image)
Only annotates the objects in the image, does not output any sub-images.- Parameters:
image
- the image to process- Returns:
- the annotated objects
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceStoppable
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUp
in interfaceCleanUpHandler
-
destroy
public void destroy()
Frees up memory in a "destructive" non-reversible way.- Specified by:
destroy
in interfaceDestroyable
- Overrides:
destroy
in classAbstractOptionHandler
- See Also:
AbstractOptionHandler.cleanUpOptions()
-
-