|
|
|
|
|
|
|
|
|
|
namespace UnityEngine.Perception.GroundTruth |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Produces keypoint annotations for a humanoid model. This labeler supports generic
|
|
|
|
/// <see cref="KeyPointTemplate"/>. Template values are mapped to rigged
|
|
|
|
/// <see cref="Animator"/> <seealso cref="Avatar"/>. Custom joints can be
|
|
|
|
/// created by applying <see cref="JointLabel"/> to empty game objects at a body
|
|
|
|
/// part's location.
|
|
|
|
/// </summary>
|
|
|
|
/// <summary>
|
|
|
|
/// The active keypoint template. Required to annotate keypoint data.
|
|
|
|
/// </summary>
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public override string description |
|
|
|
{ |
|
|
|
get => "Produces keypoint annotations for all visible labeled objects that have a humanoid animation avatar component."; |
|
|
|
|
|
|
protected override bool supportsVisualization => true; |
|
|
|
|
|
|
|
// ReSharper disable MemberCanBePrivate.Global
|
|
|
|
/// <summary>
|
|
|
|
/// The GUID id to associate with the annotations produced by this labeler.
|
|
|
|
/// </summary>
|
|
|
|
/// <summary>
|
|
|
|
/// The <see cref="IdLabelConfig"/> which associates objects with labels.
|
|
|
|
/// </summary>
|
|
|
|
public IdLabelConfig idLabelConfig; |
|
|
|
// ReSharper restore MemberCanBePrivate.Global
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
protected override void Setup() |
|
|
|
{ |
|
|
|
if (idLabelConfig == null) |
|
|
|
|
|
|
|
|
|
|
m_KeyPointEntries = new List<KeyPointEntry>(); |
|
|
|
|
|
|
|
// Texture to use in case the template does not contain a texture for the joints or the skeletal connections
|
|
|
|
/// <inheritdoc/>
|
|
|
|
protected override void OnBeginRendering() |
|
|
|
{ |
|
|
|
var reporter = perceptionCamera.SensorHandle.ReportAnnotationAsync(m_AnnotationDefinition); |
|
|
|
|
|
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
// ReSharper disable NotAccessedField.Global
|
|
|
|
// ReSharper disable NotAccessedField.Local
|
|
|
|
public struct KeyPointEntry |
|
|
|
struct KeyPointEntry |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The id of the labeled entity
|
|
|
|
/// </summary>
|
|
|
|
public int label_id; |
|
|
|
public uint instance_id; |
|
|
|
public string template_guid; |
|
|
|
|
|
|
[Serializable] |
|
|
|
public struct KeyPoint |
|
|
|
struct KeyPoint |
|
|
|
{ |
|
|
|
public int index; |
|
|
|
public float x; |
|
|
|
|
|
|
// ReSharper restore InconsistentNaming
|
|
|
|
// ReSharper restore NotAccessedField.Global
|
|
|
|
// ReSharper restore NotAccessedField.Local
|
|
|
|
// Converts a coordinate from world space into pixel space
|
|
|
|
Vector3 ConvertToScreenSpace(Vector3 worldLocation) |
|
|
|
{ |
|
|
|
var pt = perceptionCamera.attachedCamera.WorldToScreenPoint(worldLocation); |
|
|
|
|
|
|
|
|
|
|
void ProcessEntity(Labeling labeledEntity) |
|
|
|
{ |
|
|
|
// Cache out the data of a labeled game object the first time we see it, this will
|
|
|
|
// save performance each frame. Also checks to see if a labeled game object can be annotated.
|
|
|
|
if (!m_KnownStatus.ContainsKey(labeledEntity.instanceId)) |
|
|
|
{ |
|
|
|
var cached = new CachedData() |
|
|
|
|
|
|
GUI.color = oldColor; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
protected override void OnVisualize() |
|
|
|
{ |
|
|
|
var jointTexture = activeTemplate.jointTexture; |
|
|
|