Esempio n. 1
0
        static GameObject SetupCamera(IdLabelConfig config, KeypointTemplate template, Action <int, List <KeypointLabeler.KeypointEntry> > computeListener, RenderTexture renderTexture = null)
        {
            var cameraObject = new GameObject();

            cameraObject.SetActive(false);
            var camera = cameraObject.AddComponent <Camera>();

            camera.orthographic  = false;
            camera.fieldOfView   = 60;
            camera.nearClipPlane = 0.3f;
            camera.farClipPlane  = 1000;

            camera.transform.position = new Vector3(0, 0, -10);

            if (renderTexture)
            {
                camera.targetTexture = renderTexture;
            }

            var perceptionCamera = cameraObject.AddComponent <PerceptionCamera>();

            perceptionCamera.captureRgbImages = false;
            var keyPointLabeler = new KeypointLabeler(config, template);

            if (computeListener != null)
            {
                keyPointLabeler.KeypointsComputed += computeListener;
            }

            perceptionCamera.AddLabeler(keyPointLabeler);

            return(cameraObject);
        }
Esempio n. 2
0
 static void SetupCubeJoints(GameObject cube, KeypointTemplate template)
 {
     SetupCubeJoint(cube, template, "FrontLowerLeft", -0.495f, -0.495f, -0.495f);
     SetupCubeJoint(cube, template, "FrontUpperLeft", -0.495f, 0.495f, -0.495f);
     SetupCubeJoint(cube, template, "FrontUpperRight", 0.495f, 0.495f, -0.495f);
     SetupCubeJoint(cube, template, "FrontLowerRight", 0.495f, -0.495f, -0.495f);
     SetupCubeJoint(cube, template, "BackLowerLeft", -0.495f, -0.495f, 0.495f);
     SetupCubeJoint(cube, template, "BackUpperLeft", -0.495f, 0.495f, 0.495f);
     SetupCubeJoint(cube, template, "BackUpperRight", 0.495f, 0.495f, 0.495f);
     SetupCubeJoint(cube, template, "BackLowerRight", 0.495f, -0.495f, 0.495f);
 }
Esempio n. 3
0
        static void SetupCubeJoints(GameObject cube, KeypointTemplate template)
        {
            const float dim = 0.5f;

            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);
        }
Esempio n. 4
0
        static void SetupCubeJoint(GameObject cube, KeypointTemplate template, string label, float x, float y, float z)
        {
            var joint = new GameObject();

            joint.transform.parent        = cube.transform;
            joint.transform.localPosition = new Vector3(x, y, z);
            var jointLabel = joint.AddComponent <JointLabel>();

            jointLabel.templateInformation = new List <JointLabel.TemplateData>();
            var templateData = new JointLabel.TemplateData
            {
                template = template,
                label    = label
            };

            jointLabel.templateInformation.Add(templateData);
        }
Esempio n. 5
0
        private void CreateFullyOccludedScene(KeypointTemplate template, GameObject cam)
        {
            var cube = TestHelper.CreateLabeledCube(scale: 6, z: 8);

            SetupCubeJoints(cube, template);

            var blocker = GameObject.CreatePrimitive(PrimitiveType.Cube);

            blocker.transform.position   = new Vector3(0, 0, 5);
            blocker.transform.localScale = new Vector3(7, 7, 7);

            cube.SetActive(true);
            cam.SetActive(true);

            AddTestObjectForCleanup(cam);
            AddTestObjectForCleanup(cube);
            AddTestObjectForCleanup(blocker);
        }