Class PerceptionCamera
Captures ground truth from the associated Camera.
Inherited Members
Namespace: UnityEngine.Perception.GroundTruth
Assembly: Unity.Perception.Runtime.dll
Syntax
[RequireComponent(typeof(Camera))]
public class PerceptionCamera : MonoBehaviour
Fields
alphaThreshold
The minimum level of transparency that will be rendered per pixel in the segmentation image.
Declaration
[Tooltip("The minimum level of transparency that will be rendered per pixel in segmentation images.")]
[Range(0, 1)]
public float alphaThreshold
Field Value
Type | Description |
---|---|
float |
captureRgbImages
Whether camera output should be captured to disk.
Declaration
public bool captureRgbImages
Field Value
Type | Description |
---|---|
bool |
captureTriggerMode
The method of triggering captures for this camera.
Declaration
public CaptureTriggerMode captureTriggerMode
Field Value
Type | Description |
---|---|
CaptureTriggerMode |
description
A human-readable description of the camera.
Declaration
public string description
Field Value
Type | Description |
---|---|
string |
firstCaptureFrame
Frame number at which this camera starts capturing.
Declaration
public int firstCaptureFrame
Field Value
Type | Description |
---|---|
int |
framesBetweenCaptures
The number of frames to simulate and render between the camera's scheduled captures. Setting this to 0 makes the camera capture every frame.
Declaration
public int framesBetweenCaptures
Field Value
Type | Description |
---|---|
int |
id
The string ID of this camera sensor
Declaration
public string id
Field Value
Type | Description |
---|---|
string |
manualSensorAffectSimulationTiming
Have this unscheduled (manual capture) camera affect simulation timings (similar to a scheduled camera) by requesting a specific frame delta time.
Declaration
public bool manualSensorAffectSimulationTiming
Field Value
Type | Description |
---|---|
bool |
overrideLayerMask
Whether to override the camera's LayerMask on its labelers.
Declaration
public bool overrideLayerMask
Field Value
Type | Description |
---|---|
bool |
showVisualizations
Turns on/off the realtime visualization capability.
Declaration
public bool showVisualizations
Field Value
Type | Description |
---|---|
bool |
simulationDeltaTime
The simulation frame time (seconds) for this camera. E.g. 0.0166 translates to 60 frames per second. This will be used as Unity's captureDeltaTime, causing a fixed number of frames to be generated for each second of elapsed simulation time regardless of the capabilities of the underlying hardware.
Declaration
public float simulationDeltaTime
Field Value
Type | Description |
---|---|
float |
useAccumulation
Whether to use accumulation before capture (e.g. Path Tracing)
Declaration
public bool useAccumulation
Field Value
Type | Description |
---|---|
bool |
waitFrames
Number of frames to wait before starting the scenario
Declaration
public static int waitFrames
Field Value
Type | Description |
---|---|
int |
Properties
SensorHandle
The SensorHandle associated with this camera. Use this to report additional annotations and metrics at runtime.
Declaration
public SensorHandle SensorHandle { get; }
Property Value
Type | Description |
---|---|
SensorHandle |
attachedCamera
Caches access to the camera attached to the perception camera.
Declaration
public Camera attachedCamera { get; }
Property Value
Type | Description |
---|---|
Camera |
cameraSensor
The CameraSensor used to generate the PerceptionCamera's output.
Declaration
public CameraSensor cameraSensor { get; set; }
Property Value
Type | Description |
---|---|
CameraSensor |
captureFrameCount
The number of capture-able frames that have been generated
Declaration
public static int captureFrameCount { get; }
Property Value
Type | Description |
---|---|
int |
channels
The currently enabled CameraChannel<T>s for this PerceptionCamera.
Declaration
public IReadOnlyList<CameraChannelBase> channels { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<CameraChannelBase> |
labelers
The CameraLabeler instances which will be run for this PerceptionCamera.
Declaration
public IReadOnlyList<CameraLabeler> labelers { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<CameraLabeler> |
layerMask
The LayerMask used for filtering objects before capturing labeler data. The overrideLayerMask field must be enabled for this LayerMask to be used. The attached Camera's cullingMask is used otherwise.
Declaration
public LayerMask layerMask { get; set; }
Property Value
Type | Description |
---|---|
LayerMask |
Methods
AddLabeler(CameraLabeler)
Add the given CameraLabeler to the PerceptionCamera. It will be set up and executed by this PerceptionCamera each frame it captures data.
Declaration
public void AddLabeler(CameraLabeler cameraLabeler)
Parameters
Type | Name | Description |
---|---|---|
CameraLabeler | cameraLabeler | The labeler to add to this PerceptionCamera |
EnableChannel<T>()
Enables a channel of the given type on the sensor.
Declaration
public T EnableChannel<T>() where T : CameraChannelBase, new()
Returns
Type | Description |
---|---|
T | Newly created Channel |
Type Parameters
Name | Description |
---|---|
T | The type of channel to enable. |
GetChannel<T>()
Returns the enabled channel of the specified type.
Declaration
public T GetChannel<T>() where T : CameraChannelBase
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | The type of channel to get. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Channel's must be enabled before they can be accessed. |
IsChannelEnabled<T>()
Returns whether a channel of the given type has been enabled on the sensor.
Declaration
public bool IsChannelEnabled<T>() where T : CameraChannelBase
Returns
Type | Description |
---|---|
bool | The enabled status of the given channel. |
Type Parameters
Name | Description |
---|---|
T | The type of channel to check the enabled status of. |
RemoveLabeler(CameraLabeler)
Removes the given CameraLabeler from the list of labelers under this PerceptionCamera, if it is in the list. The labeler is cleaned up in the process. Labelers removed from a PerceptionCamera should not be used again.
Declaration
public bool RemoveLabeler(CameraLabeler cameraLabeler)
Parameters
Type | Name | Description |
---|---|---|
CameraLabeler | cameraLabeler |
Returns
Type | Description |
---|---|
bool |
RemovePersistentSensorData(string)
Removes a persistent sensor data object.
Declaration
public bool RemovePersistentSensorData(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key of the object to remove. |
Returns
Type | Description |
---|---|
bool | True if a data object was removed. False if it was not set. |
RequestCapture()
Requests a capture from this PerceptionCamera on the next rendered frame. Can only be used when using Manual capture mode.
Declaration
public void RequestCapture()
SetPersistentSensorData(string, object)
Add a data object which will be added to the dataset with each capture. Overrides existing sensor data associated with the given key.
Declaration
public void SetPersistentSensorData(string key, object data)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key to associate with the data. |
object | data | An object containing the data. Will be serialized into json. |
TryGetChannel<T>(out T)
Returns whether a channel of the given type is enabled, and additionally outputs the found channel.
Declaration
public bool TryGetChannel<T>(out T channel) where T : CameraChannelBase
Parameters
Type | Name | Description |
---|---|---|
T | channel | The found channel of the given type. |
Returns
Type | Description |
---|---|
bool | True if a channel of the given type is enabled, false if otherwise. |
Type Parameters
Name | Description |
---|---|
T | The type of channel to get. |
Events
RenderedObjectInfosCalculated
Invoked when RenderedObjectInfos are calculated. The first parameter is the Time.frameCount at which the objects were rendered. This may be called many frames after the objects were rendered.
Declaration
public event Action<int, NativeArray<RenderedObjectInfo>, SceneHierarchyInformation> RenderedObjectInfosCalculated
Event Type
Type | Description |
---|---|
Action<int, NativeArray<RenderedObjectInfo>, SceneHierarchyInformation> |