MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MyCaffe.basecode.Datum Class Reference

The Datum class is a simple wrapper to the SimpleDatum class to ensure compatibility with the original C++ Caffe code. More...

Inheritance diagram for MyCaffe.basecode.Datum:
MyCaffe.basecode.SimpleDatum

Public Member Functions

 Datum ()
 The Datum constructor. More...
 
 Datum (bool bIsReal, int nChannels, int nWidth, int nHeight, int nLabel=-1, DateTime? dtTime=null, int nBoost=0, bool bAutoLabeled=false, int nIdx=-1)
 The Datum constructor. More...
 
 Datum (bool bIsReal, int nChannels, int nWidth, int nHeight, int nLabel, DateTime dtTime, List< byte > rgData, int nBoost, bool bAutoLabeled, int nIdx)
 The Datum constructor. More...
 
 Datum (bool bIsReal, int nChannels, int nWidth, int nHeight, int nLabel, DateTime dtTime, List< double > rgfData, int nBoost, bool bAutoLabeled, int nIdx)
 The Datum constructor. More...
 
 Datum (bool bIsReal, int nChannels, int nWidth, int nHeight, int nLabel, DateTime dtTime, List< float > rgfData, int nBoost, bool bAutoLabeled, int nIdx)
 The Datum constructor. More...
 
 Datum (SimpleDatum d, bool bCopyData=false)
 The Datum constructor. More...
 
 Datum (Datum d, bool bCopyData=false)
 The Datum constructor. More...
 
- Public Member Functions inherited from MyCaffe.basecode.SimpleDatum
 SimpleDatum ()
 The SimpleDatum constructor. More...
 
 SimpleDatum (bool bIsReal, int nChannels, int nWidth, int nHeight, int nLabel=-1, DateTime? dtTime=null, int nBoost=0, bool bAutoLabeled=false, int nIdx=-1, int nVirtualID=0, int nImageID=0, int nSourceID=0, int nOriginalSourceID=0)
 The SimpleDatum constructor. More...
 
 SimpleDatum (bool bIsReal, int nChannels, int nWidth, int nHeight, int nLabel, DateTime dtTime, List< byte > rgData, int nBoost, bool bAutoLabeled, int nIdx, int nVirtualID=0, int nImageID=0, int nSourceID=0, int nOriginalSourceID=0)
 The SimpleDatum constructor. More...
 
 SimpleDatum (bool bIsReal, int nChannels, int nWidth, int nHeight, int nLabel, DateTime dtTime, List< double > rgfData, int nBoost, bool bAutoLabeled, int nIdx, int nVirtualID=0, int nImageID=0, int nSourceID=0, int nOriginalSourceID=0)
 The SimpleDatum constructor. More...
 
 SimpleDatum (bool bIsReal, int nChannels, int nWidth, int nHeight, int nLabel, DateTime dtTime, List< float > rgfData, int nBoost, bool bAutoLabeled, int nIdx, int nVirtualID=0, int nImageID=0, int nSourceID=0, int nOriginalSourceID=0)
 The SimpleDatum constructor. More...
 
 SimpleDatum (bool bIsReal, int nChannels, int nWidth, int nHeight, int nLabel, DateTime dtTime, byte[] rgData, int nBoost, bool bAutoLabeled, int nIdx, int nVirtualID=0, int nImageID=0, int nSourceID=0, int nOriginalSourceID=0)
 The SimpleDatum constructor. More...
 
 SimpleDatum (bool bIsReal, int nChannels, int nWidth, int nHeight, int nLabel, DateTime dtTime, double[] rgdfData, int nBoost, bool bAutoLabeled, int nIdx, int nVirtualID=0, int nImageID=0, int nSourceID=0, int nOriginalSourceID=0)
 The SimpleDatum constructor. More...
 
 SimpleDatum (bool bIsReal, int nChannels, int nWidth, int nHeight, int nLabel, DateTime dtTime, float[] rgfData, int nBoost, bool bAutoLabeled, int nIdx, int nVirtualID=0, int nImageID=0, int nSourceID=0, int nOriginalSourceID=0)
 The SimpleDatum constructor. More...
 
 SimpleDatum (bool bIsReal, int nChannels, int nWidth, int nHeight, int nLabel, DateTime dtTime, int nBoost=0, bool bAutoLabeled=false, int nIdx=-1, int nVirtualID=0, int nImageID=0, int nSourceID=0, int nOriginalSourceID=0)
 The SimpleDatum constructor. More...
 
 SimpleDatum (int nChannels, int nWidth, int nHeight, float[] rgf, int nOffset, int nCount, bool bDataIsReal=true)
 The SimpleDatum constructor. More...
 
 SimpleDatum (int nChannels, int nWidth, int nHeight)
 The SimpleDatum constructor. More...
 
 SimpleDatum (Bytemap data)
 The SimpleDatum constructor. More...
 
 SimpleDatum (Valuemap data)
 The SimpleDatum constructor. More...
 
 SimpleDatum (SimpleDatum d, bool bCopyData=false)
 The SimpleDatum constructor. More...
 
 SimpleDatum (SimpleDatum d, int nHeight, int nWidth)
 The SimpleDatum constructor. More...
 
 SimpleDatum (List< SimpleDatum > rg, bool bAlignChannels)
 Constructor that copies an array into a single SimpleDatum by appending each to the other in order. More...
 
