/// <summary> /// The ParseConfigurationString method parses a deep draw configuration string into the actual settings. /// </summary> /// <param name="strConfig">Specifies the configuration string to parse.</param> /// <param name="nWd">Returns the input width.</param> /// <param name="nHt">Returns the input height.</param> /// <param name="dfOutputDetailPct">Returns the percentage of detail to apply to the final image.</param> /// <param name="strSrcBlobName">Returns the source blob name.</param> /// <param name="dfRandomImageScale">Returns the random image scale to use, a number in the range [0,50] used to create varying degrees of gray in the random input image. /// A value of 0 removes the variation and uses a consistent image. The default value is 16.</param> /// <returns>Returns the collection of Octaves to run.</returns> public static OctavesCollection ParseConfigurationString(string strConfig, out int nWd, out int nHt, out double dfOutputDetailPct, out string strSrcBlobName, out double dfRandomImageScale) { RawProto proto = RawProto.Parse(strConfig); string strVal; nHt = -1; if ((strVal = proto.FindValue("input_height")) != null) { nHt = int.Parse(strVal); } nWd = -1; if ((strVal = proto.FindValue("input_width")) != null) { nWd = int.Parse(strVal); } dfOutputDetailPct = 0.25; if ((strVal = proto.FindValue("output_detail_pct")) != null) { dfOutputDetailPct = double.Parse(strVal); } strSrcBlobName = "data"; if ((strVal = proto.FindValue("src_blob_name")) != null) { strSrcBlobName = strVal; } dfRandomImageScale = 16; if ((strVal = proto.FindValue("random_image_scale")) != null) { dfRandomImageScale = double.Parse(strVal); } OctavesCollection col = new OctavesCollection(); RawProtoCollection rpcol = proto.FindChildren("octave"); foreach (RawProto protoChild in rpcol) { col.Add(Octaves.FromProto(protoChild)); } return(col); }
/// <summary> /// The CreateConfigurationString function packs all deep draw settings into a configuration string. /// </summary> /// <param name="nWd">Specifies the input width.</param> /// <param name="nHt">Specifies the input height.</param> /// <param name="dfOutputDetailPct">Specifies the percentage of detail to apply to the final output.</param> /// <param name="colOctaves">Specifies the collection of Octaves to run.</param> /// <param name="strSrcBlobName">Specifies the name of the source blob.</param> /// <param name="dfRandomImageScale">Specifies the random image scale to use, a number in the range [0,50] used to create varying degrees of gray in the random input image. /// A value of 0 removes the variation and uses a consistent image.</param> /// <returns>The configuration string is returned.</returns> public static string CreateConfigurationString(int nWd, int nHt, double dfOutputDetailPct, OctavesCollection colOctaves, string strSrcBlobName, double dfRandomImageScale) { RawProtoCollection rgChildren = new RawProtoCollection(); rgChildren.Add("input_height", nHt.ToString(), RawProto.TYPE.STRING); rgChildren.Add("input_width", nWd.ToString(), RawProto.TYPE.STRING); rgChildren.Add("output_detail_pct", dfOutputDetailPct.ToString(), RawProto.TYPE.STRING); rgChildren.Add("src_blob_name", strSrcBlobName, RawProto.TYPE.STRING); rgChildren.Add("random_image_scale", dfRandomImageScale.ToString(), RawProto.TYPE.STRING); foreach (Octaves octave in colOctaves) { rgChildren.Add(octave.ToProto("octave")); } RawProto proto = new RawProto("root", "", rgChildren); return(proto.ToString()); }