/// <summary> /// Compares this BatchSampler to another. /// </summary> /// <param name="bs">Specifies the other BatchSampler to compare this one to.</param> /// <returns>If the two BatchSampler's are the same <i>true</i> is returned, otherwise <i>false</i> is returned.</returns> public bool Compare(BatchSampler bs) { if (bs.m_bUseOriginalImage != m_bUseOriginalImage) { return(false); } if (bs.m_nMaxSample != m_nMaxSample) { return(false); } if (bs.m_nMaxTrials != m_nMaxTrials) { return(false); } if (!bs.m_sampler.Compare(m_sampler)) { return(false); } if (!bs.m_constraint.Compare(m_constraint)) { return(true); } return(true); }
/// <summary> /// Creates a copy of the BatchSampler. /// </summary> /// <returns>A new instance of the BatchSampler is returned.</returns> public BatchSampler Clone() { BatchSampler bs = new BatchSampler(); bs.m_bUseOriginalImage = m_bUseOriginalImage; bs.m_nMaxSample = m_nMaxSample; bs.m_nMaxTrials = m_nMaxTrials; bs.m_sampler = m_sampler.Clone(); bs.m_constraint = m_constraint.Clone(); return(bs); }
/// <summary> /// Compares this BatchSampler to another. /// </summary> /// <param name="obj">Specifies the other BatchSampler to compare this one to.</param> /// <returns>If the two BatchSampler's are the same <i>true</i> is returned, otherwise <i>false</i> is returned.</returns> public int CompareTo(object obj) { BatchSampler bs = obj as BatchSampler; if (bs == null) { return(1); } if (!Compare(bs)) { return(1); } return(0); }
/// <summary> /// Load the BatchSampler from a binary reader. /// </summary> /// <param name="br">The binary reader to use.</param> /// <param name="bNewInstance">When <i>true</i>, a the BatchSampler is read into a new instance, otherwise it is read into the current instance.</param> /// <returns>The BatchSampler instance is returned.</returns> public object Load(BinaryReader br, bool bNewInstance) { BatchSampler b = this; if (bNewInstance) { b = new BatchSampler(); } m_bUseOriginalImage = br.ReadBoolean(); m_nMaxSample = br.ReadUInt32(); m_nMaxTrials = br.ReadUInt32(); m_sampler = Sampler.Load(br); m_constraint = SamplerConstraint.Load(br); return(b); }
/// <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 AnnotatedDataParameter FromProto(RawProto rp) { AnnotatedDataParameter p = new AnnotatedDataParameter(); string strVal; if ((strVal = rp.FindValue("anno_type")) != null) p.m_type = (SimpleDatum.ANNOTATION_TYPE)int.Parse(strVal); if ((strVal = rp.FindValue("label_map_file")) != null) p.m_strLabelFile = strVal; RawProtoCollection col = rp.FindChildren("batch_sampler"); foreach (RawProto rp1 in col) { p.m_rgBatchSampler.Add(BatchSampler.FromProto(rp1)); } return p; }
/// <summary> /// Parse a new BatchSampler from a RawProto. /// </summary> /// <param name="rp">Specifies the RawProto containing a representation of the BatchSampler.</param> /// <returns>A new instance of the BatchSampler is returned.</returns> public static BatchSampler FromProto(RawProto rp) { string strVal; BatchSampler p = new BatchSampler(); if ((strVal = rp.FindValue("use_original_image")) != null) { p.use_original_image = bool.Parse(strVal); } if ((strVal = rp.FindValue("max_sample")) != null) { p.max_sample = uint.Parse(strVal); } if ((strVal = rp.FindValue("max_trials")) != null) { p.max_trials = uint.Parse(strVal); } RawProto protoSampler = rp.FindChild("sampler"); if (protoSampler != null) { p.sampler = Sampler.FromProto(protoSampler); } RawProto protoConstraint = rp.FindChild("sample_constraint"); if (protoConstraint != null) { p.sample_constraint = SamplerConstraint.FromProto(protoConstraint); } return(p); }
/// <summary> /// Load the BatchSampler from a binary reader. /// </summary> /// <param name="br">The binary reader to use.</param> /// <returns>A new BatchSampler instance is returned.</returns> public static BatchSampler Load(BinaryReader br) { BatchSampler b = new BatchSampler(); return((BatchSampler)b.Load(br, true)); }