void Clip (int nDataLen, int? nNewChannel, int? nNewHeight, int? nNewWidth)
 Clip the data length down to a smaller size and copies the clipped data. More...
 
List< int > GetNonZeroIndexes ()
 Returns all indexes with non-zero data. More...
 
void Zero ()
 Zero out all data in the datum but keep the size and other settings. More...
 
bool Sub (SimpleDatum sd, bool bSetNegativeToZero=false)
 Subtract the data of another SimpleDatum from this one, so this = this - sd. More...
 
bool SubAbs (SimpleDatum sd)
 Subtract the data of another SimpleDatum from this one, and take the absolute value, so this = Math.Abs(this - sd). More...
 
void Scale (double dfScale, double dfMin=-double.MaxValue, double dfMax=double.MaxValue)
 Scale the values by the scaling factor. More...
 
void ScalePow (double dfScalePow, double dfMin=-double.MaxValue, double dfMax=double.MaxValue)
 Scale the values by the scaling factor that raises each value by the specified power. More...
 
void Copy (SimpleDatum d, bool bCopyData, int? nHeight=null, int? nWidth=null)
 Copy another SimpleDatum into this one. More...
 
void CopyData (SimpleDatum d)
 Copy just the data from another SimpleDatum, making sure to update the C x H x W dimensions and IsReal settings to fit the new data. More...
 
void SetData (SimpleDatum d)
 Set the data of the current SimpleDatum by copying the data of another. More...
 
bool GetDataValid (bool bByType=true)
 Returns true if the ByteData or RealDataD or RealDataF are not null, false otherwise. More...
 
List< T > ClipToLastColumnsX< T > (int nLastColumns=10)
 DEPRECIATED: Clips the SimpleDatum to the last nLastColumns and returns the data. More...
 
void MaskOutAllButLastColumnsX (int nLastColumsToRetain, int nMaskingValue)
 DEPRECIATED: Masks out all data except for the last columns of data. More...
 
void SetData (List< byte > rgByteData, int nLabel, bool bAllowVirtualOverride=false)
 Sets the byte data of the SimpleDatum and its Label. More...
 
void SetData (List< double > rgRealData, int nLabel, bool bAllowVirtualOverride=false)
 Sets the double data of the SimpleDatum and its Label. More...
 
void SetData (List< float > rgRealData, int nLabel, bool bAllowVirtualOverride=false)
 Sets the float data of the SimpleDatum and its Label. More...
 
void SetData (byte[] rgb, int nLabel)
 Set the data to the byte array specified. More...
 
