浏览代码

Fixing remainder of tests.

/keypoint_self_occlusion
Jon Hogins 4 年前
当前提交
0f05f1ed
共有 2 个文件被更改,包括 32 次插入13 次删除
  1. 9
      com.unity.perception/Runtime/GroundTruth/Labelers/KeypointLabeler.cs
  2. 36
      com.unity.perception/Tests/Runtime/GroundTruthTests/KeypointGroundTruthTests.cs

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


if (keypointEntries.Count != 0)
DoDepthCheck(scriptableRenderContext, keypointEntries, positions);
else
{
var frameKeypointData = m_FrameKeypointData[m_CurrentFrame];
frameKeypointData.isDepthCheckComplete = true;
m_FrameKeypointData[m_CurrentFrame] = frameKeypointData;
}
positions.Dispose();
}

}
//TODO: move this code
uint2 dimensions = new uint2((uint)perceptionCamera.attachedCamera.pixelWidth, (uint)perceptionCamera.attachedCamera.pixelHeight);
var pixelLocation = PixelLocationFromScreenPoint(keypoints[idx]);
if (pixelLocation.x < 0 || pixelLocation.y < 0)
{

positions[idx] = new float3((uint)pixelLocation.x, (uint)pixelLocation.y, loc.z);
positions[idx] = new float3(pixelLocation.x + .5f, pixelLocation.y + .5f, loc.z);
}
string GetPose(Animator animator)

36
com.unity.perception/Tests/Runtime/GroundTruthTests/KeypointGroundTruthTests.cs


Assert.AreEqual(t.keypoints[5].y, t.keypoints[6].y);
for (var i = 0; i < 9; i++) Assert.AreEqual(i, t.keypoints[i].index);
for (var i = 0; i < 8; i++) Assert.AreEqual(2, t.keypoints[i].state);
for (var i = 0; i < 4; i++) Assert.AreEqual(2, t.keypoints[i].state);
for (var i = 4; i < 8; i++) Assert.AreEqual(1, t.keypoints[i].state);
Assert.Zero(t.keypoints[8].state);
Assert.Zero(t.keypoints[8].x);
Assert.Zero(t.keypoints[8].y);

Assert.AreEqual(t.keypoints[5].y, t.keypoints[6].y);
for (var i = 0; i < 9; i++) Assert.AreEqual(i, t.keypoints[i].index);
for (var i = 0; i < 8; i++) Assert.AreEqual(2, t.keypoints[i].state);
for (var i = 0; i < 4; i++) Assert.AreEqual(2, t.keypoints[i].state);
for (var i = 4; i < 8; i++) Assert.AreEqual(1, t.keypoints[i].state);
Assert.Zero(t.keypoints[8].state);
Assert.Zero(t.keypoints[8].x);
Assert.Zero(t.keypoints[8].y);

cam.GetComponent<PerceptionCamera>().showVisualizations = false;
var cube = TestHelper.CreateLabeledCube(scale: 6, z: 8);
SetupCubeJoint(cube, template, "Center", 0, 0, 0);
SetupCubeJoint(cube, template, "Center", 0, 0, -.5f);
cube.SetActive(true);
cam.SetActive(true);

var testCase2 = incoming[1];
Assert.AreEqual(1, testCase2.Count);
var t2 = testCase2.First();
Assert.AreEqual(445, t2.keypoints[0].x, 1);
Assert.AreEqual(416, t2.keypoints[0].x, 1);
Assert.AreEqual(768 / 2, t2.keypoints[0].y);
}

Assert.AreEqual(t.keypoints[5].y, t.keypoints[6].y);
for (var i = 0; i < 9; i++) Assert.AreEqual(i, t.keypoints[i].index);
for (var i = 0; i < 8; i++) Assert.AreEqual(2, t.keypoints[i].state);
for (var i = 0; i < 4; i++) Assert.AreEqual(2, t.keypoints[i].state);
for (var i = 4; i < 8; i++) Assert.AreEqual(1, t.keypoints[i].state);
Assert.Zero(t.keypoints[8].state);
Assert.Zero(t.keypoints[8].x);
Assert.Zero(t.keypoints[8].y);

