浏览代码

Some random stuff

/labeler_mock
Jon Hogins 4 年前
当前提交
902366ef
共有 2 个文件被更改,包括 39 次插入33 次删除
  1. 2
      com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs
  2. 70
      com.unity.perception/Runtime/GroundTruth/Labeling/LabelingConfiguration2.cs

2
com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs


public class SemanticSegmentationLabeler : MonoBehaviour
{
public string annotationId = "12F94D8D-5425-4DEB-9B21-5E53AD957D66";
public LabelingConfiguration labelingConfiguration;
public SemanticSegmentationLabelConfig labelConfig;
}
}

70
com.unity.perception/Runtime/GroundTruth/Labeling/LabelingConfiguration2.cs


namespace UnityEngine.Perception.GroundTruth
{
[Serializable]
public struct IdLabelEntry : ILabelEntry
{
string ILabelEntry.label => this.label;
public string label;
public int id;
}
[CreateAssetMenu(fileName = "LabelingConfiguration2", menuName = "Perception/Labeling Configuration 2", order = 1)]
public class LabelingConfiguration2 : ScriptableObject
[CreateAssetMenu(fileName = "IdLabelingConfiguration", menuName = "Perception/ID Labeling Configuration", order = 1)]
public class IdLabelConfig : LabelingConfiguration2<IdLabelEntry>
{
}
[Serializable]
public struct SemanticSegmentationLabelEntry : ILabelEntry
{
string ILabelEntry.label => this.label;
public string label;
public int pixelValue;
}
/// <summary>
/// A definition for how a <see cref="Labeling"/> should be resolved to a single label and id for ground truth generation.
/// </summary>
[CreateAssetMenu(fileName = "SemanticSegmentationLabelingConfiguration", menuName = "Perception/Semantic Segmentation Label Config", order = 1)]
public class SemanticSegmentationLabelConfig : LabelingConfiguration2<SemanticSegmentationLabelEntry>
{
/// <summary>
/// Whether the inspector will auto-assign ids based on the id of the first element.

/// Whether the inspector will start label ids at zero or one when <see cref="AutoAssignIds"/> is enabled.
/// </summary>
public StartingLabelId StartingLabelId = StartingLabelId.One;
[SerializeField]
public List<string> Labels = new List<string>();
}
/// <summary>
/// A definition for how a <see cref="Labeling"/> should be resolved to a single label and id for ground truth generation.
/// </summary>
[CreateAssetMenu(fileName = "LabelingConfiguration2", menuName = "Perception/Labeling Configuration 2", order = 1)]
public class LabelingConfiguration2<T> : ScriptableObject where T : ILabelEntry
{
public List<LabelFeature> LabelFeatures = new List<LabelFeature>();
public List<T> LabelEntries = new List<T>();
/// <summary>
/// Attempts to find the matching index in <see cref="LabelEntries"/> for the given <see cref="Labeling"/>.

/// <param name="labeling">The <see cref="Labeling"/> to match </param>
/// <param name="labelEntry">When this method returns, contains the matching <see cref="LabelEntry"/>, or <code>default</code> if no match was found.</param>
/// <returns>Returns true if a match was found. False if not.</returns>
public bool TryGetMatchingConfigurationEntry(Labeling labeling, out LabelEntry labelEntry)
public bool TryGetMatchingConfigurationEntry(Labeling labeling, out T labelEntry)
{
return TryGetMatchingConfigurationEntry(labeling, out labelEntry, out int _);
}

/// <param name="labelEntry">When this method returns, contains the matching <see cref="LabelEntry"/>, or <code>default</code> if no match was found.</param>
/// <param name="labelEntryIndex">When this method returns, contains the index of the matching <see cref="LabelEntry"/>, or <code>-1</code> if no match was found.</param>
/// <returns>Returns true if a match was found. False if not.</returns>
public bool TryGetMatchingConfigurationEntry(Labeling labeling, out LabelEntry labelEntry, out int labelEntryIndex)
public bool TryGetMatchingConfigurationEntry(Labeling labeling, out T labelEntry, out int labelEntryIndex)
{
foreach (var labelingClass in labeling.labels)
{

if (string.Equals(entry.label, labelingClass))
if (string.Equals(entry, labelingClass))
labelEntry = entry;
labelEntry = LabelEntries[i];
labelEntryIndex = i;
return true;
}

}
}
/// <summary>
/// Structure defining a label configuration for <see cref="LabelingConfiguration"/>.
/// </summary>
[Serializable]
public class LabelFeature
public interface ILabelEntry
public string key;
}
[Serializable]
public class StringLabelFeature : LabelFeature
{
public List<string> values;
}
[Serializable]
public class IntLabelFeature : LabelFeature
{
public List<string> values;
}
[Serializable]
public class ColorLabelFeature : LabelFeature
{
public List<string> values;
string label { get; }
}
}
正在加载...
取消
保存