void SetData (double[] rgdf, int nLabel)
 Set the data to the double array specified. More...
 
void SetData (float[] rgf, int nLabel)
 Set the data to the float array specified. More...
 
void SetLabel (int nLabel)
 Sets the label. More...
 
void ResetLabel ()
 Resets the label to the original label used when creating the SimpleDatum. More...
 
GetDataAt< T > (int nIdx)
 Returns the item at a specified index in the type specified. More...
 
double GetDataAtD (int nIdx)
 Returns the item at a specified index in the double type. More...
 
float GetDataAtF (int nIdx)
 Returns the item at a specified index in the float type. More...
 
byte GetDataAtByte (int nIdx)
 Returns the item at a specified index in the byte type. More...
 
T[] GetData< T > (int nImagePadX=0, int nImagePadY=0)
 Returns the data as a generic array and optionally pads the data. More...
 
byte[] GetByteData (out bool bEncoded)
 Returns the data as a byte array regardless of how it is stored. More...
 
SimpleDatum Add (SimpleDatum d)
 Creates a new SimpleDatum and adds another SimpleDatum to it. More...
 
SimpleDatum Div (double dfVal, bool bConvertToByte)
 Divides all elements of the SimpleDatum by a value and returns the result as a new SimpleDatum. More...
 
void SetImageID (int nID)
 Set the image ID. More...
 
void ResetBoost ()
 Reset the boost to the original boost. More...
 
SimpleDatum Resize (int nH, int nW)
 Resize the data and return it as a new SimpleDatum. More...
 
override string ToString ()
 Return a string representation of the SimpleDatum. More...
 
string ToArrayAsString (int nMaxItems)
 Returns a string containing the items of the SimpleDatum. More...
 
Bytemap ToBytemap ()
 Return the SimpleData data as a Bytemap. More...
 
void SaveAnnotationDataToDataCriteria ()
 Save the annotation data and type to the data criteria. More...
 
bool LoadAnnotationDataFromDataCriteria ()
 Load the annotation data and type from the data criteria. More...
 
void SaveInfo (string strFile)
 Save the SimpleDatum information to a text file. More...
 

Properties

int channels [get]
 Returns the number of channels in the data. More...
 
int height [get]
 Specifies the height of the data. More...
 
int width [get]
 Specifies the width of the data. More...
 
int index [get]
 Specifies the index of the data. More...
 
float[] float_data [get]
 Returns the data as an array of float. The datum must be initialized with bIsReal = true with float data. More...
 
double[] double_data [get]
 Returns the data as an array of double. The datum must be initialized with bIsReal = true with double data. More...
 
byte[] data [get]
 Returns the non-real data as an array of bytes. The datum must be initialized with bIsReal = false. More...
 
int label [get]
 Returns the known label of the data. More...
 
- Properties inherited from MyCaffe.basecode.SimpleDatum
int HitCount [getset]
 Get/set the hit count for the SimpleDatum. More...
 
object Tag [getset]
 Specifies user data associated with the SimpleDatum. More...
 
string TagName [getset]
 Returns a user-defined name of the tag associated with the data. More...
 
double Min [get]
 Returns the minimum value in the data or double.NaN if there is no data. More...
 
double Max [get]
 Returns the maximum value in the data or double.NaN if there is no data. More...
 
int ItemCount [get]
 Returns the number of data items. More...
 
bool HasRealData [get]
 Returns true if either the RealDataD or RealDataF are non null and have length > 0. More...
 
int SourceID [get]
 Returns the ID of the data source that owns this image. More...
 
int OriginalSourceID [get]
 Returns the original source ID which is set when using a virtual ID. More...
 
int ImageID [get]
 Returns the ID of the image in the database. More...
 
int VirtualID [get]
 Returns the virtual ID of the SimpleDatum. More...
 
int GroupID [getset]
 Get/set the group ID of the SimpleDatum. More...
 
int Index [getset]
 Returns the index of the SimpleDatum. More...
 
