浏览代码

Merge branch 'aisv647_visualizations' of https://github.com/Unity-Technologies/com.unity.perception into aisv647_visualizations

/aisv647_visualizations
Jon Hogins 4 年前
当前提交
9adacea8
共有 1 个文件被更改,包括 14 次插入3 次删除
  1. 17
      com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBoxLabeler.cs

17
com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBoxLabeler.cs


private GameObject visualizationHolder = null;
private Vector2 originalScreenSize = Vector2.zero;
/// <summary>
/// Creates a new BoundingBox2DLabeler. Be sure to assign <see cref="idLabelConfig"/> before adding to a <see cref="PerceptionCamera"/>.
/// </summary>

perceptionCamera.RenderedObjectInfosCalculated += OnRenderedObjectInfosCalculated;
visualizationEnabled = supportsVisualization;
// Record the original screen size. The screen size can change during play, and the visual bounding
// boxes need to be scaled appropriately
originalScreenSize = new Vector2(Screen.width, Screen.height);
}
/// <inheritdoc/>

{
ClearObjectPool(m_BoundingBoxValues.Length);
// The player screen can be dynamically resized during play, need to
// scale the bounding boxes appropriately from the original screen size
float screenRatioWidth = Screen.width / originalScreenSize.x;
float screenRatioHeight = Screen.height / originalScreenSize.y;
for (int i = 0; i < m_BoundingBoxValues.Length; i++)
{
var boxVal = m_BoundingBoxValues[i];

var rectTrans = objectPool[i].transform as RectTransform;
rectTrans.anchoredPosition = new Vector2(boxVal.x, -boxVal.y);
rectTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, boxVal.width);
rectTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, boxVal.height);
rectTrans.anchoredPosition = new Vector2(boxVal.x * screenRatioWidth, -boxVal.y * screenRatioHeight);
rectTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, boxVal.width * screenRatioWidth);
rectTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, boxVal.height * screenRatioHeight);
}
}

正在加载...
取消
保存