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
Namespace: UnityEngine.Perception.GroundTruth
Assembly: Unity.Perception.Runtime.dll
Syntax
public struct SensorHandle : IDisposable, IEquatable<SensorHandle>
Properties
Id
The Id of the sensor
Declaration
public readonly string Id { get; }
Property Value
Type | Description |
---|---|
string |
IsNil
Returns true if this SensorHandle was default-instantiated.
Declaration
public bool IsNil { get; }
Property Value
Type | Description |
---|---|
bool |
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 |
---|---|
bool |
ShouldAccumulateThisFrame
Whether the sensor should start to accumulate on this frame. Sensors are expected to call this method each frame to determine whether they should start accumulating during the frame.
Declaration
public bool ShouldAccumulateThisFrame { get; }
Property Value
Type | Description |
---|---|
bool |
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 |
---|---|
bool |
Methods
Dispose()
Dispose this SensorHandle.
Declaration
public void Dispose()
Equals(object)
Compare two SensorHandle by Id
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | Any other object to compare |
Returns
Type | Description |
---|---|
bool | True is obj is a SensorHandle and has the same Id |
Overrides
Equals(SensorHandle)
Compare two SensorHandle by Id
Declaration
public bool Equals(SensorHandle other)
Parameters
Type | Name | Description |
---|---|---|
SensorHandle | other | Other SensorHandle to compare |
Returns
Type | Description |
---|---|
bool | True if Id as equal, false if not |
GetHashCode()
Ovverided method for GetHashCode. It uses Id.GetHashCode();
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | Hash code based on Id |
Overrides
ReportAnnotation(AnnotationDefinition, Annotation)
Reports an annotation for the sensor.
Declaration
public AnnotationHandle ReportAnnotation(AnnotationDefinition definition, Annotation annotation)
Parameters
Type | Name | Description |
---|---|---|
AnnotationDefinition | definition | The annotation definition |
Annotation | annotation | The annotation value |
Returns
Type | Description |
---|---|
AnnotationHandle | created AnnotationHandle |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown when an annotation is reported for a frame that should not be captured |
ArgumentException | Thrown when an annotation is reported with an invalid annotation definition |
ReportAnnotationAsync(AnnotationDefinition)
Creates an async annotation for reporting the values for an annotation during a future frame.
Declaration
public AsyncFuture<Annotation> ReportAnnotationAsync(AnnotationDefinition annotationDefinition)
Parameters
Type | Name | Description |
---|---|---|
AnnotationDefinition | annotationDefinition | The AnnotationDefinition of this annotation. |
Returns
Type | Description |
---|---|
AsyncFuture<Annotation> | Returns a handle to the AsyncFuture<T>, 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. |
ReportMetric(MetricDefinition, Metric)
Reports a metric on the current frame.
Declaration
public void ReportMetric(MetricDefinition definition, Metric metric)
Parameters
Type | Name | Description |
---|---|---|
MetricDefinition | definition | The metric definition |
Metric | metric | The metric value |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown when a metric is reported on a frame that should not capture |
ArgumentException | Thrown if the passed in metric is invalid |
ReportMetricAsync(MetricDefinition)
Start an async metric for reporting metric values for this frame in a subsequent frame.
Declaration
public AsyncFuture<Metric> ReportMetricAsync(MetricDefinition metricDefinition)
Parameters
Type | Name | Description |
---|---|---|
MetricDefinition | metricDefinition | The MetricDefinition of the metric |
Returns
Type | Description |
---|---|
AsyncFuture<Metric> | An AsyncFuture<T> which should be used to report the metric values, potentially in a later frame |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if ShouldCaptureThisFrame is false |
ReportSensor(Sensor)
Reports a sensor capture immediately for the current frame
Declaration
public void ReportSensor(Sensor sensor)
Parameters
Type | Name | Description |
---|---|---|
Sensor | sensor | The capture to report |
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. |
ReportSensorAsync()
Creates an async sensor for reporting the values for a sensor during a future frame.
Declaration
public AsyncFuture<Sensor> ReportSensorAsync()
Returns
Type | Description |
---|---|
AsyncFuture<Sensor> | Returns a handle to the AsyncFuture<T>, 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. |
RequestCapture()
Requests a capture from this sensor on the next rendered frame. Can only be used with manual capture mode (Manual).
Declaration
public void RequestCapture()
ToString()
Overrides method ToString
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | SensorHandler Id |
Overrides
Operators
operator ==(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 |
---|---|
bool | Returns true if the two SensorHandles refer to the same sensor. |
operator !=(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 |
---|---|
bool | Returns false if the two SensorHandles refer to the same sensor. |