DateTime TimeStamp [getset]
 Get/set the Timestamp. More...
 
bool AutoLabeled [getset]
 Get/set whether or not the label was auto generated. More...
 
bool IsRealData [get]
 Returns whether or not the data contains real numbers or byte data. More...
 
int Height [get]
 Return the height of the data. More...
 
int Width [get]
 Return the width of the data. More...
 
int Channels [get]
 Return the number of channels of the data. More...
 
int Label [get]
 Return the known label of the data. More...
 
int OriginalLabel [getset]
 Get/set the original known label of the data. More...
 
byte[] ByteData [get]
 Return the byte data. This field is valid when IsRealData = false. More...
 
double[] RealDataD [get]
 Return the double data. This field is valid when IsRealData = true. More...
 
float[] RealDataF [get]
 Return the float data. This field is valid when IsRealData = true. More...
 
int Boost [getset]
 Get/set the boost for this data. More...
 
DATA_FORMAT DataCriteriaFormat [getset]
 Get/set the data format of the data criteria. More...
 
byte[] DataCriteria [getset]
 Get/set data criteria associated with the data. More...
 
DATA_FORMAT DebugDataFormat [getset]
 Get/set the data format of the debug data. More...
 
byte[] DebugData [getset]
 Get/set debug data associated with the data. More...
 
string Description [getset]
 Get/set a description of the data. More...
 
ANNOTATION_TYPE annotation_type [getset]
 When using annotations, the annotation type specifies the type of annotation. Currently, only the BBOX annotation type is supported. More...
 
AnnotationGroupCollection annotation_group [getset]
 When using annoations, each annotation group contains an annotation for a particular class used with SSD. More...
 

Additional Inherited Members

- Public Types inherited from MyCaffe.basecode.SimpleDatum
enum  ANNOTATION_TYPE { NONE = -1 , BBOX = 0 }
 Specifies the annotation type when using annotations. More...
 
enum  DATA_FORMAT {
  NONE , IMAGE_1CH , IMAGE_3CH , SEGMENTATION ,
  DICTIONARY , CUSTOM , BITMAP , LIST_DOUBLE ,
  LIST_FLOAT , ANNOTATION_DATA
}
 Defines the data format of the DebugData and DataCriteria when specified. More...
 
- Static Public Member Functions inherited from MyCaffe.basecode.SimpleDatum
static byte[] GetByteData (byte[] rgData, int nImagePadX, int nImagePadY, int nHeight, int nWidth, int nChannels)
 Return the non-real data as a byte array after padding the data. More...
 
static Tuple< double[], float[]> GetRealData (byte[] rgData, int nImagePadX, int nImagePadY, int nHeight, int nWidth, int nChannels)
 Return the real data as a double or float array (depending on the original encoding data type) after padding the data. More...
 
static T[] PadData< T > (List< T > rgData, int nImagePadX, int nImagePadY, int nHeight, int nWidth, int nChannels)
 Padd the data. More...
 
static byte[] GetByteData (List< double > rgData)
 Encodes a list of double values to an encoded byte array. More...
 
static byte[] GetByteData (List< float > rgData)
 Encodes a list of float values to an encoded byte array. More...
 
static Tuple< double[], float[]> GetRealData (byte[] rgData)
 Decodes an array of byte values into a array of either double or float values depending on how the original encoding was made. More...
 
static bool AccumulateMean (ref double[] rgdfMean, SimpleDatum sd, int nTotal)
 Accumulate a portion of a SimpleDatum to calculate the mean value. More...
 
static SimpleDatum CalculateMean (Log log, SimpleDatum[] rgImg, WaitHandle[] rgAbort)
 Calculate the mean of an array of SimpleDatum and return the mean as a new SimpleDatum. More...
 
static byte[] SaveAnnotationDataToDataCriteriaByteArray (ANNOTATION_TYPE type, AnnotationGroupCollection annotations)
 Save the annotation data to a byte array. More...
 
