Deep Learning SDK for Geospatial Data
 1.0.0+
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
Classification

Detailed Description

Contains classification and feature detection functionality.

Classes

class  dg::deepcore::classification::CaffeModel
 A Caffe Model. More...
 
class  dg::deepcore::classification::CaffeNetParameterIndex
 
class  dg::deepcore::classification::CaffeLayerIndex
 Holds a caffe::LayerParamer and its connections to other layers. More...
 
class  dg::deepcore::classification::Model
 Represents a feature detection and classification model. More...
 
struct  dg::deepcore::classification::Prediction
 A structure to hold information about hits during detection and classification runs. More...
 
struct  dg::deepcore::classification::WindowPrediction
 Another Prediction struct that also keeps the window region where the detection happened. More...
 
class  dg::deepcore::classification::CaffeModelMetadata
 Contains Caffe model metadata. More...
 
class  dg::deepcore::classification::CaffeModelMetadataJson
 Converts between CaffeModelMetadata and JSON. More...
 
class  dg::deepcore::classification::CaffeModelPackage
 Represents a Caffe model package. More...
 
class  dg::deepcore::classification::GbdxModelReader
 Reads a ModelPackage from a gbdxm file. More...
 
class  dg::deepcore::classification::GbdxModelWriter
 Writes a ModelPackage to a gbdxm file. More...
 
class  dg::deepcore::classification::ModelMetadata
 Contains model metadata. More...
 
class  dg::deepcore::classification::ModelMetadataT< T >
 A template class implementing some default constructors and ModelMetadata::copy in terms of operator=. More...
 
class  dg::deepcore::classification::ModelMetadataJson
 Converts between ModelMetadata and JSON. More...
 
class  dg::deepcore::classification::ModelPackage
 An abstract base class for model packages. Contains metadata and a loading and packaging mechanism. More...
 
class  dg::deepcore::classification::ModelPackageT< T >
 A template class implementing some default constructors. More...
 

Typedefs

typedef CaffeModelMetadata dg::deepcore::classification::CaffeModelPackage::MetadataType
 Defines a CaffeModelMetadata as MetadataType. More...
 
using dg::deepcore::classification::CaffeLayerIndexMap = std::map< std::string, CaffeLayerIndex * >
 
typedef std::vector< std::string > dg::deepcore::classification::Labels
 A collection of string labels to be used for the classes identified in a model. More...
 

Enumerations

enum  dg::deepcore::classification::FilterType { dg::deepcore::classification::Include, dg::deepcore::classification::Exclude }
 The type of filtering to perform. More...
 
enum  dg::deepcore::classification::ModelMetadata::ColorMode { dg::deepcore::classification::ModelMetadata::UNKNOWN = 0, dg::deepcore::classification::ModelMetadata::GRAYSCALE = 1, dg::deepcore::classification::ModelMetadata::RGB = 2, dg::deepcore::classification::ModelMetadata::MULTIBAND = 3 }
 A list of the color modes that are supported in a model. More...
 

Functions

const char * dg::deepcore::classification::CaffeModelMetadata::type () const noexceptoverride
 The type of model found in this metadata. More...
 
virtual ModelMetadata * dg::deepcore::classification::ModelMetadata::copy () const =0
 Creates a copy of this object. More...
 
virtual const char * dg::deepcore::classification::ModelMetadata::type () const noexcept=0
 Get the identifier for the model type. More...
 
 dg::deepcore::classification::ModelMetadataT< T >::ModelMetadataT (const T &rhs)
 Copy Constructor for ModelMetadataT. More...
 
 dg::deepcore::classification::ModelMetadataT< T >::ModelMetadataT (T &&rhs)
 Move constructor for ModelMetadataT. More...
 
virtual ModelMetadata * dg::deepcore::classification::ModelMetadataT< T >::copy () const override
 Method to copy the ModelMetadata. More...
 
virtual const char * dg::deepcore::classification::ModelPackage::type () const noexcept=0
 Gets the identifier for the model type. More...
 
virtual const Labels & dg::deepcore::classification::ModelPackage::itemNames () const noexcept=0
 Gets the list of allowed item names for this model. More...
 
virtual const std::vector
< std::string > & 
dg::deepcore::classification::ModelPackage::modelMetadataItemNames () const noexcept=0
 Gets the list of items that can contain model metadata and can be read by ModelPackage::readMetadataFromItem. More...
 
virtual const std::vector
< std::string > & 
dg::deepcore::classification::ModelPackage::metadataItemNames () const noexcept=0
 Gets the list of metadata items that are guaranteed to be retrieved from model items. Other metadata items can be retrieved, but the ones returned by this methods must always be retrived. More...
 
std::vector< std::string > dg::deepcore::classification::ModelPackage::readMetadataFromItem (const std::string &itemName) const
 Gets the metadata from a specified item name. More...
 
virtual std::vector< std::string > dg::deepcore::classification::ModelPackage::readMetadataFromItem (const std::string &itemName, const std::vector< uint8_t > &itemData) const =0
 Read metadata from the given item data. More...
 
 dg::deepcore::classification::ModelPackageT< T >::ModelPackageT (const T &rhs)
 Copy constructor for the ModelPackageT. More...
 
 dg::deepcore::classification::ModelPackageT< T >::ModelPackageT (T &&rhs)
 Move constructor for the ModelPackageT. More...
 
const std::vector< std::string > & dg::deepcore::classification::ModelPackageT< T >::itemNames () const noexceptoverride
 A method that returns all of the item names inside the ModelPackageT. More...
 
const std::vector< std::string > & dg::deepcore::classification::ModelPackageT< T >::modelMetadataItemNames () const noexceptoverride
 A method that returns all of the item names for the model metadata inside the ModelPackageT. More...
 
