using System;
using System.Collections.Generic;
namespace UnityEngine.Perception.GroundTruth
{
///
/// A definition for how a should be resolved to a single label and id for ground truth generation.
///
[CreateAssetMenu(fileName = "LabelingConfiguration", menuName = "Perception/Labeling Configuration", order = 1)]
public class LabelingConfiguration : ScriptableObject
{
///
/// A sequence of which defines the labels relevant for this configuration and their values.
///
[SerializeField]
public List LabelingConfigurations = new List();
///
/// Attempts to find the matching index in for the given .
///
///
/// The matching index is the first class name in the given Labeling which matches an entry in .
///
/// The to match
/// When this method returns, contains the index of the matching , or -1 if no match was found.
/// Returns true if a match was found. False if not.
public bool TryGetMatchingConfigurationIndex(Labeling labeling, out int index)
{
foreach (var labelingClass in labeling.labels)
{
for (var i = 0; i < LabelingConfigurations.Count; i++)
{
var configuration = LabelingConfigurations[i];
if (string.Equals(configuration.label, labelingClass))
{
index = i;
return true;
}
}
}
index = -1;
return false;
}
}
///
/// Structure defining a label configuration for .
///
[Serializable]
public struct LabelingConfigurationEntry
{
///
/// The label string
///
public string label;
///
/// The value to use when generating semantic segmentation images.
///
public int value;
///
/// Creates a new LabelingConfigurationEntry with the given values.
///
/// The label string.
/// The value to use when generating semantic segmentation images.
public LabelingConfigurationEntry(string label, int value)
{
this.label = label;
this.value = value;
}
}
}