Example #1
0
    public override bool RunComponent(IOutputContext context)
    {
        foreach (Camera tracking_camera in cameras_)
        {
            for (int i = 0; i < tracked_objects_.Count; ++i)
            {
                GameObject tracked_object      = tracked_objects_[i];
                string     tracked_object_name = tracked_object.name;
                if (i < tracked_object_aliases_array_.Length)
                {
                    // If there is an alias on the alias list, use it.
                    tracked_object_name = tracked_object_aliases_array_[i];
                }

                // Return the center of the object.
                string  stream_name       = string.Format("tracker_{0}_X_{1}", tracked_object_name, tracking_camera.name);
                Vector3 viewport_position = tracking_camera.WorldToViewportPoint(tracked_object.transform.position);
                context.OutputFloats(stream_name, new float[] { viewport_position.x, viewport_position.y });

                // Return the bounding box
                string stream_name_bbox = string.Format("tracker_{0}_X_{1}_bbox", tracked_object_name, tracking_camera.name);
                context.OutputFloats(stream_name_bbox, GetBounds2DViewPoint(tracking_camera, tracked_object));
            }
        }
        return(true);
    }