const std::vector< std::string > & dg::deepcore::classification::ModelPackageT< T >::metadataItemNames () const noexceptoverride
 A method that returns all of the names for the items in the ModelPackageT metadata. More...
 
 dg::deepcore::classification::Prediction::Prediction ()
 Default Constructor for Prediction. More...
 
 dg::deepcore::classification::Prediction::Prediction (const std::string &label, float confidence=0.0)
 Constructor for Prediction. More...
 
 dg::deepcore::classification::WindowPrediction::WindowPrediction ()
 Default constructor for WindowPrediction. More...
 
 dg::deepcore::classification::WindowPrediction::WindowPrediction (const std::vector< Prediction > &predictions, const cv::Rect &window)
 A parameterized constructor for WindowPrediction. More...
 
 dg::deepcore::classification::WindowPrediction::WindowPrediction (std::vector< Prediction > &&predictions, cv::Rect &&window)
 A move constructor for WindowPrediction. More...
 
std::vector< WindowPrediction > dg::deepcore::classification::filterLabels (const std::vector< WindowPrediction > &windowPredictions, FilterType type, const std::set< std::string > &labels)
 Run category filtering to remove unwanted or retain only wanted categories. More...
 
formatting_ostream & dg::deepcore::classification::operator<< (formatting_ostream &os, const ModelMetadata::ColorMode &mode)
 Allows logging a ModelMetadata::ColorMode with DG_LOG. More...
 
std::vector< WindowPrediction > dg::deepcore::classification::nonMaxSuppression (const vector< WindowPrediction > &windowPredictions, float overlapThreshold)
 Run Non-Maximum Suppression (NMS) to remove overlapping prediction windows. More...
 
static const std::vector
< std::string > 
dg::deepcore::classification::CaffeModelMetadataJson::fieldNames ()
 Gets the metadata field names specific to Caffe model type. More...
 
static const std::map
< std::string, std::string > 
dg::deepcore::classification::CaffeModelMetadataJson::fieldToOption ()
 Gets the metadata field names specific to Caffe model type. More...
 
const std::vector< uint8_t > & dg::deepcore::classification::CaffeModelPackage::model () const
 Gets the model data. More...
 
std::vector< uint8_t > & dg::deepcore::classification::CaffeModelPackage::model ()
 Gets the model data. More...
 
const std::vector< uint8_t > & dg::deepcore::classification::CaffeModelPackage::trained () const
 Gets the trained data. More...
 
std::vector< uint8_t > & dg::deepcore::classification::CaffeModelPackage::trained ()
 Gets the trained data. More...
 
const std::vector< uint8_t > & dg::deepcore::classification::CaffeModelPackage::mean () const
 Returns the mean data. More...
 
std::vector< uint8_t > & dg::deepcore::classification::CaffeModelPackage::mean ()
 Returns the mean data. More...
 
 dg::deepcore::classification::GbdxModelReader::GbdxModelReader (std::istream &is)
 Constructs a gbdxm model reader from an input stream. More...
 
 dg::deepcore::classification::GbdxModelReader::GbdxModelReader (const std::vector< uint8_t > &buf)
 Constructs a gbdxm model reader from a vector. More...
 
 dg::deepcore::classification::GbdxModelReader::GbdxModelReader (const uint8_t *buf, size_t size)
 Constructs a gbdxm model reader from a memory buffer. More...
 
 dg::deepcore::classification::GbdxModelReader::GbdxModelReader (const std::string &fileName)
 Constructs a gbdxm model reader from a file. More...
 
ModelPackage * dg::deepcore::classification::GbdxModelReader::readModel ()
 Read the model. More...
 
ModelPackage * dg::deepcore::classification::GbdxModelReader::readModel (std::map< std::string, std::string > &outContentsMap)
 Read the model and return the original contents map. More...
 
 dg::deepcore::classification::GbdxModelWriter::GbdxModelWriter (std::ostream &os, const ModelPackage &model, bool encrypt=true)
 Constructs a GbdxModelWriter to write to the given output stream. More...
 
 dg::deepcore::classification::GbdxModelWriter::GbdxModelWriter (const std::string &fileName, const ModelPackage &model, bool encrypt=true)
 Constructs a GbdxModelWriter to write to a file on disk. More...
 
void dg::deepcore::classification::GbdxModelWriter::close ()
 Closes the writer. The object is unusable after it's closed. More...
 
void dg::deepcore::classification::GbdxModelWriter::writeModel (const std::map< std::string, std::string > &contentMap)
 Writes out the model contained in the ModelPackage. More...
 
void dg::deepcore::classification::GbdxModelWriter::writeMetadata (const std::map< std::string, std::string > &contentMap)
 Writes the model metadata. Metadata must be written before any more files are written to the package. More...
 
void dg::deepcore::classification::GbdxModelWriter::addFile (const std::string &itemName, const std::string &fileName)
 Adds a file to the archive from a file on disk. More...
 
void dg::deepcore::classification::GbdxModelWriter::addFile (const std::string &itemName, std::istream &is)
 Adds a file to the archive from an input stream. More...
 
void dg::deepcore::classification::GbdxModelWriter::addFile (const std::string &itemName, const std::vector< uint8_t > &buf)
 Adds a file to the archive from a vector. More...
 
void dg::deepcore::classification::GbdxModelWriter::addFile (const std::string &itemName, const uint8_t *buf, size_t size)
 Adds a file to the archive from a memory buffer. More...
 
void dg::deepcore::classification::GbdxModelWriter::addFileFromString (const std::string &itemName, const std::string &buf)
 Adds a file to the archive from a string. More...
 
