MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
SourceDescriptor.cs
1using System;
2using System.Collections.Generic;
4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
7
9{
13 [Serializable]
14 [TypeConverter(typeof(ExpandableObjectConverter))]
16 {
17 int m_nHt;
18 int m_nWd;
19 int m_nCh;
20 bool m_bIsRealData;
21 int m_nImageCount;
22 int m_nInactiveCount;
23 bool m_bSaveImagesToFile;
24 List<LabelDescriptor> m_rgLabels = new List<LabelDescriptor>();
26 string m_strLabelCounts;
27 int m_nCopyOfSourceID;
28 TemporalDescriptor m_temporalDesc = null;
29
46 public SourceDescriptor(int nID, string strName, int nWd, int nHt, int nCh, bool bIsRealData, bool bSaveImagesToFile, int nCopyOfSourceId = 0, string strOwner = null, int nCount = 0, List<LabelDescriptor> rgLabels = null, string strLabelCounts = null, byte[] rgbTemporal = null)
47 : base(nID, strName, strOwner)
48 {
49 m_nHt = nHt;
50 m_nWd = nWd;
51 m_nCh = nCh;
52 m_bIsRealData = bIsRealData;
53 m_nImageCount = nCount;
54 m_strLabelCounts = strLabelCounts;
55 m_rgLabels = rgLabels;
56 m_bSaveImagesToFile = bSaveImagesToFile;
57 m_nCopyOfSourceID = nCopyOfSourceId;
58 m_temporalDesc = TemporalDescriptor.FromBytes(rgbTemporal);
59 }
60
66 public SourceDescriptor(string strName, bool bSaveImagesToFile)
67 : this(0, strName, 0, 0, 0, false, bSaveImagesToFile)
68 {
69 }
70
77 {
78 m_colParameters = new descriptors.ParameterDescriptorCollection();
79 m_nInactiveCount = s.m_nInactiveCount;
80
81 foreach (ParameterDescriptor p in s.m_colParameters)
82 {
83 m_colParameters.Add(new ParameterDescriptor(p));
84 }
85
86 if (s.m_temporalDesc != null)
87 m_temporalDesc = new TemporalDescriptor(s.m_temporalDesc);
88 }
89
94 public void Copy(SourceDescriptor sd)
95 {
96 base.Copy(sd);
97
98 m_nCh = sd.m_nCh;
99 m_nHt = sd.m_nHt;
100 m_nWd = sd.m_nWd;
101 m_bIsRealData = sd.m_bIsRealData;
102 m_nImageCount = sd.m_nImageCount;
103 m_nInactiveCount = sd.m_nInactiveCount;
104 m_bSaveImagesToFile = sd.m_bSaveImagesToFile;
105 m_nCopyOfSourceID = sd.m_nCopyOfSourceID;
106
107 m_rgLabels = new List<descriptors.LabelDescriptor>();
108 foreach (LabelDescriptor ld in sd.m_rgLabels)
109 {
110 m_rgLabels.Add(new descriptors.LabelDescriptor(ld));
111 }
112
113 m_colParameters = new descriptors.ParameterDescriptorCollection();
114 foreach (ParameterDescriptor p in sd.m_colParameters)
115 {
116 m_colParameters.Add(new ParameterDescriptor(p));
117 }
118
119 m_strLabelCounts = sd.m_strLabelCounts;
120
121 if (sd.m_temporalDesc != null)
122 m_temporalDesc = new TemporalDescriptor(sd.m_temporalDesc);
123 }
124
131 public void Resize(int nChannels, int nHeight, int nWidth)
132 {
133 m_nCh = nChannels;
134 m_nHt = nHeight;
135 m_nWd = nWidth;
136 }
137
141 [Description("Specifies whether the images are saved to the file system or directly to the database.")]
143 {
144 get { return m_bSaveImagesToFile; }
145 }
146
150 [Description("If this source was copied from another source, this property returns the ID of the original Source, otherwise 0 is returned.")]
151 [ReadOnly(true)]
152 public int CopyOfSourceID
153 {
154 get { return m_nCopyOfSourceID; }
155 set { m_nCopyOfSourceID = value; }
156 }
157
161 [Browsable(false)]
162 public List<LabelDescriptor> Labels
163 {
164 get { return m_rgLabels; }
165 set { m_rgLabels = value; }
166 }
167
171 [Description("Specifies the item height in pixels.")]
172 public int Height
173 {
174 get { return m_nHt; }
175 }
176
180 [Description("Specifies the item width in pixels.")]
181 public int Width
182 {
183 get { return m_nWd; }
184 }
185
189 [Description("Specifies the item colors - 1 channel = black/white, 3 channels = RGB color.")]
190 public int Channels
191 {
192 get { return m_nCh; }
193 }
194
198 [Description("Specifies whether or not the each data point represents a real or integer number. Integer numbers are used for black/white and color images where each data point falls within the range [0 - 255].")]
199 public bool IsRealData
200 {
201 get { return m_bIsRealData; }
202 }
203
207 [Description("Specifies the number of images within this data source.")]
208 public int ImageCount
209 {
210 get { return m_nImageCount; }
211 }
212
216 [Description("Specifies the number of inactive images within this data source.")]
218 {
219 get { return m_nInactiveCount; }
220 }
221
226 public void SetInactiveImageCount(int nCount)
227 {
228 m_nInactiveCount = nCount;
229 }
230
234 [Description("Lists the number of images for each label associated with this data source.")]
235 [ReadOnly(true)]
236 public string LabelCountsAsText
237 {
238 get { return m_strLabelCounts; }
239 set { m_strLabelCounts = value; }
240 }
241
246 public override string ToString()
247 {
248 return "Source Description " + Name;
249 }
250
254 [Description("Specifies the parameters of the data source (if any).")]
256 {
257 get { return m_colParameters; }
258 set { m_colParameters = value; }
259 }
260
264 [ReadOnly(true)]
266 {
267 get { return m_temporalDesc; }
268 set { m_temporalDesc = value; }
269 }
270 }
271}
The BaseDescriptor is the base class for all other descriptors, where descriptors are used to describ...
string Owner
Get/set the owner of the item.
int ID
Get/set the database ID of the item.
string Name
Get/set the name of the item.
The LabelDescriptor class describes a single label.
The ParameterDescriptorCollection class contains a list of ParameterDescriptor's.
void Add(ParameterDescriptor p)
Adds a ParameterDescriptor to the collection.
ParameterDescriptorCollection()
The ParameterDescriptorCollection constructor.
The ParameterDescriptor class describes a parameter in the database.
The SourceDescriptor class contains all information describing a data source.
int InactiveImageCount
Returns the number of inactive images within this data source.
void SetInactiveImageCount(int nCount)
Set the number of inactive images within this data source.
void Resize(int nChannels, int nHeight, int nWidth)
Resize the testing and training data sources.
int CopyOfSourceID
Get/set the Source ID from which this source was copied. If this Source is an original,...
override string ToString()
Return a string representation of thet SourceDescriptor.
bool IsRealData
Returns whether or not the each data point represents a real or integer number. Integer numbers are u...
List< LabelDescriptor > Labels
Get/set the list of LabelDescriptors that describe the labels used by the data items.
void Copy(SourceDescriptor sd)
Copy another SourceDesciptor into this one.
int Height
Returns the height of each data item in the data source.
SourceDescriptor(string strName, bool bSaveImagesToFile)
The SourceDescriptor constructor.
SourceDescriptor(int nID, string strName, int nWd, int nHt, int nCh, bool bIsRealData, bool bSaveImagesToFile, int nCopyOfSourceId=0, string strOwner=null, int nCount=0, List< LabelDescriptor > rgLabels=null, string strLabelCounts=null, byte[] rgbTemporal=null)
The SourceDescriptor constructor.
bool SaveImagesToFile
Gets whether or not the images are saved to the file system (true), or directly to the database (fals...
SourceDescriptor(SourceDescriptor s)
The SourceDescriptor constructor.
int Width
Returns the width of each data item in the data source.
TemporalDescriptor TemporalDescriptor
Get/set the temporal descriptor (if any).
ParameterDescriptorCollection Parameters
Get/set the source parameters (if any).
string LabelCountsAsText
Get/set a string that lists the number of images for each label associated with this data source.
int ImageCount
Returns the number of images within this data source.
int Channels
Returns the item colors - 1 channel = black/white, 3 channels = RGB color.
The TemporalDescriptor is used to describe a temporal aspects of the data source.
static TemporalDescriptor FromBytes(byte[] rgb)
Returns a new TemporalDescriptor from a byte array.
The descriptors namespace contains all descriptor used to describe various items stored within the da...