浏览代码

Fix for instance segmentation bug (#131)

* Fix for instance segmentation bug

Removed check for object ID 255 to be considered an invalid ID, it shouldn't have been, the logic already supported that ID. Added tests to verify result.

* Updated changelog
/main
GitHub 4 年前
当前提交
4ade45f0
共有 3 个文件被更改,包括 25 次插入2 次删除
  1. 2
      com.unity.perception/CHANGELOG.md
  2. 2
      com.unity.perception/Runtime/GroundTruth/InstanceIdToColorMapping.cs
  3. 23
      com.unity.perception/Tests/Runtime/GroundTruthTests/InstanceIdToColorMappingTests.cs

2
com.unity.perception/CHANGELOG.md


### Fixed
Fixed a bug in instance segmentation labeler that erroneously logged that object ID 255 was not supported
## [0.6.0-preview.1] - 2020-12-03
### Added

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


static uint GetColorForId(uint id)
{
if (id > maxId || id == 0 || id == k_InvalidPackedColor) return k_InvalidPackedColor;
if (id > maxId || id == 0) return k_InvalidPackedColor;
if (id <= k_HslCount)
{

23
com.unity.perception/Tests/Runtime/GroundTruthTests/InstanceIdToColorMappingTests.cs


}
[Test]
public void InstanceIdToColorMappingTests_GetCorrectValuesFor255()
{
var expectedColor = new Color(0, 0, 191, 254);
Assert.IsTrue(InstanceIdToColorMapping.TryGetColorFromInstanceId(255u, out var color));
Assert.AreEqual(color.r, expectedColor.r);
Assert.AreEqual(color.g, expectedColor.g);
Assert.AreEqual(color.b, expectedColor.b);
Assert.AreEqual(color.a, expectedColor.a);
Assert.IsTrue(InstanceIdToColorMapping.TryGetInstanceIdFromColor(color, out var id2));
Assert.AreEqual(255u, id2);
color = InstanceIdToColorMapping.GetColorFromInstanceId(255u);
Assert.AreEqual(color.r, expectedColor.r);
Assert.AreEqual(color.g, expectedColor.g);
Assert.AreEqual(color.b, expectedColor.b);
Assert.AreEqual(color.a, expectedColor.a);
id2 = InstanceIdToColorMapping.GetInstanceIdFromColor(color);
Assert.AreEqual(255u, id2);
}
[Test]
[TestCase(255u)]
public void InstanceIdToColorMappingTests_GetBlackForId(uint id)
{
Assert.IsFalse(InstanceIdToColorMapping.TryGetColorFromInstanceId(id, out var color));

正在加载...
取消
保存