static ModelMetadata * dg::deepcore::classification::ModelMetadata::create (const char *type)
 A factory function that creates metadata based on type. More...
 
 dg::deepcore::classification::ModelMetadata::ModelMetadata ()
 Default constructor. More...
 
virtual ModelMetadata & dg::deepcore::classification::ModelMetadata::operator= (const ModelMetadata &rhs)
 The copy operator. Can be overridden if additional state needs to be copied. More...
 
virtual ModelMetadata & dg::deepcore::classification::ModelMetadata::operator= (ModelMetadata &&rhs)
 The move operator. Can be overridden if additional state needs to be copied. More...
 
const std::string & dg::deepcore::classification::ModelMetadata::version () const noexcept
 Gets the model version. More...
 
void dg::deepcore::classification::ModelMetadata::setVersion (const std::string &version) noexcept
 Sets the model version. More...
 
const std::string & dg::deepcore::classification::ModelMetadata::name () const noexcept
 Gets the model name. More...
 
const void dg::deepcore::classification::ModelMetadata::setName (const std::string &name) noexcept
 Sets the model name. More...
 
const std::string & dg::deepcore::classification::ModelMetadata::description () const noexcept
 Gets the model descriptions. More...
 
void dg::deepcore::classification::ModelMetadata::setDescription (const std::string &description) noexcept
 Sets the model description. More...
 
time_t dg::deepcore::classification::ModelMetadata::timeCreated () const noexcept
 Gets the model creation date/time. More...
 
void dg::deepcore::classification::ModelMetadata::setTimeCreated (time_t timeCreated) noexcept
 Sets the model creation date/time. More...
 
const Labels & dg::deepcore::classification::ModelMetadata::labels () const noexcept
 Gets the model labels. More...
 
Labels & dg::deepcore::classification::ModelMetadata::labels () noexcept
 Gets the model labels. More...
 
void dg::deepcore::classification::ModelMetadata::setLabels (const Labels &labels) noexcept
 Sets the model labels. More...
 
void dg::deepcore::classification::ModelMetadata::setLabels (Labels &&labels) noexcept
 Sets the model labels. More...
 
const cv::Size & dg::deepcore::classification::ModelMetadata::modelSize () const noexcept
 Gets the model size. More...
 
cv::Size & dg::deepcore::classification::ModelMetadata::modelSize () noexcept
 Gets the model size. More...
 
void dg::deepcore::classification::ModelMetadata::setModelSize (const cv::Size &modelSize) noexcept
 Sets the model size. More...
 
const cv::Rect2d & dg::deepcore::classification::ModelMetadata::boundingBox () const noexcept
 Gets the bounding box (lat/lon). More...
 
cv::Rect2d & dg::deepcore::classification::ModelMetadata::boundingBox () noexcept
 Gets the bounding box (lat/lon). More...
 
void dg::deepcore::classification::ModelMetadata::setBoundingBox (const cv::Rect2d &boundingBox) noexcept
 Sets the bounding box (lat/lon). More...
 
const std::string & dg::deepcore::classification::ModelMetadata::imageType () const noexcept
 Gets the image type. More...
 
void dg::deepcore::classification::ModelMetadata::setImageType (const std::string &imageType) noexcept
 Sets the image type. More...
 
ColorMode dg::deepcore::classification::ModelMetadata::colorMode () const noexcept
 Gets the color mode. More...
 
void dg::deepcore::classification::ModelMetadata::setColorMode (ColorMode colorMode) noexcept
 Sets the color mode. More...
 
int64_t dg::deepcore::classification::ModelMetadata::size () const noexcept
 Gets the total serialized uncompressed model package size. More...
 
void dg::deepcore::classification::ModelMetadata::setSize (int64_t size) noexcept
 Sets the total serialized uncompressed model package size. More...
 
static Json::Value dg::deepcore::classification::ModelMetadataJson::toJson (const ModelMetadata &metadata)
 Convert the given model metadata to JSON. More...
 
static ModelMetadata * dg::deepcore::classification::ModelMetadataJson::fromJson (const Json::Value &root)
 Convert JSON to ModelMetada. More...
 
static ModelMetadata * dg::deepcore::classification::ModelMetadataJson::fromJsonPartial (const Json::Value &root, std::vector< std::string > &missingFields)
 Convert JSON to ModelMetada, not requiring all metadata to be there, but listing the missing fields instead. More...
 
static std::map< std::string,
std::string > 
dg::deepcore::classification::ModelMetadataJson::fieldToOption (const std::string &type)
 Creates a map that is used for conversion of fieldName->CLIOptions. More...
 
static std::vector< std::string > dg::deepcore::classification::ModelMetadataJson::fieldNames (const std::string &type)
 Gets the metadata field names for the given model type. More...
 
Json::Value dg::deepcore::classification::ModelMetadataJson::toJsonBase (const ModelMetadata &metadata)
 Convert common model metadata to JSON. Must be called from all ModelMetadata::toJsonInternal implementations. More...
 
void dg::deepcore::classification::ModelMetadataJson::fromJsonBase (const Json::Value &root, ModelMetadata &metadata, std::vector< std::string > &missingFields)
 Read common metadata from JSON. Must be called from all ModelMetadata::fromJsonInternal implementations. More...
 
static ModelPackage * dg::deepcore::classification::ModelPackage::create (ModelMetadata *metadata)
 Create a ModelMetada instance based on given metadata. More...
 
static ModelPackage * dg::deepcore::classification::ModelPackage::create (const ModelMetadata &metadata)
 Create a ModelMetada instance based on given metadata. More...
 
