浏览代码

Fixing issue where the label ids were not being reported properly in the dataset.

/fix_label_id_report
Jon Hogins 4 年前
当前提交
5738273a
共有 2 个文件被更改,包括 17 次插入15 次删除
  1. 20
      com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
  2. 12
      com.unity.perception/Runtime/GroundTruth/RenderedObjectInfoGenerator.cs

20
com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs


for (var i = 0; i < renderedObjectInfos.Length; i++)
{
var objectInfo = renderedObjectInfos[i];
if (!TryGetLabelIdFromInstanceId(objectInfo.instanceId, out var labelId))
if (!TryGetLabelEntryFromInstanceId(objectInfo.instanceId, out var labelEntry))
label_id = labelId,
label_id = labelEntry.id,
instance_id = objectInfo.instanceId,
visible_pixels = objectInfo.pixelCount
};

for (var i = 0; i < renderedObjectInfos.Length; i++)
{
var objectInfo = renderedObjectInfos[i];
if (!TryGetLabelIdFromInstanceId(objectInfo.instanceId, out var labelId))
if (!TryGetLabelEntryFromInstanceId(objectInfo.instanceId, out var labelEntry))
label_id = labelId,
label_name = labelingConfigurations[labelId].label,
label_id = labelEntry.id,
label_name = labelEntry.label,
instance_id = objectInfo.instanceId,
x = objectInfo.boundingBox.x,
y = objectInfo.boundingBox.y,

/// Returns the class ID for the given instance ID resolved by <see cref="LabelingConfiguration"/>. Only valid when bounding boxes are being computed.
/// </summary>
/// <param name="instanceId">The instanceId of the object</param>
/// <param name="labelId">When this method returns, contains the labelId associated with the given instanceId, if one exists. -1 otherwise.</param>
/// <returns>True if a valid labelId was found for the given instanceId.</returns>
/// <param name="labelEntry">When this method returns, contains the LabelEntry associated with the given instanceId if one exists. default otherwise.</param>
/// <returns>True if a valid LabelEntry was found for the given instanceId.</returns>
public bool TryGetLabelIdFromInstanceId(int instanceId, out int labelId)
public bool TryGetLabelEntryFromInstanceId(int instanceId, out LabelEntry labelEntry)
throw new InvalidOperationException($"{nameof(TryGetLabelIdFromInstanceId)} can only be used when bounding box capture is enabled");
return m_RenderedObjectInfoGenerator.TryGetLabelIdFromInstanceId(instanceId, out labelId);
throw new InvalidOperationException($"{nameof(TryGetLabelEntryFromInstanceId)} can only be used when bounding box capture is enabled");
return m_RenderedObjectInfoGenerator.TryGetLabelEntryFromInstanceId(instanceId, out labelEntry);
}
void OnObjectCountsReceived(NativeSlice<uint> counts, IReadOnlyList<LabelEntry> entries, int frameCount)

12
com.unity.perception/Runtime/GroundTruth/RenderedObjectInfoGenerator.cs


using Unity.Jobs;
using Unity.Mathematics;
using Unity.Profiling;
using UnityEngine.UIElements;
namespace UnityEngine.Perception.GroundTruth
{

/// <inheritdoc/>
public void SetupMaterialProperties(MaterialPropertyBlock mpb, MeshRenderer meshRenderer, Labeling labeling, uint instanceId)
{
if (m_LabelingConfiguration.TryGetMatchingConfigurationEntry(labeling, out var entry, out var index))
if (m_LabelingConfiguration.TryGetMatchingConfigurationEntry(labeling, out _, out var index))
{
if (m_InstanceIdToLabelEntryIndexLookup.Length <= instanceId)
{

/// Attempts to find the label id for the given instance id using the LabelingConfiguration passed into the constructor.
/// </summary>
/// <param name="instanceId">The instanceId of the object for which the labelId should be found</param>
/// <param name="labelId">The labelId of the object. -1 if not found</param>
/// <param name="labelEntry">The LabelEntry associated with the object. default if not found</param>
public bool TryGetLabelIdFromInstanceId(int instanceId, out int labelId)
public bool TryGetLabelEntryFromInstanceId(int instanceId, out LabelEntry labelEntry)
labelId = -1;
labelEntry = default;
labelId = m_InstanceIdToLabelEntryIndexLookup[instanceId];
var labelEntryIndex = m_InstanceIdToLabelEntryIndexLookup[instanceId];
labelEntry = m_LabelingConfiguration.LabelEntries[labelEntryIndex];
return true;
}

正在加载...
取消
保存