/// <summary>
        /// Return a copy of this object.
        /// </summary>
        /// <returns>A new copy of the object is returned.</returns>
        public SaveOutputParameter Clone()
        {
            SaveOutputParameter p = new SaveOutputParameter(Active);

            p.Copy(this);
            return(p);
        }
        /// <summary>
        /// Load the and return a new ResizeParameter.
        /// </summary>
        /// <param name="br"></param>
        /// <param name="bNewInstance"></param>
        /// <returns>The new object is returned.</returns>
        public SaveOutputParameter Load(BinaryReader br, bool bNewInstance = true)
        {
            RawProto            proto = RawProto.Parse(br.ReadString());
            SaveOutputParameter p     = FromProto(proto);

            if (!bNewInstance)
            {
                Copy(p);
            }

            return(p);
        }
        /// <summary>
        /// Copy on parameter to another.
        /// </summary>
        /// <param name="src">Specifies the parameter to copy.</param>
        public override void Copy(LayerParameterBase src)
        {
            DetectionOutputParameter p = (DetectionOutputParameter)src;

            m_nNumClasses              = p.m_nNumClasses;
            m_bShareLocation           = p.m_bShareLocation;
            m_nBackgroundLabelId       = p.m_nBackgroundLabelId;
            m_nmsParam                 = p.m_nmsParam.Clone();
            m_saveOutputParam          = p.save_output_param.Clone() as SaveOutputParameter;
            m_codeType                 = p.m_codeType;
            m_bVarianceEncodedInTarget = p.m_bVarianceEncodedInTarget;
            m_nKeepTopK                = p.m_nKeepTopK;
            m_fConfidenceThreshold     = p.m_fConfidenceThreshold;
            m_bVisualize               = p.m_bVisualize;
            m_fVisualizeThreshold      = p.m_fVisualizeThreshold;
            m_strSaveFile              = p.m_strSaveFile;
        }
        /// <summary>
        /// Copy the source object.
        /// </summary>
        /// <param name="src">Specifies the source data.</param>
        public override void Copy(OptionalParameter src)
        {
            base.Copy(src);

            if (src is SaveOutputParameter)
            {
                SaveOutputParameter p = (SaveOutputParameter)src;

                m_strOutputDirectory  = p.m_strOutputDirectory;
                m_strOutputNamePrefix = p.m_strOutputNamePrefix;
                m_outputFormat        = p.m_outputFormat;
                m_strLabelMapFile     = p.m_strLabelMapFile;
                m_strNameSizeFile     = p.m_strNameSizeFile;
                m_nNumTestImage       = p.m_nNumTestImage;

                m_resizeParam = null;
                if (p.resize_param != null)
                {
                    m_resizeParam = p.resize_param.Clone();
                }
            }
        }
        /// <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 new SaveOutputParameter FromProto(RawProto rp)
        {
            SaveOutputParameter p = new SaveOutputParameter(false);
            string strVal;

            RawProto rpOption = rp.FindChild("option");

            if (rpOption != null)
            {
                ((OptionalParameter)p).Copy(OptionalParameter.FromProto(rpOption));
            }

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

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

            if ((strVal = rp.FindValue("output_format")) != null)
            {
                if (strVal == OUTPUT_FORMAT.VOC.ToString())
                {
                    p.output_format = OUTPUT_FORMAT.VOC;
                }
                else if (strVal == OUTPUT_FORMAT.COCO.ToString())
                {
                    p.output_format = OUTPUT_FORMAT.COCO;
                }
                else
                {
                    throw new Exception("Unknown output_format '" + strVal + "'!");
                }
            }

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

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

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

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

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

            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 DetectionOutputParameter FromProto(RawProto rp)
        {
            DetectionOutputParameter p = new DetectionOutputParameter();
            string strVal;

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

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

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

            RawProto rpNms = rp.FindChild("nms_param");

            if (rpNms != null)
            {
                p.nms_param = NonMaximumSuppressionParameter.FromProto(rpNms);
            }

            RawProto rpSave = rp.FindChild("save_output_param");

            if (rpSave != null)
            {
                p.save_output_param = SaveOutputParameter.FromProto(rpSave);
            }

            if ((strVal = rp.FindValue("code_type")) != null)
            {
                if (strVal == PriorBoxParameter.CodeType.CENTER_SIZE.ToString())
                {
                    p.code_type = PriorBoxParameter.CodeType.CENTER_SIZE;
                }
                else if (strVal == PriorBoxParameter.CodeType.CORNER.ToString())
                {
                    p.code_type = PriorBoxParameter.CodeType.CORNER;
                }
                else if (strVal == PriorBoxParameter.CodeType.CORNER_SIZE.ToString())
                {
                    p.code_type = PriorBoxParameter.CodeType.CORNER_SIZE;
                }
                else
                {
                    throw new Exception("Unknown PriorBoxParameter.CodeType '" + strVal + "'!");
                }
            }

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

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

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

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

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

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

            return(p);
        }