static ModelPackage * dg::deepcore::classification::ModelPackage::create (const char *type)
 Create a ModelMetadata instance based on type with metadata initialized to default values. More...
 
virtual ModelPackage & dg::deepcore::classification::ModelPackage::operator= (const ModelPackage &rhs)
 The copy operator. Can be overridden if additional state needs to be copied. More...
 
virtual ModelPackage & dg::deepcore::classification::ModelPackage::operator= (ModelPackage &&rhs)
 The move operator. Can be overridden if additional state needs to be moved. More...
 
const ModelMetadata & dg::deepcore::classification::ModelPackage::metadata () const
 Gets the metadata. More...
 
ModelMetadata & dg::deepcore::classification::ModelPackage::metadata ()
 Gets the metadata. More...
 
void dg::deepcore::classification::ModelPackage::setMetadata (const ModelMetadata &metadata) noexcept
 Sets the metadata. More...
 
void dg::deepcore::classification::ModelPackage::setMetadata (ModelMetadata *metadata)
 Sets the metadata. More...
 
const std::vector< uint8_t > & dg::deepcore::classification::ModelPackage::item (const std::string &itemName) const
 Get a model item. More...
 
std::vector< uint8_t > & dg::deepcore::classification::ModelPackage::item (const std::string &itemName)
 Get a model item. More...
 
bool dg::deepcore::classification::ModelPackage::haveItem (const std::string &itemName) const
 Returns whether an item already exists in the model. More...
 
void dg::deepcore::classification::ModelPackage::setItem (const std::string &itemName, const std::vector< uint8_t > &item)
 Sets a model item. More...
 
void dg::deepcore::classification::ModelPackage::setItem (const std::string &itemName, std::vector< uint8_t > &&item)
 Sets a model item. More...
 

Variables

static const std::vector
< std::string > 
dg::deepcore::classification::CaffeModelPackage::ITEM_NAMES
 A collection of strings that names that will be found in this package. More...
 
static const std::vector
< std::string > 
dg::deepcore::classification::CaffeModelPackage::METADATA_ITEM_NAMES
 A collection of strings that are metadata item names for the items in the package. More...
 
static const std::vector
< std::string > 
dg::deepcore::classification::CaffeModelPackage::MODEL_METADATA_ITEM_NAMES
 A collection of names of items found in the model. More...
 
std::string dg::deepcore::classification::Prediction::label
 A string label that is the display name of the class in the model for this Prediction. More...
 
float dg::deepcore::classification::Prediction::confidence
 A float value that is the minimum threshold value for this Prediction. More...
 
std::vector< Prediction > dg::deepcore::classification::WindowPrediction::predictions
 A vector containing Predictions for the window. More...
 
cv::Rect dg::deepcore::classification::WindowPrediction::window
 A window that is the active region for this set of Predictions. More...
 

Typedef Documentation

using dg::deepcore::classification::CaffeLayerIndexMap = typedef std::map<std::string, CaffeLayerIndex*>
typedef std::vector< std::string > dg::deepcore::classification::Labels

A collection of string labels to be used for the classes identified in a model.

Defines a CaffeModelMetadata as MetadataType.

Enumeration Type Documentation

A list of the color modes that are supported in a model.

Enumerator
UNKNOWN 
GRAYSCALE 
RGB 
MULTIBAND 

The type of filtering to perform.

Enumerator
Include 

Include, or retain, listed labels.

Exclude 

Exclude, or remove, listed labels.

Function Documentation

dg::deepcore::classification::GbdxModelReader::GbdxModelReader ( std::istream &  is)

Constructs a gbdxm model reader from an input stream.

Parameters
[in,out]isThe input stream to read the model from. GbdxModelReader does not take ownership of this object, so lifetime must be longer than the reader's lifetime.
dg::deepcore::classification::GbdxModelReader::GbdxModelReader ( const std::vector< uint8_t > &  buf)

Constructs a gbdxm model reader from a vector.

Parameters
[in]bufThe input vector to read the model from. GbdxModelReader does not take ownership of this object, so lifetime must be longer than the reader's lifetime.
dg::deepcore::classification::GbdxModelReader::GbdxModelReader ( const uint8_t *  buf,
size_t  size 
)

Constructs a gbdxm model reader from a memory buffer.

Parameters
[in]bufThe input buffer to read the model from. GbdxModelReader does not take ownership of this object, so lifetime must be longer than the reader's lifetime.
[in]sizeSize of the buffer
dg::deepcore::classification::GbdxModelReader::GbdxModelReader ( const std::string &  fileName)

Constructs a gbdxm model reader from a file.

Parameters
[in]fileNameThe input file path to read the model from.
dg::deepcore::classification::GbdxModelWriter::GbdxModelWriter ( std::ostream &  os,
const ModelPackage model,
bool  encrypt = true 
)

Constructs a GbdxModelWriter to write to the given output stream.

Parameters
[in,out]osThe output stream to write to. The stream lifetime must be greater than the writer's lifetime.
[in]modelThe model to serialize. The model object's lifetime must be greater than the writer's lifetime.
[in]encryptWhether to encrypt the model.
dg::deepcore::classification::GbdxModelWriter::GbdxModelWriter ( const std::string &  fileName,
const ModelPackage model,
bool  encrypt = true 
)

Constructs a GbdxModelWriter to write to a file on disk.

Parameters
[in]fileNamePath to the output file. Must be in a writable location.
[in]modelThe model to serialize. The model object's lifetime must be greater than the writer's lifetime.
[in]encryptWhether to encrypt the model.
dg::deepcore::classification::ModelMetadata::ModelMetadata ( )

Default constructor.

