浏览代码

Code cleaned up and commented

/keypoint_self_occlusion
Steve Borkman 3 年前
当前提交
dab48757
共有 3 个文件被更改,包括 30 次插入51 次删除
  1. 8
      com.unity.perception/Runtime/GroundTruth/Labelers/CocoKeypointTemplate.asset
  2. 36
      com.unity.perception/Runtime/GroundTruth/Labelers/KeypointLabeler.cs
  3. 37
      com.unity.perception/Runtime/GroundTruth/Labelers/KeypointOcclusionOverrides.cs

8
com.unity.perception/Runtime/GroundTruth/Labelers/CocoKeypointTemplate.asset


associateToRig: 1
rigLabel: 14
color: {r: 1, g: 0.5694697, b: 0, a: 1}
selfOcclusionDistance: 0.15
selfOcclusionDistance: 0.185
- label: right_elbow
associateToRig: 1
rigLabel: 16

associateToRig: 1
rigLabel: 13
color: {r: 0.33125544, g: 1, b: 0, a: 1}
selfOcclusionDistance: 0.15
selfOcclusionDistance: 0.185
- label: left_elbow
associateToRig: 1
rigLabel: 15

associateToRig: 1
rigLabel: 2
color: {r: 0, g: 1, b: 0.36656523, a: 1}
selfOcclusionDistance: 0.2
selfOcclusionDistance: 0.18
- label: right_knee
associateToRig: 1
rigLabel: 4

associateToRig: 1
rigLabel: 1
color: {r: 0, g: 1, b: 1, a: 1}
selfOcclusionDistance: 0.3
selfOcclusionDistance: 0.2
- label: left_knee
associateToRig: 1
rigLabel: 3

36
com.unity.perception/Runtime/GroundTruth/Labelers/KeypointLabeler.cs


/// </summary>
public IdLabelConfig idLabelConfig;
public float visThickness = 6;
public bool drawBones = true;
/// <summary>
/// Controls which objects will have keypoints recorded in the dataset.
/// <see cref="KeypointObjectFilter"/>

{
var bonePosition = bone.position;
// Check to see if
InitKeypoint(bonePosition, cachedData, checkLocationsSlice, i, jointSelfOcclusionDistance);
}
}

/// <inheritdoc/>
protected override void OnVisualize()
{
// TODO - remove this, it is just for debugging
hudPanel.UpdateEntry(this, "frame", m_CurrentFrame.ToString());
// END OF TODO
if (m_KeypointEntriesToReport == null) return;
using (k_OnVisualizeMarker.Auto())
{

foreach (var entry in m_KeypointEntriesToReport)
{
if (drawBones)
foreach (var bone in activeTemplate.skeleton)
foreach (var bone in activeTemplate.skeleton)
{
var joint1 = GetKeypointForJoint(entry, bone.joint1);
var joint2 = GetKeypointForJoint(entry, bone.joint2);
var joint1 = GetKeypointForJoint(entry, bone.joint1);
var joint2 = GetKeypointForJoint(entry, bone.joint2);
if (joint1 != null && joint1.Value.state == 2 && joint2 != null && joint2.Value.state == 2)
{
VisualizationHelper.DrawLine(joint1.Value.x, joint1.Value.y, joint2.Value.x, joint2.Value.y, bone.color, visThickness, skeletonTexture);
}
if (joint1 != null && joint1.Value.state == 2 && joint2 != null && joint2.Value.state == 2)
{
VisualizationHelper.DrawLine(joint1.Value.x, joint1.Value.y, joint2.Value.x, joint2.Value.y, bone.color, 8, skeletonTexture);
#if false
var color = keypoint.state == 1 ? Color.black : activeTemplate.keypoints[keypoint.index].color;
if (keypoint.state > 0)
VisualizationHelper.DrawPoint(keypoint.x, keypoint.y, color, visualizationBaseSize * activeTemplate.keypoints[keypoint.index].selfOcclusionDistance, jointTexture);
#else
VisualizationHelper.DrawPoint(keypoint.x, keypoint.y, activeTemplate.keypoints[keypoint.index].color, visThickness, jointTexture);
#endif
VisualizationHelper.DrawPoint(keypoint.x, keypoint.y, activeTemplate.keypoints[keypoint.index].color, 8, jointTexture);
}
}
}

37
com.unity.perception/Runtime/GroundTruth/Labelers/KeypointOcclusionOverrides.cs


using System;
using System.Collections.Generic;
[Serializable]
public struct KeypointOcclusionOverride
{
public string label;
public float distance;
}
/// <summary>
/// When attached to a model used by the <see cref="KeypointLabeler"/> overrides the distance values
/// for each keypoint defined in <see cref="KeypointTemplate"/> by multiplying them by this overrideDistanceScale
/// scalar. The values in <see cref="KeypointTemplate"/> are generally set for a typical adult model, which makes it
/// so that these values do not meet the needs of models with different body types (i.e. children, different heights, different weights).
/// Changing the value of the scalar will help to get keypoint occlusion working properly for these models. A value of 1.0
/// will use the template values as is.
/// </summary>
public float overrideDistanceScale = 1.0f;
#if false
public Dictionary<string, float> overridesMap { get; private set; }
public List<KeypointOcclusionOverride> keypointOcclusionOverrides;
[Tooltip("Overrides the default occlusion distance values by a scalar. This is necessary for bodies with different body types (i.e. children should be less than one)")]
[SerializeField]
// ReSharper disable once InconsistentNaming, this needs to be human readable in the inspector
float distanceScale = 1.0f;
void Start()
/// <summary>
/// The value to use to scale the values for keypoints distances defined in <see cref="KeypointTemplate"/>
/// </summary>
public float overrideDistanceScale
overridesMap = new Dictionary<string, float>(keypointOcclusionOverrides.Count);
foreach (var kpOverride in keypointOcclusionOverrides)
{
overridesMap[kpOverride.label] = kpOverride.distance;
}
get => distanceScale;
private set => distanceScale = value;
#endif
}
}
正在加载...
取消
保存