浏览代码

Tests for self-occlusion scalar value

/keypoint_self_occlusion
Steve Borkman 3 年前
当前提交
9e858d67
共有 3 个文件被更改,包括 96 次插入2 次删除
  1. 2
      com.unity.perception/Runtime/GroundTruth/Labelers/KeypointLabeler.cs
  2. 2
      com.unity.perception/Runtime/GroundTruth/Labelers/KeypointOcclusionOverrides.cs
  3. 94
      com.unity.perception/Tests/Runtime/GroundTruthTests/KeypointGroundTruthTests.cs

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


else
resolvedSelfOcclusionDistance = activeTemplate.keypoints[templateIdx].selfOcclusionDistance;
resolvedSelfOcclusionDistance *= cachedData.occlusionScalar;
var jointSelfOcclusionDistance = JointSelfOcclusionDistance(joint.transform, jointPosition, cameraPosition, cameraforward, resolvedSelfOcclusionDistance);
InitKeypoint(jointPosition, cachedData, checkLocationsSlice, templateIdx, jointSelfOcclusionDistance);

2
com.unity.perception/Runtime/GroundTruth/Labelers/KeypointOcclusionOverrides.cs


public float overrideDistanceScale
{
get => distanceScale;
private set => distanceScale = value;
internal set => distanceScale = value;
}
}
}

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


using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Perception.GroundTruth;
using UnityEngine.SceneManagement;

cube.transform.localScale = args.objectScale;
cube.transform.localRotation = args.rotation;
SetupCubeJoint(cube, "Center", args.pointLocalPosition.x, args.pointLocalPosition.y, args.pointLocalPosition.z, args.checkDistance);
cube.SetActive(true);
cam.SetActive(true);
AddTestObjectForCleanup(cam);
AddTestObjectForCleanup(cube);
//for (int i = 0; i < 10000; i++)
yield return null;
//force all async readbacks to complete
DestroyTestObject(cam);
texture.Release();
var testCase = incoming.Last();
Assert.AreEqual(1, testCase.Count);
var t = testCase.First();
Assert.AreEqual(args.expectOccluded ? 1 : 2, t.keypoints[8].state);
}
public static IEnumerable<(Vector3 objectScale, Quaternion rotation, float checkDistance, Vector3 pointLocalPosition, float overrideScalar, bool expectOccluded)>
Keypoint_OnCorner_OfRotatedScaledBox_RespectsModelOverrideThreshold_TestCases()
{
yield return (
new Vector3(90f, 90f, 10f),
Quaternion.identity,
.11f,
new Vector3(-.4f, -.4f, -.4f),
1f,
false);
yield return (
new Vector3(90f, 90f, 1f),
Quaternion.identity,
.5f,
new Vector3(-.4f, -.4f, .4f),
.5f,
true);
yield return (
new Vector3(90, 90, 9),
Quaternion.AngleAxis(90, Vector3.right),
.11f,
new Vector3(-.4f, -.4f, -.4f),
1f,
false);
yield return (
new Vector3(90, 90, 90),
Quaternion.AngleAxis(90, Vector3.right),
.11f,
new Vector3(-.4f, -.4f, -.4f),
.5f,
true);
yield return (
new Vector3(90, 90, 90),
Quaternion.AngleAxis(90, Vector3.right),
.055f,
new Vector3(-.4f, -.4f, -.4f),
1f,
true);
yield return (
new Vector3(90, 90, 90),
Quaternion.AngleAxis(90, Vector3.right),
.055f,
new Vector3(-.4f, -.4f, -.4f),
2f,
false);
}
[UnityTest]
public IEnumerator Keypoint_OnCorner_OfRotatedScaledBox_RespectsModelOverrideThreshold(
[ValueSource(nameof(Keypoint_OnCorner_OfRotatedScaledBox_RespectsModelOverrideThreshold_TestCases))]
(Vector3 objectScale, Quaternion rotation, float checkDistance, Vector3 pointLocalPosition, float overrideScalar, bool expectOccluded) args)
{
var incoming = new List<List<KeypointLabeler.KeypointEntry>>();
var labelerSelfOcclusionDistance = 0.5f;
var template = CreateTestTemplate(Guid.NewGuid(), "TestTemplate", labelerSelfOcclusionDistance);
var frameSize = 1024;
var texture = new RenderTexture(frameSize, frameSize, 16);
var cam = SetupCamera(SetUpLabelConfig(), template, (frame, data) =>
{
incoming.Add(data);
}, texture);
var camComponent = cam.GetComponent<Camera>();
camComponent.orthographic = true;
camComponent.orthographicSize = 100f;
cam.transform.localPosition = new Vector3(0, 0, -95f);
var cube = TestHelper.CreateLabeledCube(scale: 1f);
cube.transform.localScale = args.objectScale;
cube.transform.localRotation = args.rotation;
SetupCubeJoint(cube, "Center", args.pointLocalPosition.x, args.pointLocalPosition.y, args.pointLocalPosition.z, args.checkDistance);
var kpOc = cube.AddComponent<KeypointOcclusionOverrides>();
kpOc.overrideDistanceScale = args.overrideScalar;
cube.SetActive(true);
cam.SetActive(true);

正在加载...
取消
保存