template<typename T>
dg::deepcore::classification::ModelMetadataT< T >::ModelMetadataT ( const T &  rhs)

Copy Constructor for ModelMetadataT.

Parameters
[in]rhsA ModelMetadataT to be copied.
template<typename T>
dg::deepcore::classification::ModelMetadataT< T >::ModelMetadataT ( T &&  rhs)

Move constructor for ModelMetadataT.

Parameters
[in]rhsA T to be moved.
template<typename T>
dg::deepcore::classification::ModelPackageT< T >::ModelPackageT ( const T &  rhs)

Copy constructor for the ModelPackageT.

template<typename T>
dg::deepcore::classification::ModelPackageT< T >::ModelPackageT ( T &&  rhs)

Move constructor for the ModelPackageT.

dg::deepcore::classification::Prediction::Prediction ( )

Default Constructor for Prediction.

dg::deepcore::classification::Prediction::Prediction ( const std::string &  label,
float  confidence = 0.0 
)

Constructor for Prediction.

Parameters
[in]labelA string value for the class in the model for this Prediction.
[in]confidenceA double value that is the minimum threshold value for this Prediction. Defaults to 0.
dg::deepcore::classification::WindowPrediction::WindowPrediction ( )

Default constructor for WindowPrediction.

dg::deepcore::classification::WindowPrediction::WindowPrediction ( const std::vector< Prediction > &  predictions,
const cv::Rect &  window 
)

A parameterized constructor for WindowPrediction.

Parameters
[in]predictionsA vector of Predictions associated with this WindowPrediction
[in]windowThe window for all predictions in this WindowPrediction
dg::deepcore::classification::WindowPrediction::WindowPrediction ( std::vector< Prediction > &&  predictions,
cv::Rect &&  window 
)

A move constructor for WindowPrediction.

void dg::deepcore::classification::GbdxModelWriter::addFile ( const std::string &  itemName,
const std::string &  fileName 
)

Adds a file to the archive from a file on disk.

Parameters
[in]itemNameThe item name to write. Must correspond to ModelPackage::itemNames(), no duplicates are allowed.
[in]fileNameThe path to the file to get the data from.
void dg::deepcore::classification::GbdxModelWriter::addFile ( const std::string &  itemName,
std::istream &  is 
)

Adds a file to the archive from an input stream.

Parameters
[in]itemNameThe item name to write. Must correspond to ModelPackage::itemNames(), no duplicates are allowed.
[in,out]isThe input stream to read the data from.
void dg::deepcore::classification::GbdxModelWriter::addFile ( const std::string &  itemName,
const std::vector< uint8_t > &  buf 
)

Adds a file to the archive from a vector.

Parameters
[in]itemNameThe item name to write. Must correspond to ModelPackage::itemNames(), no duplicates are allowed.
[in]bufThe vector to read the data from.
void dg::deepcore::classification::GbdxModelWriter::addFile ( const std::string &  itemName,
const uint8_t *  buf,
size_t  size 
)

Adds a file to the archive from a memory buffer.

Parameters
[in]itemNameThe item name to write. Must correspond to ModelPackage::itemNames(), no duplicates are allowed.
[in]bufThe buffer to read the data from.
[in]sizeSize of the input buffer.
void dg::deepcore::classification::GbdxModelWriter::addFileFromString ( const std::string &  itemName,
const std::string &  buf 
)

Adds a file to the archive from a string.

Parameters
[in]itemNameThe item name to write. Must correspond to ModelPackage::itemNames(), no duplicates are allowed.
[in]bufThe string to read the data from.
const cv::Rect2d & dg::deepcore::classification::ModelMetadata::boundingBox ( ) const
noexcept

Gets the bounding box (lat/lon).

Returns
A const reference to the bounding box.
cv::Rect2d & dg::deepcore::classification::ModelMetadata::boundingBox ( )
noexcept

Gets the bounding box (lat/lon).

Returns
A reference to the bounding box.
void dg::deepcore::classification::GbdxModelWriter::close ( )

Closes the writer. The object is unusable after it's closed.

ModelMetadata::ColorMode dg::deepcore::classification::ModelMetadata::colorMode ( ) const
noexcept

Gets the color mode.

Returns
The color mode.
virtual ModelMetadata* dg::deepcore::classification::ModelMetadata::copy ( ) const
pure virtual

Creates a copy of this object.

Returns
A pointer to the copy of this object. Caller takes ownership of the pointer.
Note
ModelMetadata implementations should generally not define this, but override ModelMetadata::operator= and inherit from the ModelMetadataT template instead.

Implemented in dg::deepcore::classification::ModelMetadataT< T >, and dg::deepcore::classification::ModelMetadataT< CaffeModelMetadata >.

template<typename T>
virtual ModelMetadata* dg::deepcore::classification::ModelMetadataT< T >::copy ( ) const
overridevirtual

Method to copy the ModelMetadata.

Returns
a pointer to the ModelMetadata copied.

Implements dg::deepcore::classification::ModelMetadata.

ModelPackage * dg::deepcore::classification::ModelPackage::create ( ModelMetadata metadata)
static

Create a ModelMetada instance based on given metadata.

Parameters
[in]metadataThe model metadata. ModelPackage takes ownership of the pointer.
ModelPackage * dg::deepcore::classification::ModelPackage::create ( const ModelMetadata metadata)
static

Create a ModelMetada instance based on given metadata.

Parameters
[in]metadataThe model metadata.
ModelPackage * dg::deepcore::classification::ModelPackage::create ( const char *  type)
static

Create a ModelMetadata instance based on type with metadata initialized to default values.

