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 Colorm_CanvasColorthe canvas color.protected intm_CanvasHeightthe canvas height.protected intm_CanvasWidththe canvas width.protected booleanm_CenterOnCanvaswhether to place the located object on a fixed size canvas.protected List<String>m_Errorsfor storing errors.protected booleanm_Stoppedwhether the execution was stopped.protected List<String>m_Warningsfor 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 voidaddError(String msg)Adds the error to its internal list of errors.protected voidaddWarning(String msg)Adds the warning to its internal list of warnings.LocatedObjectsannotate(BufferedImage image)Only annotates the objects in the image, does not output any sub-images.StringcanvasColorTipText()Returns the tip text for this property.StringcanvasHeightTipText()Returns the tip text for this property.StringcanvasWidthTipText()Returns the tip text for this property.protected BufferedImagecenterOnCanvas(BufferedImage img)Copies the object image onto the canvas with defined dimensions and color.StringcenterOnCanvasTipText()Returns the tip text for this property.protected voidcheck(BufferedImage image)Checks whether the input can be used.voidcleanUp()Cleans up data structures, frees up memory.voiddefineOptions()Adds options to the internal list of options.voiddestroy()Frees up memory in a "destructive" non-reversible way.protected abstract LocatedObjectsdoLocate(BufferedImage image, boolean annotateOnly)Performs the actual locating of the objects.ColorgetCanvasColor()Returns the color to use for filling the canvas.intgetCanvasHeight()Returns the height of the canvas in pixels.intgetCanvasWidth()Returns the width of the canvas in pixels.booleangetCenterOnCanvas()Returns whether to center the located object on a fixed-size canvas.protected ColorgetDefaultCanvasColor()Returns the default color for the canvas.protected intgetDefaultCanvasHeight()Returns the default height of the canvas in pixels.protected intgetDefaultCanvasWidth()Returns the default width of the canvas in pixels.protected booleangetDefaultCenterOnCanvas()Returns the default for centering the located object on a canvas.List<String>getErrors()Returns the errors.StringgetQuickInfo()Returns a quick info about the object, which can be displayed in the GUI.List<String>getWarnings()Returns the warnings.booleanhasErrors()Checks whether there are any errors recorded.booleanhasWarnings()Checks whether there are any warnings recorded;protected voidinitialize()Initializes the members.LocatedObjectslocate(BufferedImage image)Locates the objects in the image.protected voidreset()Resets the scheme.voidsetCanvasColor(Color value)Sets the color to use for filling the canvas.voidsetCanvasHeight(int value)Sets the height of the canvas in pixels.voidsetCanvasWidth(int value)Sets the width of the canvas in pixels.voidsetCenterOnCanvas(boolean value)Sets whether to center the located object on a fixed-size canvas.voidstopExecution()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:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractOptionHandler
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classAbstractOptionHandler
-
reset
protected void reset()
Resets the scheme.- Overrides:
resetin 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:
getQuickInfoin 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:
stopExecutionin interfaceStoppable
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUpin interfaceCleanUpHandler
-
destroy
public void destroy()
Frees up memory in a "destructive" non-reversible way.- Specified by:
destroyin interfaceDestroyable- Overrides:
destroyin classAbstractOptionHandler- See Also:
AbstractOptionHandler.cleanUpOptions()
-
-