/// <summary> /// Parse a new SampleConstraint from a RawProto. /// </summary> /// <param name="rp">Specifies the RawProto containing a representation of the SampleConstraint.</param> /// <returns>A new instance of the SampleConstraint is returned.</returns> public static SamplerConstraint FromProto(RawProto rp) { string strVal; SamplerConstraint p = new SamplerConstraint(); if ((strVal = rp.FindValue("min_jaccard_overlap")) != null) { p.min_jaccard_overlap = BaseParameter.ParseFloat(strVal); } if ((strVal = rp.FindValue("max_jaccard_overlap")) != null) { p.max_jaccard_overlap = BaseParameter.ParseFloat(strVal); } if ((strVal = rp.FindValue("min_sample_coverage")) != null) { p.min_sample_coverage = BaseParameter.ParseFloat(strVal); } if ((strVal = rp.FindValue("max_sample_coverage")) != null) { p.max_sample_coverage = BaseParameter.ParseFloat(strVal); } if ((strVal = rp.FindValue("min_object_coverage")) != null) { p.min_object_coverage = BaseParameter.ParseFloat(strVal); } if ((strVal = rp.FindValue("max_object_coverage")) != null) { p.max_object_coverage = BaseParameter.ParseFloat(strVal); } return(p); }
/// <summary> /// Compares this SampleConstraint to another. /// </summary> /// <param name="bs">Specifies the other SampleConstraint to compare this one to.</param> /// <returns>If the two SampleConstraint's are the same <i>true</i> is returned, otherwise <i>false</i> is returned.</returns> public bool Compare(SamplerConstraint bs) { if (bs.m_fMinJaccardOverlap != m_fMinJaccardOverlap) { return(false); } if (bs.m_fMaxJaccardOverlap != m_fMaxJaccardOverlap) { return(false); } if (bs.m_fMinSampleCoverage != m_fMinSampleCoverage) { return(false); } if (bs.m_fMaxSampleCoverage != m_fMaxSampleCoverage) { return(false); } if (bs.m_fMinObjectCoverage != m_fMinObjectCoverage) { return(false); } if (bs.m_fMaxObjectCoverage != m_fMaxObjectCoverage) { return(false); } return(true); }
/// <summary> /// Creates a copy of the SampleConstraint. /// </summary> /// <returns>A new instance of the SampleConstraint is returned.</returns> public SamplerConstraint Clone() { SamplerConstraint bs = new SamplerConstraint(); bs.m_fMinJaccardOverlap = m_fMinJaccardOverlap; bs.m_fMaxJaccardOverlap = m_fMaxJaccardOverlap; bs.m_fMinSampleCoverage = m_fMinSampleCoverage; bs.m_fMaxSampleCoverage = m_fMaxSampleCoverage; bs.m_fMinObjectCoverage = m_fMinObjectCoverage; bs.m_fMaxObjectCoverage = m_fMaxObjectCoverage; return(bs); }
/// <summary> /// Compares this SampleConstraint to another. /// </summary> /// <param name="obj">Specifies the other SampleConstraint to compare this one to.</param> /// <returns>If the two SampleConstraint's are the same <i>true</i> is returned, otherwise <i>false</i> is returned.</returns> public int CompareTo(object obj) { SamplerConstraint bs = obj as SamplerConstraint; 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> /// Load the SampleConstraint from a binary reader. /// </summary> /// <param name="br">The binary reader to use.</param> /// <param name="bNewInstance">When <i>true</i>, a the SampleConstraint is read into a new instance, otherwise it is read into the current instance.</param> /// <returns>The SampleConstraint instance is returned.</returns> public object Load(BinaryReader br, bool bNewInstance) { SamplerConstraint b = this; if (bNewInstance) { b = new SamplerConstraint(); } b.m_fMinJaccardOverlap = load(br); b.m_fMaxJaccardOverlap = load(br); b.m_fMinSampleCoverage = load(br); b.m_fMaxSampleCoverage = load(br); b.m_fMinObjectCoverage = load(br); b.m_fMaxObjectCoverage = load(br); return(b); }
/// <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 SampleConstraint from a binary reader. /// </summary> /// <param name="br">The binary reader to use.</param> /// <returns>A new SampleConstraint instance is returned.</returns> public static SamplerConstraint Load(BinaryReader br) { SamplerConstraint b = new SamplerConstraint(); return((SamplerConstraint)b.Load(br, true)); }