Parameters
[in]typeType of ModelMetadata to create.
ModelMetadata * dg::deepcore::classification::ModelMetadata::create ( const char *  type)
static

A factory function that creates metadata based on type.

Parameters
[in]typeThe type of model metadata to create.
Returns
A new instance of the appropriate ModelMetadata.
const string & dg::deepcore::classification::ModelMetadata::description ( ) const
noexcept

Gets the model descriptions.

Returns
The model description.
const std::vector< std::string > dg::deepcore::classification::CaffeModelMetadataJson::fieldNames ( )
static

Gets the metadata field names specific to Caffe model type.

Returns
A list of field names specific to Caffe model type. Currently returns an empty list.
std::vector< std::string > dg::deepcore::classification::ModelMetadataJson::fieldNames ( const std::string &  type)
static

Gets the metadata field names for the given model type.

Returns
A list of field names for the given model type.
const std::map< std::string, std::string > dg::deepcore::classification::CaffeModelMetadataJson::fieldToOption ( )
static

Gets the metadata field names specific to Caffe model type.

Returns
A list of CLI Options specific to Caffe model type. Currently returns an empty map.
std::map< std::string, std::string > dg::deepcore::classification::ModelMetadataJson::fieldToOption ( const std::string &  type)
static

Creates a map that is used for conversion of fieldName->CLIOptions.

Returns
returns a map with the correlation between fieldNames and CLI Options.
std::vector< WindowPrediction > dg::deepcore::classification::filterLabels ( const std::vector< WindowPrediction > &  windowPredictions,
FilterType  type,
const std::set< std::string > &  labels 
)

Run category filtering to remove unwanted or retain only wanted categories.

Parameters
[in]windowPredictionsThe list of prediction windows.
[in]typeThe type of filtering to perform
[in]labelsA set of labels that will be removed or retained from the input
Returns
Return the filtered list of prediction windows after category filtering has been applied.
ModelMetadata * dg::deepcore::classification::ModelMetadataJson::fromJson ( const Json::Value &  root)
static

Convert JSON to ModelMetada.

Parameters
[in]rootThe root of the JSON structure containing the model metadata.
Returns
The model metadata. Caller takes ownership of the pointer.
void dg::deepcore::classification::ModelMetadataJson::fromJsonBase ( const Json::Value &  root,
ModelMetadata metadata,
std::vector< std::string > &  missingFields 
)
protected

Read common metadata from JSON. Must be called from all ModelMetadata::fromJsonInternal implementations.

Parameters
[in]rootThe root of the JSON structure containing the model metadata.
[in,out]metadataThe metadata to fill in.
[out]missingFieldsA list of fields missing from the JSON file.
ModelMetadata * dg::deepcore::classification::ModelMetadataJson::fromJsonPartial ( const Json::Value &  root,
std::vector< std::string > &  missingFields 
)
static

Convert JSON to ModelMetada, not requiring all metadata to be there, but listing the missing fields instead.

Parameters
[in]rootThe root of the JSON structure containing the model metadata.
[out]missingFieldsList of metadata fields that were missing from JSON.
Returns
The model metadata. Caller takes ownership of the pointer.
bool dg::deepcore::classification::ModelPackage::haveItem ( const std::string &  itemName) const

Returns whether an item already exists in the model.

Parameters
[in]itemNameName of the item.
Returns
True if the item exists in the model, false otherwise.
const string & dg::deepcore::classification::ModelMetadata::imageType ( ) const
noexcept

Gets the image type.

Returns
The image type.
const std::vector< uint8_t > & dg::deepcore::classification::ModelPackage::item ( const std::string &  itemName) const

Get a model item.

Parameters
[in]itemNameName of the item.
Returns
A const reference to the item.
std::vector< uint8_t > & dg::deepcore::classification::ModelPackage::item ( const std::string &  itemName)

Get a model item.

Parameters
[in]itemNameName of the item.
Returns
A reference to the item.
virtual const Labels& dg::deepcore::classification::ModelPackage::itemNames ( ) const
pure virtualnoexcept

Gets the list of allowed item names for this model.

Returns
The item names.

Implemented in dg::deepcore::classification::ModelPackageT< T >, and dg::deepcore::classification::ModelPackageT< CaffeModelPackage >.

template<typename T>
const std::vector<std::string>& dg::deepcore::classification::ModelPackageT< T >::itemNames ( ) const
overridevirtualnoexcept

A method that returns all of the item names inside the ModelPackageT.

Implements dg::deepcore::classification::ModelPackage.

const Labels & dg::deepcore::classification::ModelMetadata::labels ( ) const
noexcept

Gets the model labels.

Returns
A const reference to the model labels.
Labels & dg::deepcore::classification::ModelMetadata::labels ( )
noexcept

Gets the model labels.

Returns
A reference to the model labels.
const vector< uint8_t > & dg::deepcore::classification::CaffeModelPackage::mean ( ) const

Returns the mean data.

Returns
A const reference to the mean data.
vector< uint8_t > & dg::deepcore::classification::CaffeModelPackage::mean ( )

Returns the mean data.

Returns
A reference to the mean data.
const ModelMetadata & dg::deepcore::classification::ModelPackage::metadata ( ) const

Gets the metadata.

Returns
A const reference to metadata.
ModelMetadata & dg::deepcore::classification::ModelPackage::metadata ( )

Gets the metadata.

Returns
A reference to metadata.
virtual const std::vector<std::string>& dg::deepcore::classification::ModelPackage::metadataItemNames ( ) const
pure virtualnoexcept

Gets the list of metadata items that are guaranteed to be retrieved from model items. Other metadata items can be retrieved, but the ones returned by this methods must always be retrived.

