浏览代码

Fixed some issues with xmldoc (#122)

/main
GitHub 4 年前
当前提交
aba53584
共有 2 个文件被更改,包括 50 次插入36 次删除
  1. 4
      com.unity.perception/Runtime/GroundTruth/InstanceIdToColorMapping.cs
  2. 82
      com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBox3DLabeler.cs

4
com.unity.perception/Runtime/GroundTruth/InstanceIdToColorMapping.cs


/// Retrieve the ID associated with the passed in color. If the passed in color is black this service will return 0.
/// </summary>
/// <param name="color">The color to map to an ID.</param>
/// <returns>This value will be updated with the ID for the passed in color.</returns>
/// <returns>The ID for the passed in color.</returns>
/// <<exception cref="InvalidOperationException">Thrown if the passed in color cannot be mapped to an ID in the alpha 255 range<see cref="maxId"/></exception>
/// <exception cref="InvalidOperationException">Thrown if the passed in color cannot be mapped to an ID in the alpha 255 range<see cref="maxId"/></exception>
public static uint GetInstanceIdFromColor(Color32 color)
{
var id = GetIdForColor(GetPackedColorFromColor(color));

82
com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBox3DLabeler.cs


public class BoundingBox3DLabeler : CameraLabeler
{
EntityQuery m_EntityQuery;
///<inheritdoc/>
public override string description
{

/// <summary>
/// Each 3D bounding box data record maps a tuple of (instance, label) to translation, size and rotation that draws a 3D bounding box,
/// as well as velocity and acceleration (optional) of the 3D bounding box. All location data is given with respect to the sensor coordinate system.
///
/// bounding_box_3d
/// label_id (int): Integer identifier of the label
/// label_name (str): String identifier of the label
/// instance_id (str): UUID of the instance.
/// translation (float, float, float): 3d bounding box's center location in meters as center_x, center_y, center_z with respect to global coordinate system.
/// size (float, float, float): 3d bounding box size in meters as width, length, height.
/// rotation (float, float, float, float): 3d bounding box orientation as quaternion: w, x, y, z.
/// velocity (float, float, float) [optional]: 3d bounding box velocity in meters per second as v_x, v_y, v_z.
/// acceleration (float, float, float) [optional]: 3d bounding box acceleration in meters per second^2 as a_x, a_y, a_z.
/// </summary>
/// <remarks>
/// Currently not supporting exporting velocity and acceleration. Both values will be null.

public struct BoxData
{
/// <summary>
/// Integer identifier of the label
/// </summary>
/// <summary>
/// String identifier of the label
/// </summary>
/// <summary>
/// UUID of the instance
/// </summary>
/// <summary>
/// 3d bounding box's center location in meters as center_x, center_y, center_z with respect to global coordinate system
/// </summary>
/// <summary>
/// 3d bounding box size in meters as width, length, height
/// </summary>
/// <summary>
/// 3d bounding box orientation as quaternion: w, x, y, z
/// </summary>
/// <summary>
/// [optional]: 3d bounding box velocity in meters per second as v_x, v_y, v_z
/// </summary>
/// <summary>
/// [optional]: 3d bounding box acceleration in meters per second^2 as a_x, a_y, a_z
/// </summary>
int m_CurrentFrame;
/// <inheritdoc/>

"Bounding box for each labeled object visible to the sensor", id: new Guid(annotationId));
perceptionCamera.RenderedObjectInfosCalculated += OnRenderObjectInfosCalculated;
m_AsyncAnnotations = new Dictionary<int, AsyncAnnotation>();
m_BoundingBoxValues = new Dictionary<int, Dictionary<uint, BoxData>>();
m_ToReport = new List<BoxData>();

right = rotation * right;
up = rotation * up;
forward = rotation * forward;
corners[3] = corners[0] + doubleRight;
corners[3] = corners[0] + doubleRight;
for (var i = 0; i < 4; i++)
{
corners[i + 4] = corners[i] + doubleForward;

protected override void OnBeginRendering()
{
m_CurrentFrame = Time.frameCount;
foreach (var entity in entities)
{
ProcessEntity(entityManager.GetComponentObject<Labeling>(entity));

if (!m_BoundingBoxValues.TryGetValue(frameCount, out var boxes))
return;
m_AsyncAnnotations.Remove(frameCount);
m_BoundingBoxValues.Remove(frameCount);

for (var i = 0; i < renderedObjectInfos.Length; i++)
{
var objectInfo = renderedObjectInfos[i];

m_ToReport.Add(box);
}
}
BoundingBoxComputed?.Invoke(frameCount, m_ToReport);
asyncAnnotation.ReportValues(m_ToReport);
}

if (idLabelConfig.TryGetLabelEntryFromInstanceId(labeledEntity.instanceId, out var labelEntry))
{
var entityGameObject = labeledEntity.gameObject;
var labelTransform = entityGameObject.transform;
var cameraTransform = perceptionCamera.transform;
var combinedBounds = new Bounds(Vector3.zero, Vector3.zero);

// they are axis-aligned with respect to the current component's coordinate space. This, in theory
// could still provide non-ideal fitting bounds (if the model is made strangely, but garbage in; garbage out)
var meshBounds = mesh.mesh.bounds;
// Apply the transformations on this object until we reach the labeled transform
while (currentTransform != labelTransform)
{

// need to calculate all 8 corners of the bounds and combine them with the current combined
// bounds
var corners = GetBoxCorners(transformedBounds, transformedRotation);
// If this is the first time, create a new bounds struct
if (areBoundsUnset)
{

combinedBounds.Encapsulate(c2);
}
}
// Convert the combined bounds into world space
combinedBounds.center = labelTransform.TransformPoint(combinedBounds.center);
combinedBounds.extents = Vector3.Scale(combinedBounds.extents, labelTransform.localScale);

cameraCenter = Vector3.Scale(cameraTransform.localScale, cameraCenter);
m_BoundingBoxValues[m_CurrentFrame][labeledEntity.instanceId] = converted;
}
}

正在加载...
取消
保存