|
|
|
|
|
|
perceptionCamera.captureRgbImages = false; |
|
|
|
var keyPointLabeler = new KeypointLabeler(config, template); |
|
|
|
keyPointLabeler.objectFilter = keypointObjectFilter; |
|
|
|
keyPointLabeler.distanceThreshold = defaultSelfOcclusionDistance; |
|
|
|
keyPointLabeler.selfOcclusionDistance = defaultSelfOcclusionDistance; |
|
|
|
if (computeListener != null) |
|
|
|
keyPointLabeler.KeypointsComputed += computeListener; |
|
|
|
|
|
|
|
|
|
|
return cfg; |
|
|
|
} |
|
|
|
|
|
|
|
static void SetupCubeJoint(GameObject cube, KeypointTemplate template, string label, float x, float y, float z) |
|
|
|
static void SetupCubeJoint(GameObject cube, string label, float x, float y, float z, float? selfOcclusionDistance = null) |
|
|
|
{ |
|
|
|
var joint = new GameObject(); |
|
|
|
joint.transform.parent = cube.transform; |
|
|
|
|
|
|
if (selfOcclusionDistance.HasValue) |
|
|
|
{ |
|
|
|
jointLabel.selfOcclusionDistanceSource = SelfOcclusionDistanceSource.JointLabel; |
|
|
|
jointLabel.selfOcclusionDistance = selfOcclusionDistance.Value; |
|
|
|
} |
|
|
|
else |
|
|
|
jointLabel.selfOcclusionDistanceSource = SelfOcclusionDistanceSource.KeypointLabeler; |
|
|
|
SetupCubeJoint(cube, template, "FrontLowerLeft", -dim, -dim, -dim); |
|
|
|
SetupCubeJoint(cube, template, "FrontUpperLeft", -dim, dim, -dim); |
|
|
|
SetupCubeJoint(cube, template, "FrontUpperRight", dim, dim, -dim); |
|
|
|
SetupCubeJoint(cube, template, "FrontLowerRight", dim, -dim, -dim); |
|
|
|
SetupCubeJoint(cube, template, "BackLowerLeft", -dim, -dim, dim); |
|
|
|
SetupCubeJoint(cube, template, "BackUpperLeft", -dim, dim, dim); |
|
|
|
SetupCubeJoint(cube, template, "BackUpperRight", dim, dim, dim); |
|
|
|
SetupCubeJoint(cube, template, "BackLowerRight", dim, -dim, dim); |
|
|
|
SetupCubeJoint(cube, "FrontLowerLeft", -dim, -dim, -dim); |
|
|
|
SetupCubeJoint(cube, "FrontUpperLeft", -dim, dim, -dim); |
|
|
|
SetupCubeJoint(cube, "FrontUpperRight", dim, dim, -dim); |
|
|
|
SetupCubeJoint(cube, "FrontLowerRight", dim, -dim, -dim); |
|
|
|
SetupCubeJoint(cube, "BackLowerLeft", -dim, -dim, dim); |
|
|
|
SetupCubeJoint(cube, "BackUpperLeft", -dim, dim, dim); |
|
|
|
SetupCubeJoint(cube, "BackUpperRight", dim, dim, dim); |
|
|
|
SetupCubeJoint(cube, "BackLowerRight", dim, -dim, dim); |
|
|
|
} |
|
|
|
|
|
|
|
[UnityTest] |
|
|
|
|
|
|
cam.GetComponent<PerceptionCamera>().showVisualizations = false; |
|
|
|
|
|
|
|
var cube = TestHelper.CreateLabeledCube(scale: 6, z: 8); |
|
|
|
SetupCubeJoint(cube, template, "Center", 0, 0, -.5f); |
|
|
|
SetupCubeJoint(cube, "Center", 0, 0, -.5f); |
|
|
|
|
|
|
|
cube.SetActive(true); |
|
|
|
cam.SetActive(true); |
|
|
|
|
|
|
var labeling = cube.AddComponent<Labeling>(); |
|
|
|
labeling.labels.Add("label"); |
|
|
|
|
|
|
|
SetupCubeJoint(cube, template, "Center",0f, 0f, -.5f); |
|
|
|
SetupCubeJoint(cube, "Center",0f, 0f, -.5f); |
|
|
|
|
|
|
|
cube.SetActive(true); |
|
|
|
cam.SetActive(true); |
|
|
|
|
|
|
[Values(CheckDistanceType.Global, CheckDistanceType.JointLabel)] CheckDistanceType checkDistanceType, |
|
|
|
[Values(ProjectionKind.Orthographic, ProjectionKind.Projection)] ProjectionKind projectionKind) |
|
|
|
{ |
|
|
|
if (checkDistanceType == CheckDistanceType.JointLabel) |
|
|
|
Assert.Inconclusive("Not yet implemented"); |
|
|
|
|
|
|
|
var defaultSelfOcclusionDistance = |
|
|
|
checkDistanceType == CheckDistanceType.Global ? args.checkDistance : 0.15f; |
|
|
|
var labelerSelfOcclusionDistance = |
|
|
|
checkDistanceType == CheckDistanceType.Global ? args.checkDistance : 0.5f; |
|
|
|
}, texture, defaultSelfOcclusionDistance: defaultSelfOcclusionDistance); |
|
|
|
}, texture, defaultSelfOcclusionDistance: labelerSelfOcclusionDistance); |
|
|
|
var camComponent = cam.GetComponent<Camera>(); |
|
|
|
camComponent.fieldOfView = args.cameraFieldOfView; |
|
|
|
camComponent.farClipPlane = 100f; |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var cube = TestHelper.CreateLabeledCube(scale: 1f, x: args.origin.x, y: args.origin.y, z: args.origin.z); |
|
|
|
SetupCubeJoint(cube, template, "Center", 0f, 0f, -.5f + args.pointDistance); |
|
|
|
var localSelfOcclusionDistance = checkDistanceType == CheckDistanceType.JointLabel ? (float?)args.checkDistance : null; |
|
|
|
SetupCubeJoint(cube, "Center", 0f, 0f, -.5f + args.pointDistance, localSelfOcclusionDistance); |
|
|
|
|
|
|
|
cube.SetActive(true); |
|
|
|
cam.SetActive(true); |
|
|
|