Implemented in dg::deepcore::classification::ModelPackageT< T >, and dg::deepcore::classification::ModelPackageT< CaffeModelPackage >.

template<typename T>
const std::vector<std::string>& dg::deepcore::classification::ModelPackageT< T >::metadataItemNames ( ) const
overridevirtualnoexcept

A method that returns all of the names for the items in the ModelPackageT metadata.

Implements dg::deepcore::classification::ModelPackage.

const vector< uint8_t > & dg::deepcore::classification::CaffeModelPackage::model ( ) const

Gets the model data.

Returns
A const reference to the model data.
vector< uint8_t > & dg::deepcore::classification::CaffeModelPackage::model ( )

Gets the model data.

Returns
A reference to the model data.
virtual const std::vector<std::string>& dg::deepcore::classification::ModelPackage::modelMetadataItemNames ( ) const
pure virtualnoexcept

Gets the list of items that can contain model metadata and can be read by ModelPackage::readMetadataFromItem.

Returns
A list of model items that can contain model metadata.

Implemented in dg::deepcore::classification::ModelPackageT< T >, and dg::deepcore::classification::ModelPackageT< CaffeModelPackage >.

template<typename T>
const std::vector<std::string>& dg::deepcore::classification::ModelPackageT< T >::modelMetadataItemNames ( ) const
overridevirtualnoexcept

A method that returns all of the item names for the model metadata inside the ModelPackageT.

Implements dg::deepcore::classification::ModelPackage.

const cv::Size & dg::deepcore::classification::ModelMetadata::modelSize ( ) const
noexcept

Gets the model size.

Returns
A const reference to model size.
cv::Size & dg::deepcore::classification::ModelMetadata::modelSize ( )
noexcept

Gets the model size.

Returns
A reference to model size.
const string & dg::deepcore::classification::ModelMetadata::name ( ) const
noexcept

Gets the model name.

Returns
Model name.
vector< WindowPrediction > dg::deepcore::classification::nonMaxSuppression ( const vector< WindowPrediction > &  windowPredictions,
float  overlapThreshold 
)

Run Non-Maximum Suppression (NMS) to remove overlapping prediction windows.

Parameters
[in]windowPredictionsThe list of prediction windows.
[in]overlapThresholdUsed to maintain overlapping prediction windows that contain detected objects.
Returns
Return the filtered list of prediction windows after NMS has been applied.
formatting_ostream& dg::deepcore::classification::operator<< ( formatting_ostream &  os,
const ModelMetadata::ColorMode &  mode 
)

Allows logging a ModelMetadata::ColorMode with DG_LOG.

Parameters
[in,out]osThe stream to write to.
[in]modeThe color mode.
Returns
A reference to the input stream.
ModelPackage & dg::deepcore::classification::ModelPackage::operator= ( const ModelPackage rhs)
virtual

The copy operator. Can be overridden if additional state needs to be copied.

Parameters
[in]rhsThe ModelPackage to copy the object state from.
ModelPackage & dg::deepcore::classification::ModelPackage::operator= ( ModelPackage &&  rhs)
virtual

The move operator. Can be overridden if additional state needs to be moved.

Parameters
[in]rhsThe ModelPackage to copy the object state from.
ModelMetadata & dg::deepcore::classification::ModelMetadata::operator= ( const ModelMetadata rhs)
virtual

The copy operator. Can be overridden if additional state needs to be copied.

Parameters
[in]rhsThe ModelPackage to copy the object state from.
ModelMetadata & dg::deepcore::classification::ModelMetadata::operator= ( ModelMetadata &&  rhs)
virtual

The move operator. Can be overridden if additional state needs to be copied.

Parameters
[in]rhsThe ModelPackage to move the object state from.
vector< string > dg::deepcore::classification::ModelPackage::readMetadataFromItem ( const std::string &  itemName) const

Gets the metadata from a specified item name.

Read metadata from internal item data.

Parameters
[in]itemNamethe name of the item from which metadata will be read.
Returns
A vector of strings that are the metadata of the named item.
Parameters
[in]itemNameName of the item to read from.
Returns
A list of metadata items read.
virtual std::vector<std::string> dg::deepcore::classification::ModelPackage::readMetadataFromItem ( const std::string &  itemName,
const std::vector< uint8_t > &  itemData 
) const
pure virtual

Read metadata from the given item data.

Parameters
[in]itemNameName of the item to read from.
[in]itemDataItem data to read from.
Returns
A list of metadata items read.

Implemented in dg::deepcore::classification::CaffeModelPackage.

ModelPackage * dg::deepcore::classification::GbdxModelReader::readModel ( )

Read the model.

Returns
The extracted model. Caller takes ownership of the object.
ModelPackage * dg::deepcore::classification::GbdxModelReader::readModel ( std::map< std::string, std::string > &  outContentsMap)

Read the model and return the original contents map.

Returns
The extracted model. Caller takes ownership of the object.
void dg::deepcore::classification::ModelMetadata::setBoundingBox ( const cv::Rect2d &  boundingBox)
noexcept

Sets the bounding box (lat/lon).

Parameters
[in]boundingBoxThe bounding box.
void dg::deepcore::classification::ModelMetadata::setColorMode ( ColorMode  colorMode)
noexcept

Sets the color mode.

Parameters
[in]colorModeThe color mode.
void dg::deepcore::classification::ModelMetadata::setDescription ( const std::string &  description)
noexcept

Sets the model description.

Returns
The model description.
void dg::deepcore::classification::ModelMetadata::setImageType ( const std::string &  imageType)
noexcept

Sets the image type.

