Пример #1
0
        public override void OnVisualize(Visualizer visualizer)
        {
            foreach (var box in Visualized)
            {
                var min = box.Position - box.Scale / 2;
                var max = box.Position + box.Scale / 2;

                Color color;
                switch (box.Label)
                {
                case "Car":
                    color = Color.green;
                    break;

                case "Pedestrian":
                    color = Color.yellow;
                    break;

                case "bicycle":
                    color = Color.cyan;
                    break;

                default:
                    color = Color.magenta;
                    break;
                }

                AAWireBoxes.Draw(min, max, color);
            }
            visualizer.UpdateRenderTexture(Camera.activeTexture, Camera.aspect);
        }
        public override void OnVisualize(Visualizer visualizer)
        {
            foreach (var detected in Detected)
            {
                Color color;
                switch (detected.Label)
                {
                case "Car":
                    color = Color.green;
                    break;

                case "Pedestrian":
                    color = Color.yellow;
                    break;

                case "bicycle":
                    color = Color.cyan;
                    break;

                default:
                    color = Color.magenta;
                    break;
                }

                // TODO: inverse transfrom for these?
                // relPos.Set(-relPos.y, relPos.z, relPos.x);
                // relRot.Set(-relRot.y, relRot.z, relRot.x, relRot.w);

                var transform = Matrix4x4.TRS(detected.Position, Quaternion.identity, Vector3.one);
                SolidAABox.Draw(detected.Position - detected.Scale / 2, detected.Position + detected.Scale / 2, color);
            }
            visualizer.UpdateRenderTexture(activeRT, Camera.aspect);
        }
Пример #3
0
        public override void OnVisualize(Visualizer visualizer)
        {
            foreach (var v in Detected)
            {
                var collider = v.Key;
                if (!collider.gameObject.activeInHierarchy)
                {
                    return;
                }

                var box = v.Value;
                var min = box.Position - box.Scale / 2;
                var max = box.Position + box.Scale / 2;

                Color color = Color.magenta;
                if (v.Value.Label == "Car")
                {
                    color = Color.green;
                }
                else if (v.Value.Label == "Pedestrian")
                {
                    color = Color.yellow;
                }
                else if (v.Value.Label == "bicycle")
                {
                    color = Color.cyan;
                }
                AAWireBoxes.Draw(min, max, color);
            }
            visualizer.UpdateRenderTexture(Camera.activeTexture, Camera.aspect);
        }
        protected override void SensorUpdate()
        {
            Camera.Render();
            SegmentationCamera.Render();

            minX.GetData(minXarr);
            maxX.GetData(maxXarr);
            minY.GetData(minYarr);
            maxY.GetData(maxYarr);

            DetectedObjects.Clear();

            // 0 is reserved for clear color, 255 for non-agent segmentation
            for (var i = 1; i < 255; ++i)
            {
                if (minXarr[i] == Width - 1 || maxXarr[i] == 0)
                {
                    continue;
                }

                var detected = GetDetectedObject(i);
                if (detected != null)
                {
                    DetectedObjects.Add(detected);
                }
            }

            MaxTracked = Math.Max(MaxTracked, DetectedObjects.Count);
            if (Bridge != null && Bridge.Status == Status.Connected)
            {
                Publish(new Detected2DObjectData()
                {
                    Frame    = Frame,
                    Sequence = seqId++,
                    Time     = SimulatorManager.Instance.CurrentTime,
                    Data     = DetectedObjects.ToArray(),
                });
            }

            foreach (var obj in DetectedObjects)
            {
                var min = obj.Position - obj.Scale / 2;
                var max = obj.Position + obj.Scale / 2;

                var color = string.Equals(obj.Label, "Pedestrian") ? Color.yellow : Color.green;
                AAWireBoxes.DrawBox(min, max, color);
            }

            var cmd = CommandBufferPool.Get();

            Camera.Render();
            AAWireBoxes.Draw(cmd);
            AAWireBoxes.Clear();
            HDRPUtilities.ExecuteAndClearCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
        }
Пример #5
0
        public override void OnVisualize(Visualizer visualizer)
        {
            foreach (var box in Visualized)
            {
                var min = box.Position - box.Scale / 2;
                var max = box.Position + box.Scale / 2;

                Color color = Color.green;
                if (box.Label == "Pedestrian")
                {
                    color = Color.yellow;
                }

                AAWireBoxes.Draw(min, max, color);
            }
            var test_min = new Vector2(Width / 2 - 10, Height / 2 - 10);
            var test_max = new Vector2(Width / 2 + 10, Height / 2 + 10);

            AAWireBoxes.Draw(test_min, test_max, Color.red);
            visualizer.UpdateRenderTexture(Camera.activeTexture, Camera.aspect);
        }
Пример #6
0
        public override void OnVisualize(Visualizer visualizer)
        {
            foreach (var box in Visualized)
            {
                var min = box.Position - box.Scale / 2;
                var max = box.Position + box.Scale / 2;

                Color color = Color.green;
                if (box.Label == "Pedestrian")
                {
                    color = Color.yellow;
                }

                AAWireBoxes.Draw(min, max, color);
            }
            visualizer.UpdateRenderTexture(Camera.activeTexture, Camera.aspect);
        }
Пример #7
0
        private void Update()
        {
            foreach (var v in Detected)
            {
                var collider = v.Key;
                var box      = v.Value;

                var min = box.Position - box.Scale / 2;
                var max = box.Position + box.Scale / 2;

                Color color = Color.magenta;
                if (v.Value.Label == "Car")
                {
                    color = Color.green;
                }
                else if (v.Value.Label == "Pedestrian")
                {
                    color = Color.yellow;
                }
                else if (v.Value.Label == "bicycle")
                {
                    color = Color.cyan;
                }

                AAWireBoxes.Draw(min, max, color);
            }

            if (Bridge == null || Bridge.Status != Status.Connected)
            {
                return;
            }

            if (Time.time < nextSend)
            {
                return;
            }

            Writer.Write(new Detected2DObjectData()
            {
                Sequence = seqId++,
                Frame    = Frame,
                Data     = Detected.Values.ToArray(),
            });
        }
Пример #8
0
        void Update()
        {
            if (Detected == null)
            {
                return;
            }

            foreach (var detected in Detected)
            {
                Color color;
                switch (detected.Label)
                {
                case "Car":
                    color = Color.green;
                    break;

                case "Pedestrian":
                    color = Color.yellow;
                    break;

                case "bicycle":
                    color = Color.cyan;
                    break;

                default:
                    color = Color.magenta;
                    break;
                }

                // TODO: inverse transfrom for these?
                // relPos.Set(-relPos.y, relPos.z, relPos.x);
                // relRot.Set(-relRot.y, relRot.z, relRot.x, relRot.w);

                var transform = Matrix4x4.TRS(detected.Position, Quaternion.identity, Vector3.one);
                SolidAABox.Draw(detected.Position - detected.Scale / 2, detected.Position + detected.Scale / 2, color);
            }
        }