static AnnotationGroupCollection LoadAnnotationDataFromDataCriteria (byte[] rg, DATA_FORMAT fmt, out ANNOTATION_TYPE type)
 Load the AnnotationGroups from the byte array. More...
 
static SimpleDatum LoadInfo (string strFile)
 Load a SimpleData from text file information previously saved with SaveInfo. More...
 
static List< SimpleDatumLoadFromPath (string strPath)
 Load all SimpleDatums from a directory of files previously stored with SaveInfo. More...
 
static float[] Transpose (float[] rg, int nH, int nW, int nDim=1)
 Transpose the data within a float array. More...
 
static double[] Transpose (double[] rg, int nH, int nW, int nDim=1)
 Transpose the data within a double array. More...
 
- Static Protected Member Functions inherited from MyCaffe.basecode.SimpleDatum
static double[] getRealDataD (byte[] rgData, int nIdx)
 Decodes an array of byte values into a array of double values. More...
 
static float[] getRealDataF (byte[] rgData, int nIdx)
 Decodes an array of byte values into a array of float values. More...
 
- Protected Attributes inherited from MyCaffe.basecode.SimpleDatum
object m_tag = null
 Specifies a user value. More...
 
string m_strTagName = null
 Specifies the name of the user value. More...
 

Detailed Description

The Datum class is a simple wrapper to the SimpleDatum class to ensure compatibility with the original C++ Caffe code.

Definition at line 11 of file Datum.cs.

Constructor & Destructor Documentation

◆ Datum() [1/7]

MyCaffe.basecode.Datum.Datum ( )

The Datum constructor.

Definition at line 16 of file Datum.cs.

◆ Datum() [2/7]

MyCaffe.basecode.Datum.Datum ( bool  bIsReal,
int  nChannels,
int  nWidth,
int  nHeight,
int  nLabel = -1,
DateTime?  dtTime = null,
int  nBoost = 0,
bool  bAutoLabeled = false,
int  nIdx = -1 
)

The Datum constructor.

Parameters
bIsRealSpecifies whether or not the data values are double or byte.
nChannelsSpecifies the number of channels in the data (e.g. 3 for color, 1 for black and white images)
nWidthSpecifies the width of the data (e.g. the number of pixels wide).
nHeightSpecifies the height of the data (e.g. the number of pixels high).
nLabelOptionally, specifies the known label of the data (default = -1).
dtTimeOptionally, specifies a time-stamp associated with the data (default = null).
nBoostOptionally, specifies the boost to use with the data (default = 0, where a value of 0 indicates no boost).
bAutoLabeledOptionally, specifies whether or not the label was auto-generated (default = false).
nIdxOptionally, specifies the index of the data (default = -1).

Definition at line 32 of file Datum.cs.

◆ Datum() [3/7]

MyCaffe.basecode.Datum.Datum ( bool  bIsReal,
int  nChannels,
int  nWidth,
int  nHeight,
int  nLabel,
DateTime  dtTime,
List< byte >  rgData,
int  nBoost,
bool  bAutoLabeled,
int  nIdx 
)

The Datum constructor.

Parameters
bIsRealSpecifies whether or not the data values are double or byte.
nChannelsSpecifies the number of channels in the data (e.g. 3 for color, 1 for black and white images)
nWidthSpecifies the width of the data (e.g. the number of pixels wide).
nHeightSpecifies the height of the data (e.g. the number of pixels high).
nLabelSpecifies the known label of the data.
dtTimeSpecifies a time-stamp associated with the data.
rgDataSpecifies the data as a list of bytes (expects bIsReal = false).
nBoostSpecifies the boost to use with the data (a value of 0 indicates no boost).
bAutoLabeledSpecifies whether or not the label was auto-generated.
nIdxSpecifies the index of the data.

Definition at line 50 of file Datum.cs.

◆ Datum() [4/7]

MyCaffe.basecode.Datum.Datum ( bool  bIsReal,
int  nChannels,
int  nWidth,
int  nHeight,
int  nLabel,
DateTime  dtTime,
List< double >  rgfData,
int  nBoost,
bool  bAutoLabeled,
int  nIdx 
)

