MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
VideoDataParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param.ssd
9{
17 [Serializable]
18 [TypeConverter(typeof(ExpandableObjectConverter))]
20 {
21 VideoType m_videoType = VideoType.WEBCAM;
22 int m_nDeviceID = 0;
23 string m_strVideoFile;
24 uint m_nSkipFrames = 0;
25 uint m_nVideoWidth = 400;
26 uint m_nVideoHeight = 300;
27
31 public enum VideoType
32 {
36 WEBCAM = 0,
40 VIDEO = 1
41 }
42
47 {
48 }
49
53 [Description("Specifies the video type (default = WEBCAM).")]
55 {
56 get { return m_videoType; }
57 set { m_videoType = value; }
58 }
59
63 [Description("Specifies the device ID (default = 0).")]
64 public int device_id
65 {
66 get { return m_nDeviceID; }
67 set { m_nDeviceID = value; }
68 }
69
73 [Description("Specifies the video file when using the VIDEO type.")]
74 public string video_file
75 {
76 get { return m_strVideoFile; }
77 set { m_strVideoFile = value; }
78 }
79
83 [Description("Optionally, specifies the number of frames to be skipped before processing a frame (default = 0).")]
84 public uint skip_frames
85 {
86 get { return m_nSkipFrames; }
87 set { m_nSkipFrames = value; }
88 }
89
93 [Description("Optionally, specifies the video width (default = 400).")]
94 public uint video_width
95 {
96 get { return m_nVideoWidth; }
97 set { m_nVideoWidth = value; }
98 }
99
103 [Description("Optionally, specifies the video height (default = 300).")]
104 public uint video_height
105 {
106 get { return m_nVideoHeight; }
107 set { m_nVideoHeight = value; }
108 }
109
116 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
117 {
118 RawProto proto = RawProto.Parse(br.ReadString());
119 VideoDataParameter p = FromProto(proto);
120
121 if (!bNewInstance)
122 Copy(p);
123
124 return p;
125 }
126
131 public override void Copy(LayerParameterBase src)
132 {
134
135 m_videoType = p.m_videoType;
136 m_nDeviceID = p.m_nDeviceID;
137 m_strVideoFile = p.m_strVideoFile;
138 m_nSkipFrames = p.m_nSkipFrames;
139 m_nVideoWidth = p.m_nVideoWidth;
140 m_nVideoHeight = p.m_nVideoHeight;
141 }
142
147 public override LayerParameterBase Clone()
148 {
150 p.Copy(this);
151 return p;
152 }
153
159 public override RawProto ToProto(string strName)
160 {
161 RawProtoCollection rgChildren = new RawProtoCollection();
162
163 rgChildren.Add(new RawProto("video_type", m_videoType.ToString()));
164 rgChildren.Add(new RawProto("device_id", m_nDeviceID.ToString()));
165
166 if (!string.IsNullOrEmpty(m_strVideoFile))
167 rgChildren.Add(new RawProto("video_file", m_strVideoFile.ToString()));
168
169 rgChildren.Add(new RawProto("skip_frames", m_nSkipFrames.ToString()));
170 rgChildren.Add(new RawProto("video_width", m_nVideoWidth.ToString()));
171 rgChildren.Add(new RawProto("video_height", m_nVideoHeight.ToString()));
172
173 return new RawProto(strName, "", rgChildren);
174 }
175
182 {
184 string strVal;
185
186 if ((strVal = rp.FindValue("video_type")) != null)
187 {
188 if (strVal == VideoType.VIDEO.ToString())
189 p.video_type = VideoType.VIDEO;
190 else
191 p.video_type = VideoType.WEBCAM;
192 }
193
194 if ((strVal = rp.FindValue("device_id")) != null)
195 p.device_id = int.Parse(strVal);
196
197 if ((strVal = rp.FindValue("video_file")) != null)
198 p.video_file = strVal;
199
200 if ((strVal = rp.FindValue("skip_frames")) != null)
201 p.skip_frames = uint.Parse(strVal);
202
203 if ((strVal = rp.FindValue("video_width")) != null)
204 p.video_width = uint.Parse(strVal);
205
206 if ((strVal = rp.FindValue("video_height")) != null)
207 p.video_height = uint.Parse(strVal);
208
209 return p;
210 }
211 }
212}
The RawProtoCollection class is a list of RawProto objects.
void Add(RawProto p)
Adds a RawProto to the collection.
The RawProto class is used to parse and output Google prototxt file data.
Definition: RawProto.cs:17
static RawProto Parse(string str)
Parses a prototxt and places it in a new RawProto.
Definition: RawProto.cs:306
string FindValue(string strName)
Searches for a falue of a node within this nodes children.
Definition: RawProto.cs:105
The LayerParameterBase is the base class for all other layer specific parameters.
Specifies the parameters for the VideoDataLayer.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
uint video_width
Optionally, specifies the video width (default = 400).
static VideoDataParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
uint skip_frames
Optionally, specifies the number of frames to be skipped before processing a frame (default = 0).
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
string video_file
Specifies the video file when using the VIDEO type.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
int device_id
Specifies the device ID (default = 0).
uint video_height
Optionally, specifies the video height (default = 300).
VideoType video_type
Specifies the video type (default = WEBCAM).
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.param.ssd namespace contains all SSD related parameter objects that correspond to the nat...
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12