Assert.AreEqual(2, t.keypoints[0].state);
Assert.AreEqual(2, t.keypoints[1].state);
Assert.AreEqual(2, t.keypoints[4].state);
Assert.AreEqual(2, t.keypoints[5].state);
Assert.AreEqual(1, t.keypoints[4].state);
Assert.AreEqual(1, t.keypoints[5].state);
Assert.AreEqual(1, t.keypoints[2].state);
Assert.AreEqual(1, t.keypoints[3].state);

var labeling = cube.AddComponent<Labeling>();
labeling.labels.Add("label");
SetupCubeJoint(cube, template, "Center",0f, 0f, 0f);
SetupCubeJoint(cube, template, "Center",0f, 0f, -.5f);
cube.SetActive(true);
cam.SetActive(true);

Assert.AreEqual(2, t.keypoints[8].state);
}
static IEnumerable<(float scale, bool expectObject, int expectedState, KeypointObjectFilter keypointFilter, Vector2 expectedTopLeft, Vector2 expectedBottomRight)> Keypoint_OnBox_ReportsProperCoordinates_TestCases()
static IEnumerable<(float scale, bool expectObject, int expectedStateFront, int expectedStateBack, KeypointObjectFilter keypointFilter, Vector2 expectedTopLeft, Vector2 expectedBottomRight)> Keypoint_OnBox_ReportsProperCoordinates_TestCases()
1,
KeypointObjectFilter.Visible,
new Vector2(0, 0),
new Vector2(1023.99f, 1023.99f));

0,
0,
KeypointObjectFilter.Visible,
new Vector2(0, 0),

true,
0,
0,
KeypointObjectFilter.Visible,
new Vector2(0, 0),
new Vector2(0, 0));

1,
1,
KeypointObjectFilter.Visible,
new Vector2(512, 512),

true,
1,
1,
KeypointObjectFilter.VisibleAndOccluded,
new Vector2(512, 512),
new Vector2(512, 512));

[ValueSource(nameof(Keypoint_OnBox_ReportsProperCoordinates_TestCases))]
(float scale, bool expectObject, int expectedState, KeypointObjectFilter keypointFilter, Vector2 expectedTopLeft, Vector2 expectedBottomRight) args)
(float scale, bool expectObject, int expectedStateFront, int expectedStateBack, KeypointObjectFilter keypointFilter, Vector2 expectedTopLeft, Vector2 expectedBottomRight) args)
{
var incoming = new List<List<KeypointLabeler.KeypointEntry>>();
var template = CreateTestTemplate(Guid.NewGuid(), "TestTemplate");

AddTestObjectForCleanup(cam);
AddTestObjectForCleanup(cube);
//for (int i = 0; i < 10000; i++)
yield return null;
//force all async readbacks to complete

Assert.AreEqual(template.templateID.ToString(), t.template_guid);
Assert.AreEqual(9, t.keypoints.Length);
CollectionAssert.AreEqual(Enumerable.Repeat(args.expectedState, 8), t.keypoints.Take(8).Select(k => k.state), "State mismatch");
CollectionAssert.AreEqual(Enumerable.Repeat(args.expectedStateFront, 4),
t.keypoints.Take(4).Select(k => k.state),
"State mismatch on front");
CollectionAssert.AreEqual(Enumerable.Repeat(args.expectedStateBack, 4),
t.keypoints.Skip(4).Take(4).Select(k => k.state),
"State mismatch on front");
Assert.AreEqual(args.expectedTopLeft.x, t.keypoints[0].x, k_Delta);
Assert.AreEqual(args.expectedBottomRight.y, t.keypoints[0].y, k_Delta);

正在加载...
取消
保存