/// <summary>
        /// Parses the parameter from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto to parse.</param>
        /// <returns>A new instance of the parameter is returned.</returns>
        public static TransformationParameter FromProto(RawProto rp)
        {
            string strVal;
            TransformationParameter p = new TransformationParameter();

            if ((strVal = rp.FindValue("scale")) != null)
            {
                p.scale = ParseDouble(strVal);
            }

            if ((strVal = rp.FindValue("scale_operator")) != null)
            {
                if (strVal == SCALE_OPERATOR.MUL.ToString())
                {
                    p.scale_operator = SCALE_OPERATOR.MUL;
                }
                else if (strVal == SCALE_OPERATOR.POW.ToString())
                {
                    p.scale_operator = SCALE_OPERATOR.POW;
                }
                else
                {
                    p.scale_operator = SCALE_OPERATOR.NONE;
                }
            }
            else
            {
                p.scale_operator = null;
            }

            if ((strVal = rp.FindValue("mirror")) != null)
            {
                p.mirror = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("crop_size")) != null)
            {
                p.crop_size = uint.Parse(strVal);
            }

            if ((strVal = rp.FindValue("use_image_mean")) != null ||
                (strVal = rp.FindValue("use_imagedb_mean")) != null)
            {
                p.use_imagedb_mean = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("mean_file")) != null)
            {
                p.use_imagedb_mean = true;
            }

            p.mean_value = rp.FindArray <double>("mean_value");

            if ((strVal = rp.FindValue("force_color")) != null)
            {
                p.force_color = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("force_gray")) != null)
            {
                p.force_gray = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("force_positive_range_max")) != null)
            {
                p.forced_positive_range_max = ParseDouble(strVal);
            }

            if ((strVal = rp.FindValue("mean_file")) != null)
            {
                p.mean_file = strVal;
            }

            if ((strVal = rp.FindValue("color_order")) != null)
            {
                if (strVal == COLOR_ORDER.BGR.ToString())
                {
                    p.color_order = COLOR_ORDER.BGR;
                }
                else
                {
                    p.color_order = COLOR_ORDER.RGB;
                }
            }

            RawProto rpResize = rp.FindChild("resize_param");

            if (rpResize != null)
            {
                p.resize_param = ResizeParameter.FromProto(rpResize);
            }
            else
            {
                p.resize_param = null;
            }

            RawProto rpNoise = rp.FindChild("noise_param");

            if (rpNoise != null)
            {
                p.noise_param = NoiseParameter.FromProto(rpNoise);
            }
            else
            {
                p.noise_param = null;
            }

            RawProto rpDistort = rp.FindChild("distortion_param");

            if (rpDistort != null)
            {
                p.distortion_param = DistortionParameter.FromProto(rpDistort);
            }

            RawProto rpExpand = rp.FindChild("expansion_param");

            if (rpExpand != null)
            {
                p.expansion_param = ExpansionParameter.FromProto(rpExpand);
            }
            else
            {
                p.expansion_param = null;
            }

            RawProto rpEmitCon = rp.FindChild("emit_constraint");

            if (rpEmitCon != null)
            {
                p.emit_constraint = EmitConstraint.FromProto(rpEmitCon);
            }
            else
            {
                p.emit_constraint = null;
            }

            RawProto rpMask = rp.FindChild("mask_param");

            if (rpMask != null)
            {
                p.mask_param = MaskParameter.FromProto(rpMask);
            }

            RawProto rpLabelMapping = rp.FindChild("label_mapping");

            if (rpLabelMapping != null)
            {
                p.label_mapping = DataLabelMappingParameter.FromProto(rpLabelMapping);
            }

            return(p);
        }
        /// <summary>
        /// Parses the parameter from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto to parse.</param>
        /// <returns>A new instance of the parameter is returned.</returns>
        public static TransformationParameter FromProto(RawProto rp)
        {
            string strVal;
            TransformationParameter p = new TransformationParameter();

            if ((strVal = rp.FindValue("scale")) != null)
            {
                p.scale = double.Parse(strVal);
            }

            if ((strVal = rp.FindValue("mirror")) != null)
            {
                p.mirror = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("crop_size")) != null)
            {
                p.crop_size = uint.Parse(strVal);
            }

            if ((strVal = rp.FindValue("use_image_mean")) != null ||
                (strVal = rp.FindValue("use_imagedb_mean")) != null)
            {
                p.use_imagedb_mean = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("mean_file")) != null)
            {
                p.use_imagedb_mean = true;
            }

            p.mean_value = rp.FindArray <double>("mean_value");

            if ((strVal = rp.FindValue("force_color")) != null)
            {
                p.force_color = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("force_gray")) != null)
            {
                p.force_gray = bool.Parse(strVal);
            }

            if ((strVal = rp.FindValue("force_positive_range_max")) != null)
            {
                p.forced_positive_range_max = double.Parse(strVal);
            }

            if ((strVal = rp.FindValue("mean_file")) != null)
            {
                p.mean_file = strVal;
            }

            if ((strVal = rp.FindValue("color_order")) != null)
            {
                if (strVal == COLOR_ORDER.BGR.ToString())
                {
                    p.color_order = COLOR_ORDER.BGR;
                }
                else
                {
                    p.color_order = COLOR_ORDER.RGB;
                }
            }

            RawProto rpResize = rp.FindChild("resize_param");

            p.resize_param = (rpResize != null) ? ResizeParameter.FromProto(rpResize) : null;

            RawProto rpNoise = rp.FindChild("noise_param");

            p.noise_param = (rpNoise != null) ? NoiseParameter.FromProto(rpNoise) : null;

            RawProto rpDistort = rp.FindChild("distortion_param");

            p.distortion_param = (rpDistort != null) ? DistortionParameter.FromProto(rpDistort) : null;

            RawProto rpExpand = rp.FindChild("expansion_param");

            p.expansion_param = (rpExpand != null) ? ExpansionParameter.FromProto(rpExpand) : null;

            RawProto rpEmitCon = rp.FindChild("emit_constraint");

            p.emit_constraint = (rpEmitCon != null) ? EmitConstraint.FromProto(rpEmitCon) : null;

            return(p);
        }