Parameters
[in]imageTypeThe image type.
void dg::deepcore::classification::ModelPackage::setItem ( const std::string &  itemName,
const std::vector< uint8_t > &  item 
)

Sets a model item.

Parameters
[in]itemNameName of the item, must be in the list returned by ModelPackage::itemNames().
[in]itemThe item.
void dg::deepcore::classification::ModelPackage::setItem ( const std::string &  itemName,
std::vector< uint8_t > &&  item 
)

Sets a model item.

Parameters
[in]itemNameName of the item, must be in the list returned by ModelPackage::itemNames().
[in,out]itemThe item.
void dg::deepcore::classification::ModelMetadata::setLabels ( const Labels labels)
noexcept

Sets the model labels.

Parameters
[in]labelsThe model labels.
void dg::deepcore::classification::ModelMetadata::setLabels ( Labels &&  labels)
noexcept

Sets the model labels.

Parameters
[in,out]labelsThe model labels.
void dg::deepcore::classification::ModelPackage::setMetadata ( const ModelMetadata metadata)
noexcept

Sets the metadata.

Parameters
[in]metadataThe metadata.
void dg::deepcore::classification::ModelPackage::setMetadata ( ModelMetadata metadata)

Sets the metadata.

Parameters
[in]metadataA pointer to the metadata. ModelPackage takes ownership of the pointer.
void dg::deepcore::classification::ModelMetadata::setModelSize ( const cv::Size &  modelSize)
noexcept

Sets the model size.

Parameters
[in]modelSizeThe model size.
const void dg::deepcore::classification::ModelMetadata::setName ( const std::string &  name)
noexcept

Sets the model name.

Parameters
[in]nameThe model name.
void dg::deepcore::classification::ModelMetadata::setSize ( int64_t  size)
noexcept

Sets the total serialized uncompressed model package size.

Parameters
[in]sizeThe model package size, -1 if unknown.
void dg::deepcore::classification::ModelMetadata::setTimeCreated ( time_t  timeCreated)
noexcept

Sets the model creation date/time.

Parameters
[in]timeCreatedThe model creation date/time.
void dg::deepcore::classification::ModelMetadata::setVersion ( const std::string &  version)
noexcept

Sets the model version.

Returns
The model version.
int64_t dg::deepcore::classification::ModelMetadata::size ( ) const
noexcept

Gets the total serialized uncompressed model package size.

Returns
The model package size, -1 if unknown.
time_t dg::deepcore::classification::ModelMetadata::timeCreated ( ) const
noexcept

Gets the model creation date/time.

Returns
The model creation date/time.
Json::Value dg::deepcore::classification::ModelMetadataJson::toJson ( const ModelMetadata metadata)
static

Convert the given model metadata to JSON.

Parameters
metadataThe model metadata.
Returns
The Json::Value representing the metadata JSON root.
Json::Value dg::deepcore::classification::ModelMetadataJson::toJsonBase ( const ModelMetadata metadata)
protected

Convert common model metadata to JSON. Must be called from all ModelMetadata::toJsonInternal implementations.

Parameters
[in]metadataThe model metadata.
const vector< uint8_t > & dg::deepcore::classification::CaffeModelPackage::trained ( ) const

Gets the trained data.

Returns
A const reference to the trained data.
vector< uint8_t > & dg::deepcore::classification::CaffeModelPackage::trained ( )

Gets the trained data.

Returns
A reference to the trained data.
const char * dg::deepcore::classification::CaffeModelMetadata::type ( ) const
overridevirtualnoexcept

The type of model found in this metadata.

Implements dg::deepcore::classification::ModelMetadata.

virtual const char* dg::deepcore::classification::ModelPackage::type ( ) const
pure virtualnoexcept

Gets the identifier for the model type.

Returns
The model type.

Implemented in dg::deepcore::classification::CaffeModelPackage.

virtual const char* dg::deepcore::classification::ModelMetadata::type ( ) const
pure virtualnoexcept

Get the identifier for the model type.

Returns
The model type.

Implemented in dg::deepcore::classification::CaffeModelMetadata.

const string & dg::deepcore::classification::ModelMetadata::version ( ) const
noexcept

Gets the model version.

Returns
The model version.
void dg::deepcore::classification::GbdxModelWriter::writeMetadata ( const std::map< std::string, std::string > &  contentMap)

Writes the model metadata. Metadata must be written before any more files are written to the package.

Parameters
[in]contentMapMapping between item names and file names inside the archive. Keys of this map must correspond to ModelPackage::itemNames().
void dg::deepcore::classification::GbdxModelWriter::writeModel ( const std::map< std::string, std::string > &  contentMap)

Writes out the model contained in the ModelPackage.

Parameters
[in]contentMapMapping between item names and file names inside the archive. Keys of this map must correspond to ModelPackage::itemNames().

Variable Documentation

float dg::deepcore::classification::Prediction::confidence

A float value that is the minimum threshold value for this Prediction.

const vector< string > dg::deepcore::classification::CaffeModelPackage::ITEM_NAMES
static

A collection of strings that names that will be found in this package.

std::string dg::deepcore::classification::Prediction::label

A string label that is the display name of the class in the model for this Prediction.

const vector< string > dg::deepcore::classification::CaffeModelPackage::METADATA_ITEM_NAMES
static

A collection of strings that are metadata item names for the items in the package.

const vector< string > dg::deepcore::classification::CaffeModelPackage::MODEL_METADATA_ITEM_NAMES
static

A collection of names of items found in the model.

std::vector<Prediction> dg::deepcore::classification::WindowPrediction::predictions

A vector containing Predictions for the window.

cv::Rect dg::deepcore::classification::WindowPrediction::window

A window that is the active region for this set of Predictions.