The Datum constructor.

Parameters
bIsRealSpecifies whether or not the data values are double or byte.
nChannelsSpecifies the number of channels in the data (e.g. 3 for color, 1 for black and white images)
nWidthSpecifies the width of the data (e.g. the number of pixels wide).
nHeightSpecifies the height of the data (e.g. the number of pixels high).
nLabelSpecifies the known label of the data.
dtTimeSpecifies a time-stamp associated with the data.
rgfDataSpecifies the data as a list of double (expects bIsReal = true).
nBoostSpecifies the boost to use with the data (a value of 0 indicates no boost).
bAutoLabeledSpecifies whether or not the label was auto-generated.
nIdxSpecifies the index of the data.

Definition at line 68 of file Datum.cs.

◆ Datum() [5/7]

MyCaffe.basecode.Datum.Datum ( bool  bIsReal,
int  nChannels,
int  nWidth,
int  nHeight,
int  nLabel,
DateTime  dtTime,
List< float >  rgfData,
int  nBoost,
bool  bAutoLabeled,
int  nIdx 
)

The Datum constructor.

Parameters
bIsRealSpecifies whether or not the data values are double or byte.
nChannelsSpecifies the number of channels in the data (e.g. 3 for color, 1 for black and white images)
nWidthSpecifies the width of the data (e.g. the number of pixels wide).
nHeightSpecifies the height of the data (e.g. the number of pixels high).
nLabelSpecifies the known label of the data.
dtTimeSpecifies a time-stamp associated with the data.
rgfDataSpecifies the data as a list of float (expects bIsReal = true).
nBoostSpecifies the boost to use with the data (a value of 0 indicates no boost).
bAutoLabeledSpecifies whether or not the label was auto-generated.
nIdxSpecifies the index of the data.

Definition at line 86 of file Datum.cs.

◆ Datum() [6/7]

MyCaffe.basecode.Datum.Datum ( SimpleDatum  d,
bool  bCopyData = false 
)

The Datum constructor.

Parameters
dSpecifies a SimpleDatum used to create this new Datum.
bCopyDataSpecifies whether or not to copy the data, or just share it.

Definition at line 96 of file Datum.cs.

◆ Datum() [7/7]

MyCaffe.basecode.Datum.Datum ( Datum  d,
bool  bCopyData = false 
)

The Datum constructor.

Parameters
dSpecifies another Datum to copy when creating this Datum.
bCopyDataSpecifies whether or not to copy the data, or just share it.

Definition at line 106 of file Datum.cs.

Property Documentation

◆ channels

int MyCaffe.basecode.Datum.channels
get

Returns the number of channels in the data.

Definition at line 114 of file Datum.cs.

◆ data

byte [] MyCaffe.basecode.Datum.data
get

Returns the non-real data as an array of bytes. The datum must be initialized with bIsReal = false.

Definition at line 162 of file Datum.cs.

◆ double_data

double [] MyCaffe.basecode.Datum.double_data
get

Returns the data as an array of double. The datum must be initialized with bIsReal = true with double data.

Definition at line 154 of file Datum.cs.

◆ float_data

float [] MyCaffe.basecode.Datum.float_data
get

Returns the data as an array of float. The datum must be initialized with bIsReal = true with float data.

Definition at line 146 of file Datum.cs.

◆ height

int MyCaffe.basecode.Datum.height
get

Specifies the height of the data.

Definition at line 122 of file Datum.cs.

◆ index

int MyCaffe.basecode.Datum.index
get

Specifies the index of the data.

Definition at line 138 of file Datum.cs.

◆ label

int MyCaffe.basecode.Datum.label
get

Returns the known label of the data.

Definition at line 170 of file Datum.cs.

◆ width

int MyCaffe.basecode.Datum.width
get

Specifies the width of the data.

Definition at line 130 of file Datum.cs.


The documentation for this class was generated from the following file: