Struct SensorHandle | Perception | 0.5.0-preview.1
docs.unity3d.com
    Show / Hide Table of Contents

    Struct SensorHandle

    A handle to a sensor managed by the DatasetCapture. It can be used to check whether the sensor is expected to capture this frame and report captures, annotations, and metrics regarding the sensor.

    Inherited Members
    ValueType.ToString()
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    Namespace: UnityEngine.Perception.GroundTruth
    Syntax
    public struct SensorHandle : IDisposable, IEquatable<SensorHandle>

    Properties

    Enabled

    Whether the sensor is currently enabled. When disabled, the DatasetCapture will no longer schedule frames for running captures on this sensor.

    Declaration
    public bool Enabled { get; set; }
    Property Value
    Type Description
    Boolean

    Id

    The unique ID of the sensor. This ID is used to refer to this sensor in the json metadata.

    Declaration
    public Guid Id { get; }
    Property Value
    Type Description
    Guid

    IsNil

    Returns true if this SensorHandle was default-instantiated.

    Declaration
    public bool IsNil { get; }
    Property Value
    Type Description
    Boolean

    IsValid

    Returns whether this SensorHandle is valid in the current simulation. Nil SensorHandles are never valid.

    Declaration
    public bool IsValid { get; }
    Property Value
    Type Description
    Boolean

    ShouldCaptureThisFrame

    Whether the sensor should capture this frame. Sensors are expected to call this method each frame to determine whether they should capture during the frame. Captures should only be reported when this is true.

    Declaration
    public bool ShouldCaptureThisFrame { get; }
    Property Value
    Type Description
    Boolean

    Methods

    Dispose()

    Dispose this SensorHandle.

    Declaration
    public void Dispose()
    Implements
    IDisposable.Dispose()

    Equals(Object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj
    Returns
    Type Description
    Boolean
    Overrides
    ValueType.Equals(Object)

    Equals(SensorHandle)

    Declaration
    public bool Equals(SensorHandle other)
    Parameters
    Type Name Description
    SensorHandle other
    Returns
    Type Description
    Boolean
    Implements
    IEquatable<T>.Equals(T)

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32
    Overrides
    ValueType.GetHashCode()

    ReportAnnotationAsync(AnnotationDefinition)

    Creates an async annotation for reporting the values for an annotation during a future frame.

    Declaration
    public AsyncAnnotation ReportAnnotationAsync(AnnotationDefinition annotationDefinition)
    Parameters
    Type Name Description
    AnnotationDefinition annotationDefinition

    The AnnotationDefinition of this annotation.

    Returns
    Type Description
    AsyncAnnotation

    Returns a handle to the AsyncAnnotation, which can be used to report annotation data during a subsequent frame.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if this method is called during a frame where ShouldCaptureThisFrame is false.

    ArgumentException

    Thrown if the given AnnotationDefinition is invalid.

    ReportAnnotationFile(AnnotationDefinition, String)

    Report a file-based annotation related to this sensor in this frame.

    Declaration
    public Annotation ReportAnnotationFile(AnnotationDefinition annotationDefinition, string filename)
    Parameters
    Type Name Description
    AnnotationDefinition annotationDefinition

    The AnnotationDefinition of this annotation.

    String filename

    The path to the file containing the annotation data.

    Returns
    Type Description
    Annotation

    A handle to the reported annotation for reporting annotation-based metrics.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if this method is called during a frame where ShouldCaptureThisFrame is false.

    ArgumentException

    Thrown if the given AnnotationDefinition is invalid.

    ReportAnnotationValues<T>(AnnotationDefinition, T[])

    Report a value-based annotation related to this sensor in this frame.

    Declaration
    public Annotation ReportAnnotationValues<T>(AnnotationDefinition annotationDefinition, T[] values)
    Parameters
    Type Name Description
    AnnotationDefinition annotationDefinition

    The AnnotationDefinition of this annotation.

    T[] values

    The annotation data, which will be automatically converted to json.

    Returns
    Type Description
    Annotation

    Returns a handle to the reported annotation for reporting annotation-based metrics.

    Type Parameters
    Name Description
    T

    The type of the values array.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if this method is called during a frame where ShouldCaptureThisFrame is false.

    ArgumentException

    Thrown if the given AnnotationDefinition is invalid.

    ReportCapture(String, SensorSpatialData, (String, Object)[])

    Report a sensor capture recorded to disk. This should be called on the same frame as the capture is taken, and may be called before the file is written to disk.

    Declaration
    public void ReportCapture(string filename, SensorSpatialData sensorSpatialData, params (string, object)[] additionalSensorValues)
    Parameters
    Type Name Description
    String filename

    The path to the capture data.

    SensorSpatialData sensorSpatialData

    Spatial data describing the sensor and the ego containing it.

    ValueTuple<String, Object>[] additionalSensorValues

    Additional values to be emitted as json name/value pairs on the sensor object under the capture.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if ReportCapture is being called when ShouldCaptureThisFrame is false or it has already been called this frame.

    ReportMetric(MetricDefinition, String)

    Report a metric regarding this sensor in the current frame.

    Declaration
    public void ReportMetric(MetricDefinition metricDefinition, [NotNull] string valuesJsonArray)
    Parameters
    Type Name Description
    MetricDefinition metricDefinition

    The MetricDefinition of the metric.

    String valuesJsonArray

    A string-based JSON array to be placed in the "values" field of the metric

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if values is null

    InvalidOperationException

    Thrown if ShouldCaptureThisFrame is false.

    ReportMetric<T>(MetricDefinition, T[])

    Report a metric regarding this sensor in the current frame.

    Declaration
    public void ReportMetric<T>(MetricDefinition metricDefinition, [NotNull] T[] values)
    Parameters
    Type Name Description
    MetricDefinition metricDefinition

    The MetricDefinition of the metric.

    T[] values

    An array to be converted to json and put in the "values" field of the metric

    Type Parameters
    Name Description
    T

    The value type

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if values is null

    InvalidOperationException

    Thrown if ShouldCaptureThisFrame is false.

    ReportMetricAsync(MetricDefinition)

    Start an async metric for reporting metric values for this frame in a subsequent frame.

    Declaration
    public AsyncMetric ReportMetricAsync(MetricDefinition metricDefinition)
    Parameters
    Type Name Description
    MetricDefinition metricDefinition

    The MetricDefinition of the metric

    Returns
    Type Description
    AsyncMetric

    An AsyncMetric which should be used to report the metric values, potentially in a later frame

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if ShouldCaptureThisFrame is false

    Operators

    Equality(SensorHandle, SensorHandle)

    Compares two SensorHandle instances for equality.

    Declaration
    public static bool operator ==(SensorHandle left, SensorHandle right)
    Parameters
    Type Name Description
    SensorHandle left

    The first SensorHandle.

    SensorHandle right

    The second SensorHandle.

    Returns
    Type Description
    Boolean

    Returns true if the two SensorHandles refer to the same sensor.

    Inequality(SensorHandle, SensorHandle)

    Compares two SensorHandle instances for inequality.

    Declaration
    public static bool operator !=(SensorHandle left, SensorHandle right)
    Parameters
    Type Name Description
    SensorHandle left

    The first SensorHandle.

    SensorHandle right

    The second SensorHandle.

    Returns
    Type Description
    Boolean

    Returns false if the two SensorHandles refer to the same sensor.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023