MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MaskParameter.cs
1using System;
2using System.Collections.Generic;
4using System.IO;
5using System.Linq;
6using System.Text;
7using System.Threading.Tasks;
8using MyCaffe.basecode;
9
10namespace MyCaffe.param
11{
15 [Serializable]
16 [TypeConverter(typeof(ExpandableObjectConverter))]
18 {
19 int m_nMaskLeft = 0;
20 int m_nMaskRight = 0;
21 int m_nMaskTop = 0;
22 int m_nMaskBottom = 0;
23
28 public MaskParameter(bool bActive) : base(bActive)
29 {
30 }
31
35 [Description("Defines the left side of the masked boundary where 'x' positions >= this value are masked.")]
36 public int boundary_left
37 {
38 get { return m_nMaskLeft; }
39 set { m_nMaskLeft = value; }
40 }
41
45 [Description("Defines the right side of the masked boundary where 'x' positions <= this value are masked.")]
46 public int boundary_right
47 {
48 get { return m_nMaskRight; }
49 set { m_nMaskRight = value; }
50 }
51
55 [Description("Defines the top side of the masked boundary where 'y' positions >= this value are masked.")]
56 public int boundary_top
57 {
58 get { return m_nMaskTop; }
59 set { m_nMaskTop = value; }
60 }
61
65 [Description("Defines the bottom side of the masked boundary where 'y' positions <= this value are masked.")]
66 public int boundary_bottom
67 {
68 get { return m_nMaskBottom; }
69 set { m_nMaskBottom = value; }
70 }
71
72
79 public MaskParameter Load(BinaryReader br, bool bNewInstance = true)
80 {
81 RawProto proto = RawProto.Parse(br.ReadString());
82 MaskParameter p = FromProto(proto);
83
84 if (!bNewInstance)
85 Copy(p);
86
87 return p;
88 }
89
94 public override void Copy(OptionalParameter src)
95 {
96 base.Copy(src);
97
98 if (src is MaskParameter)
99 {
101 m_nMaskLeft = p.m_nMaskLeft;
102 m_nMaskRight = p.m_nMaskRight;
103 m_nMaskTop = p.m_nMaskTop;
104 m_nMaskBottom = p.m_nMaskBottom;
105 }
106 }
107
113 {
115 p.Copy(this);
116 return p;
117 }
118
124 public override RawProto ToProto(string strName)
125 {
126 RawProto rpBase = base.ToProto("option");
127 RawProtoCollection rgChildren = new RawProtoCollection();
128
129 rgChildren.Add(rpBase);
130 rgChildren.Add(new RawProto("boundary_left", boundary_left.ToString()));
131 rgChildren.Add(new RawProto("boundary_right", boundary_right.ToString()));
132 rgChildren.Add(new RawProto("boundary_top", boundary_top.ToString()));
133 rgChildren.Add(new RawProto("boundary_bottom", boundary_bottom.ToString()));
134
135 return new RawProto(strName, "", rgChildren);
136 }
137
143 public static new MaskParameter FromProto(RawProto rp)
144 {
145 MaskParameter p = new MaskParameter(true);
146 string strVal;
147
148 RawProto rpOption = rp.FindChild("option");
149 if (rpOption != null)
150 ((OptionalParameter)p).Copy(OptionalParameter.FromProto(rpOption));
151
152 if ((strVal = rp.FindValue("boundary_left")) != null)
153 p.boundary_left = int.Parse(strVal);
154
155 if ((strVal = rp.FindValue("boundary_right")) != null)
156 p.boundary_right = int.Parse(strVal);
157
158 if ((strVal = rp.FindValue("boundary_top")) != null)
159 p.boundary_top = int.Parse(strVal);
160
161 if ((strVal = rp.FindValue("boundary_bottom")) != null)
162 p.boundary_bottom = int.Parse(strVal);
163
164 return p;
165 }
166 }
167}
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
RawProto FindChild(string strName)
Searches for a given node.
Definition: RawProto.cs:231
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
Specifies the parameters for the MaskParameter used to mask portions of the transformed data when act...
override RawProto ToProto(string strName)
Convert this object to a raw proto.
static new MaskParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
MaskParameter Clone()
Return a copy of this object.
MaskParameter(bool bActive)
The constructor.
int boundary_bottom
Get/set the mask boundary bottom.
MaskParameter Load(BinaryReader br, bool bNewInstance=true)
Load the and return a new MaskParameter.
int boundary_left
Get/set the mask boundary left.
override void Copy(OptionalParameter src)
Copy the source object.
int boundary_right
Get/set the mask boundary left.
int boundary_top
Get/set the mask boundary top.
The OptionalParameter is the base class for parameters that are optional such as the MaskParameter,...
static OptionalParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
OptionalParameter(bool bActive=false)
The constructor.
bool Active
When active, the parameter is used, otherwise it is ignored.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.param namespace contains parameters used to create models.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12