Package adams.data.objectoverlap
Class IntersectOverUnionRatio
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.objectoverlap.AbstractObjectOverlap
-
- adams.data.objectoverlap.IntersectOverUnionRatio
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,SizeOfHandler
,BoundingBoxFallbackSupporter
,LabelAwareObjectOverlap
,ObjectOverlap
,OptionalBoundingBoxFallbackSupporter
,Serializable
public class IntersectOverUnionRatio extends AbstractObjectOverlap implements LabelAwareObjectOverlap, OptionalBoundingBoxFallbackSupporter
Computes the Intersect Over Union (IOU) between annotations and predictions.- Author:
- Hisham (habdelqa at waikato dot ac dot nz), FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
IOU_COUNT
the IOU count.static String
IOU_LABEL_HIGHEST
the label of the highest IOU.static String
IOU_LABEL_HIGHEST_MATCH
whether the labels of the highest IOU match.static String
IOU_PERCENTAGE_HIGHEST
the highest IOU percentage.protected boolean
m_AdditionalObject
whether to check for additional predicted objects not present in actual.protected double
m_BoundingBoxFallbackRatio
the ratio used for determining whether to fall back from polygon on bbox.protected boolean
m_Fallback
whether to fallback on bounding box.protected GeometryType
m_Geometry
the geometry to use.protected String
m_LabelKey
the label meta-data key - ignored if empty.protected double
m_MinIntersectOverUnionRatio
the minimum IOU ratio to use.protected boolean
m_UseOtherObject
whether to use the other object in the output in case of an overlap.-
Fields inherited from class adams.data.objectoverlap.AbstractObjectOverlap
m_CopyMetaData, m_ExcludeIdentical, m_MetaDataKeys
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.data.objectoverlap.ObjectOverlap
ADDITIONAL_OBJ, UNKNOWN_LABEL
-
-
Constructor Summary
Constructors Constructor Description IntersectOverUnionRatio()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
additionalObjectTipText()
Returns the tip text for this property.String
boundingBoxFallbackRatioTipText()
Returns the tip text for this property.protected double
calculateIoU(LocatedObject thisObj, LocatedObject otherObj)
Calculates the IoU for the two objects.void
defineOptions()
Adds options to the internal list of options.protected LocatedObjects
doCalculate(LocatedObjects annotations, LocatedObjects predictions, Map<LocatedObject,Map<LocatedObject,Double>> matches)
Computes the overlapping objects between the annotations and the predictions.String
fallbackTipText()
Returns the tip text for this property.String
geometryTipText()
Returns the tip text for this property.boolean
getAdditionalObject()
Returns whether to count additional predicted objects.double
getBoundingBoxFallbackRatio()
Returns the ratio between shape area over bbox area.boolean
getFallback()
Returns whether to fall back on the bounding box if no polygon available.GeometryType
getGeometry()
Returns the geometry type to use for the calculations.String
getLabelKey()
Returns the (optional) key for a string label in the meta-data; if supplied the value of the object with the highest overlap gets stored in the report usingIOU_LABEL_HIGHEST
,IOU_LABEL_HIGHEST_MATCH
stores whether the labels match.double
getMinIntersectOverUnionRatio()
Returns the minimum IOU ratio to use.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.boolean
getUseOtherObject()
Returns whether to use/forward other object data.String
globalInfo()
Returns a string describing the object.String
labelKeyTipText()
Returns the tip text for this property.String
minIntersectOverUnionRatioTipText()
Returns the tip text for this property.void
setAdditionalObject(boolean value)
Sets whether to count additional predicted objects.void
setBoundingBoxFallbackRatio(double value)
Sets the ratio between shape area over bbox area.void
setFallback(boolean value)
Sets whether to fall back on the bounding box if no polygon available.void
setGeometry(GeometryType value)
Sets the geometry type to use for the calculations.void
setLabelKey(String value)
Sets the (optional) key for a string label in the meta-data; if supplied the value of the object with the highest overlap gets stored in the report usingIOU_LABEL_HIGHEST
,IOU_LABEL_HIGHEST_MATCH
stores whether the labels match.void
setMinIntersectOverUnionRatio(double value)
Sets the minimum IOU ratio to use.void
setUseOtherObject(boolean value)
Sets whether to use/forward other object data.com.github.fracpete.javautils.struct.Struct2<LocatedObjects,LocatedObjects>
splitOverlaps(LocatedObjects overlaps)
Splits the overlapping objects into subsets of matching labels and mismatching ones.String
useOtherObjectTipText()
Returns the tip text for this property.-
Methods inherited from class adams.data.objectoverlap.AbstractObjectOverlap
addMatch, calculate, check, copyMetaData, copyMetaDataTipText, excludeIdenticalTipText, getCopyMetaData, getExcludeIdentical, getMetaDataKeys, initMatch, matches, metaDataKeysTipText, setCopyMetaData, setExcludeIdentical, setMetaDataKeys
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, reset, 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.Destroyable
destroy
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.data.objectoverlap.ObjectOverlap
calculate, matches
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
-
-
-
Field Detail
-
IOU_PERCENTAGE_HIGHEST
public static final String IOU_PERCENTAGE_HIGHEST
the highest IOU percentage.- See Also:
- Constant Field Values
-
IOU_LABEL_HIGHEST
public static final String IOU_LABEL_HIGHEST
the label of the highest IOU.- See Also:
- Constant Field Values
-
IOU_LABEL_HIGHEST_MATCH
public static final String IOU_LABEL_HIGHEST_MATCH
whether the labels of the highest IOU match.- See Also:
- Constant Field Values
-
IOU_COUNT
public static final String IOU_COUNT
the IOU count.- See Also:
- Constant Field Values
-
m_MinIntersectOverUnionRatio
protected double m_MinIntersectOverUnionRatio
the minimum IOU ratio to use.
-
m_LabelKey
protected String m_LabelKey
the label meta-data key - ignored if empty.
-
m_UseOtherObject
protected boolean m_UseOtherObject
whether to use the other object in the output in case of an overlap.
-
m_AdditionalObject
protected boolean m_AdditionalObject
whether to check for additional predicted objects not present in actual.
-
m_Geometry
protected GeometryType m_Geometry
the geometry to use.
-
m_Fallback
protected boolean m_Fallback
whether to fallback on bounding box.
-
m_BoundingBoxFallbackRatio
protected double m_BoundingBoxFallbackRatio
the ratio used for determining whether to fall back from polygon on bbox.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractObjectOverlap
-
setMinIntersectOverUnionRatio
public void setMinIntersectOverUnionRatio(double value)
Sets the minimum IOU ratio to use.- Parameters:
value
- the minimum ratio
-
getMinIntersectOverUnionRatio
public double getMinIntersectOverUnionRatio()
Returns the minimum IOU ratio to use.- Returns:
- the minimum ratio
-
minIntersectOverUnionRatioTipText
public String minIntersectOverUnionRatioTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setLabelKey
public void setLabelKey(String value)
Sets the (optional) key for a string label in the meta-data; if supplied the value of the object with the highest overlap gets stored in the report usingIOU_LABEL_HIGHEST
,IOU_LABEL_HIGHEST_MATCH
stores whether the labels match.- Parameters:
value
- the key, ignored if empty
-
getLabelKey
public String getLabelKey()
Returns the (optional) key for a string label in the meta-data; if supplied the value of the object with the highest overlap gets stored in the report usingIOU_LABEL_HIGHEST
,IOU_LABEL_HIGHEST_MATCH
stores whether the labels match.- Returns:
- the key, ignored if empty
-
labelKeyTipText
public String labelKeyTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setUseOtherObject
public void setUseOtherObject(boolean value)
Sets whether to use/forward other object data.- Parameters:
value
- true if to use other object
-
getUseOtherObject
public boolean getUseOtherObject()
Returns whether to use/forward other object data.- Returns:
- true if to use other object
-
useOtherObjectTipText
public String useOtherObjectTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setAdditionalObject
public void setAdditionalObject(boolean value)
Sets whether to count additional predicted objects.- Parameters:
value
- true if to count additional predicted objects
-
getAdditionalObject
public boolean getAdditionalObject()
Returns whether to count additional predicted objects.- Returns:
- true if to count additional predicted objects
-
additionalObjectTipText
public String additionalObjectTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setGeometry
public void setGeometry(GeometryType value)
Sets the geometry type to use for the calculations.- Parameters:
value
- the type
-
getGeometry
public GeometryType getGeometry()
Returns the geometry type to use for the calculations.- Returns:
- the type
-
geometryTipText
public String geometryTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setFallback
public void setFallback(boolean value)
Sets whether to fall back on the bounding box if no polygon available.- Specified by:
setFallback
in interfaceOptionalBoundingBoxFallbackSupporter
- Parameters:
value
- true if to use
-
getFallback
public boolean getFallback()
Returns whether to fall back on the bounding box if no polygon available.- Specified by:
getFallback
in interfaceOptionalBoundingBoxFallbackSupporter
- Returns:
- true if to use
-
fallbackTipText
public String fallbackTipText()
Returns the tip text for this property.- Specified by:
fallbackTipText
in interfaceOptionalBoundingBoxFallbackSupporter
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setBoundingBoxFallbackRatio
public void setBoundingBoxFallbackRatio(double value)
Sets the ratio between shape area over bbox area. If below the bbox is used instead of the polygon.- Specified by:
setBoundingBoxFallbackRatio
in interfaceBoundingBoxFallbackSupporter
- Parameters:
value
- the ratio
-
getBoundingBoxFallbackRatio
public double getBoundingBoxFallbackRatio()
Returns the ratio between shape area over bbox area. If below the bbox is used instead of the polygon.- Specified by:
getBoundingBoxFallbackRatio
in interfaceBoundingBoxFallbackSupporter
- Returns:
- the ratio
-
boundingBoxFallbackRatioTipText
public String boundingBoxFallbackRatioTipText()
Returns the tip text for this property.- Specified by:
boundingBoxFallbackRatioTipText
in interfaceBoundingBoxFallbackSupporter
- 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 actor, which will be displayed in the GUI.- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractObjectOverlap
- Returns:
- null if no info available, otherwise short string
-
calculateIoU
protected double calculateIoU(LocatedObject thisObj, LocatedObject otherObj)
Calculates the IoU for the two objects.- Parameters:
thisObj
- first objectotherObj
- second object- Returns:
- the IoU
-
doCalculate
protected LocatedObjects doCalculate(LocatedObjects annotations, LocatedObjects predictions, Map<LocatedObject,Map<LocatedObject,Double>> matches)
Computes the overlapping objects between the annotations and the predictions.- Specified by:
doCalculate
in classAbstractObjectOverlap
- Parameters:
annotations
- the annotations (ground truth)predictions
- the predictions to compare withmatches
- for collecting the matches- Returns:
- the overlapping objects
-
splitOverlaps
public com.github.fracpete.javautils.struct.Struct2<LocatedObjects,LocatedObjects> splitOverlaps(LocatedObjects overlaps)
Splits the overlapping objects into subsets of matching labels and mismatching ones.- Specified by:
splitOverlaps
in interfaceLabelAwareObjectOverlap
- Parameters:
overlaps
- all overlaps, to split- Returns:
- split into matching/mismatching subsets
-
-