MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
EmitConstraint.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.ssd
11{
19 [Serializable]
20 [TypeConverter(typeof(ExpandableObjectConverter))]
22 {
23 EmitType m_emitType = EmitType.CENTER;
24 float m_fEmitOverlap = 0;
25
29 public enum EmitType
30 {
34 CENTER = 0,
38 MIN_OVERLAP = 1
39 }
40
45 public EmitConstraint(bool bActive) : base(bActive)
46 {
47 }
48
52 [Description("Get/set the emit type.")]
54 {
55 get { return m_emitType; }
56 set { m_emitType = value; }
57 }
58
62 [Description("Get/set the emit overlap used with MIN_OVERLAP.")]
63 public float emit_overlap
64 {
65 get { return m_fEmitOverlap; }
66 set { m_fEmitOverlap = value; }
67 }
68
73 public override void Copy(OptionalParameter src)
74 {
75 base.Copy(src);
76
77 if (src is EmitConstraint)
78 {
80 m_emitType = p.emit_type;
81 m_fEmitOverlap = p.emit_overlap;
82 }
83 }
84
90 {
91 EmitConstraint p = new param.ssd.EmitConstraint(Active);
92 p.Copy(this);
93 return p;
94 }
95
101 public override RawProto ToProto(string strName)
102 {
103 RawProto rpBase = base.ToProto("option");
104 RawProtoCollection rgChildren = new RawProtoCollection();
105
106 rgChildren.Add(rpBase);
107 rgChildren.Add(new RawProto("emit_type", m_emitType.ToString()));
108 rgChildren.Add(new RawProto("emit_overlap", m_fEmitOverlap.ToString()));
109
110 return new RawProto(strName, "", rgChildren);
111 }
112
118 public static new EmitConstraint FromProto(RawProto rp)
119 {
120 EmitConstraint p = new EmitConstraint(false);
121 string strVal;
122
123 RawProto rpOption = rp.FindChild("option");
124 if (rpOption != null)
125 ((OptionalParameter)p).Copy(OptionalParameter.FromProto(rpOption));
126
127 if ((strVal = rp.FindValue("emit_type")) != null)
128 {
129 switch (strVal)
130 {
131 case "CENTER":
132 p.emit_type = EmitType.CENTER;
133 break;
134
135 case "MIN_OVERLAP":
136 p.emit_type = EmitType.MIN_OVERLAP;
137 break;
138
139 default:
140 throw new Exception("Unknown emit_type '" + strVal + "'!");
141 }
142 }
143
144 if ((strVal = rp.FindValue("emit_overlap")) != null)
146
147 return p;
148 }
149 }
150}
The BaseParameter class is the base class for all other parameter classes.
static float ParseFloat(string strVal)
Parse float values using the US culture if the decimal separator = '.', then using the native culture...
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
string FindValue(string strName)
Searches for a falue of a node within this nodes children.
Definition: RawProto.cs:105
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.
Specifies the parameters for the EmitConstraint used with SSD.
EmitType emit_type
Get/set the emit type.
float emit_overlap
Get/set the emit overlap used with MIN_OVERLAP.
EmitType
Specifies the emit type.
override void Copy(OptionalParameter src)
Copy the source object.
override RawProto ToProto(string strName)
Convert this object to a raw proto.
EmitConstraint Clone()
Return a copy of this object.
static new EmitConstraint FromProto(RawProto rp)
Parses the parameter from a RawProto.
EmitConstraint(bool bActive)
The constructor.
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