using System; namespace UnityEngine.Perception.GroundTruth { /// /// Abstract class for defining custom annotation and metric generation to be run by . /// Instances of CameraLabeler on will be invoked each frame the camera is /// set to capture data (see ). /// [Serializable] public abstract class CameraLabeler { /// /// Whether the CameraLabeler should be set up and called each frame. /// public bool enabled = true; internal bool isInitialized { get; private set; } /// /// The that contains this labeler. /// protected PerceptionCamera perceptionCamera { get; private set; } /// /// The SensorHandle for the that contains this labeler. Use this to report /// annotations and metrics. /// protected SensorHandle sensorHandle { get; private set; } /// /// Called just before the first call to or . Implement this /// to initialize state. /// protected virtual void Setup() { } /// /// Called during the Update each frame the the labeler is enabled and is true. /// protected virtual void OnUpdate() {} /// /// Called just before the camera renders each frame the the labeler is enabled and is true. /// protected virtual void OnBeginRendering() {} /// /// Called when the Labeler is about to be destroyed or removed from the PerceptionCamera. Use this to clean up to state. /// protected virtual void Cleanup() {} internal void InternalSetup() => Setup(); internal void InternalOnUpdate() => OnUpdate(); internal void InternalOnBeginRendering() => OnBeginRendering(); internal void InternalCleanup() => Cleanup(); internal void Init(PerceptionCamera newPerceptionCamera) { try { this.perceptionCamera = newPerceptionCamera; sensorHandle = newPerceptionCamera.SensorHandle; Setup(); isInitialized = true; } catch (Exception) { this.enabled = false; throw; } } } }