浏览代码

Merge branch 'coco_export' into coco_perception_output_hybrid

/coco_perception_output_hybrid
Steve Borkman 3 年前
当前提交
1d945f86
共有 3 个文件被更改,包括 52 次插入30 次删除
  1. 5
      com.unity.perception/Runtime/GroundTruth/Exporters/Coco/AnnotationHandler.cs
  2. 20
      com.unity.perception/Runtime/GroundTruth/Exporters/Coco/CocoExporter.cs
  3. 57
      com.unity.perception/Runtime/GroundTruth/Labelers/KeypointLabeler.cs

5
com.unity.perception/Runtime/GroundTruth/Exporters/Coco/AnnotationHandler.cs


using System;
using System;
namespace UnityEngine.Perception.GroundTruth.Exporters.Coco
{

return new CocoTypes.KeypointCategory
{
id = keypointJson.label_id,
name = keypointJson.label_name,
supercategory = keypointJson.label_name,
keypoints = keypoints,
skeleton = skeleton
};

20
com.unity.perception/Runtime/GroundTruth/Exporters/Coco/CocoExporter.cs


if (annotationId.ToString() == KeypointLabeler.annotationId)
{
m_ReportingKeypoints = true;
if (values[0] is KeypointLabeler.KeypointJson keypointJson)
var categories = new CocoTypes.KeypointCategory[values.Length];
var i = 0;
foreach (var value in values)
m_KeypointCategories = new CocoTypes.KeypointCategories
if (value is KeypointLabeler.KeypointJson keypointJson)
categories = new []
{
AnnotationHandler.ToKeypointCategory(keypointJson)
}
};
categories[i++] = AnnotationHandler.ToKeypointCategory(keypointJson);
}
m_KeypointCategories = new CocoTypes.KeypointCategories
{
categories = categories
};
static string versionEntry = "0.0.1";
static string descriptionEntry = "Description of dataset";

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


if (idLabelConfig == null)
throw new InvalidOperationException($"{nameof(KeypointLabeler)}'s idLabelConfig field must be assigned");
m_AnnotationDefinition = DatasetCapture.RegisterAnnotationDefinition("keypoints", new []{TemplateToJson(activeTemplate)},
m_AnnotationDefinition = DatasetCapture.RegisterAnnotationDefinition("keypoints", TemplateToJson(activeTemplate, idLabelConfig),
"pixel coordinates of keypoints in a model, along with skeletal connectivity data", id: new Guid(annotationId));
// Texture to use in case the template does not contain a texture for the joints or the skeletal connections

var cachedKeypointEntry = cachedData.keypoints;
var keypointEntry = new KeypointEntry()
{
frame = cachedKeypointEntry.frame,
instance_id = cachedKeypointEntry.instance_id,
keypoints = cachedKeypointEntry.keypoints.ToArray(),
label_id = cachedKeypointEntry.label_id,

[Serializable]
public struct KeypointJson
{
public int label_id;
public string label_name;
public string template_id;
public string template_name;
public JointJson[] key_points;

// ReSharper restore NotAccessedField.Local
KeypointJson TemplateToJson(KeypointTemplate input)
KeypointJson[] TemplateToJson(KeypointTemplate input, IdLabelConfig labelConfig)
var json = new KeypointJson();
json.template_id = input.templateID;
json.template_name = input.templateName;
json.key_points = new JointJson[input.keypoints.Length];
json.skeleton = new SkeletonJson[input.skeleton.Length];
var jsons = new KeypointJson[labelConfig.labelEntries.Count];
var idx = 0;
for (var i = 0; i < input.keypoints.Length; i++)
foreach (var cfg in labelConfig.labelEntries)
json.key_points[i] = new JointJson
var json = new KeypointJson();
json.label_id = cfg.id;
json.label_name = cfg.label;
json.template_id = input.templateID;
json.template_name = input.templateName;
json.key_points = new JointJson[input.keypoints.Length];
json.skeleton = new SkeletonJson[input.skeleton.Length];
for (var i = 0; i < input.keypoints.Length; i++)
label = input.keypoints[i].label,
index = i,
color = input.keypoints[i].color
};
}
json.key_points[i] = new JointJson
{
label = input.keypoints[i].label,
index = i,
color = input.keypoints[i].color
};
}
for (var i = 0; i < input.skeleton.Length; i++)
{
json.skeleton[i] = new SkeletonJson()
for (var i = 0; i < input.skeleton.Length; i++)
joint1 = input.skeleton[i].joint1,
joint2 = input.skeleton[i].joint2,
color = input.skeleton[i].color
};
json.skeleton[i] = new SkeletonJson()
{
joint1 = input.skeleton[i].joint1,
joint2 = input.skeleton[i].joint2,
color = input.skeleton[i].color
};
}
jsons[idx++] = json;
return json;
return jsons;
}
}
}
正在加载...
取消
保存