Package adams.data.io.input
Class CocoAnnotationsReportReader
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.io.input.AbstractReportReader<Report>
-
- adams.data.io.input.CocoAnnotationsReportReader
-
- All Implemented Interfaces:
CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,FileFormatHandler
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,ShallowCopySupporter<AbstractReportReader>
,SizeOfHandler
,Stoppable
,StoppableWithFeedback
,ReportReader<Report>
,ObjectPrefixHandler
,Serializable
,Comparable
public class CocoAnnotationsReportReader extends AbstractReportReader<Report> implements ObjectPrefixHandler
Loads COCO annotations from the JSON file, with one report per image.
Handles only segmentations with polygons (not RLE) and only one polygon per annotation.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-input <adams.core.io.PlaceholderFile> (property: input) The file to read and turn into a report. default: ${CWD}
-prefix <java.lang.String> (property: prefix) The report field prefix used in the report. default: Object.
-label-key <java.lang.String> (property: labelKey) The key in the meta-data containing the label, ignored if empty. default: type
- 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 protected String
m_LabelKey
the meta-data key with the label.protected String
m_Prefix
the prefix of the objects in the report.-
Fields inherited from class adams.data.io.input.AbstractReportReader
m_Input, m_Stopped
-
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 CocoAnnotationsReportReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addValue(Report report, String key, Object value)
Adds the specified value to the report.void
defineOptions()
Adds options to the internal list of options.protected int
determineParentID(Report report)
Tries to determine the parent ID for the current report.String
getFormatDescription()
Returns a string describing the format (used in the file chooser).String[]
getFormatExtensions()
Returns the extension(s) of the format.String
getLabelKey()
Returns the key in the meta-data containing the label.String
getPrefix()
Returns the field prefix used in the report.String
globalInfo()
Returns a string describing the object.String
labelKeyTipText()
Returns the tip text for this property.protected Map<Integer,String>
loadCategories(net.minidev.json.JSONArray categories)
Turns the categories JSON array into a lookup table for category ID -> label.protected Map<Integer,Report>
loadImages(net.minidev.json.JSONArray images)
Turns the images JSON array into a lookup table for image ID -> Report.Report
newInstance()
Returns a new instance of the report class in use.String
prefixTipText()
Returns the tip text for this property.protected List<Report>
readData()
Performs the actual reading.void
setLabelKey(String value)
Sets the key in the meta-data containing the label.void
setPrefix(String value)
Sets the field prefix used in the report.-
Methods inherited from class adams.data.io.input.AbstractReportReader
checkData, cleanUp, compareTo, destroy, equals, forCommandLine, forName, getDefaultFormatExtension, getInput, getReaders, inputTipText, isStopped, postRead, read, reset, setInput, shallowCopy, shallowCopy, stopExecution
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, 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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
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 classAbstractReportReader<Report>
-
setPrefix
public void setPrefix(String value)
Sets the field prefix used in the report.- Specified by:
setPrefix
in interfaceObjectPrefixHandler
- Parameters:
value
- the field prefix
-
getPrefix
public String getPrefix()
Returns the field prefix used in the report.- Specified by:
getPrefix
in interfaceObjectPrefixHandler
- Returns:
- the field prefix
-
prefixTipText
public String prefixTipText()
Returns the tip text for this property.- Specified by:
prefixTipText
in interfaceObjectPrefixHandler
- 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 key in the meta-data containing the label.- Parameters:
value
- the key
-
getLabelKey
public String getLabelKey()
Returns the key in the meta-data containing the label.- Returns:
- the key
-
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.
-
getFormatDescription
public String getFormatDescription()
Returns a string describing the format (used in the file chooser).- Specified by:
getFormatDescription
in interfaceFileFormatHandler
- Specified by:
getFormatDescription
in classAbstractReportReader<Report>
- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensions
in interfaceFileFormatHandler
- Specified by:
getFormatExtensions
in classAbstractReportReader<Report>
- Returns:
- the extension(s) (without the dot!)
-
determineParentID
protected int determineParentID(Report report)
Tries to determine the parent ID for the current report.- Specified by:
determineParentID
in classAbstractReportReader<Report>
- Parameters:
report
- the report to determine the ID for- Returns:
- the parent database ID, -1 if it cannot be determined
-
newInstance
public Report newInstance()
Returns a new instance of the report class in use.- Specified by:
newInstance
in classAbstractReportReader<Report>
- Returns:
- the new (empty) report
-
loadCategories
protected Map<Integer,String> loadCategories(net.minidev.json.JSONArray categories)
Turns the categories JSON array into a lookup table for category ID -> label.- Parameters:
categories
- the array to process- Returns:
- the mapping
-
addValue
protected void addValue(Report report, String key, Object value)
Adds the specified value to the report.- Parameters:
report
- the report to updatekey
- the field namevalue
- the value (integer, double, boolean, string)
-
loadImages
protected Map<Integer,Report> loadImages(net.minidev.json.JSONArray images)
Turns the images JSON array into a lookup table for image ID -> Report.- Parameters:
images
- the array to process- Returns:
- the mapping
-
readData
protected List<Report> readData()
Performs the actual reading.- Specified by:
readData
in classAbstractReportReader<Report>
- Returns:
- the reports that were read
-
-