[FormerlySerializedAs("m_BoundingBoxID")]
public string boundingBoxId = "F9F22E05-443F-4602-A422-EBE4EA9B55CB" ;
/// <summary>
/// Whether visible pixels should be computed for each labeled object
/// Whether rendered object info metrics should be generated. This metric currently contains label id, instance id, and visible pixels.
public bool produceVisiblePixelsMetric = true ;
[FormerlySerializedAs("produceVisiblePixelsMetric")]
public bool produceRenderedObjectInfoMetric = true ;
[FormerlySerializedAs("visiblePixelsId")]
public string visiblePixelsId = "5BA92024-B3B7-41A7-9D3F-C03A6A8DDD01" ;
public string renderedObjectInfoId = "5BA92024-B3B7-41A7-9D3F-C03A6A8DDD01" ;
/// <summary>
/// The corner of the image to use as the origin for bounding boxs.
/// </summary>
public LabelingConfiguration LabelingConfiguration ;
/// <summary>
/// Invoked when RenderedObjectInfos (bounding boxes) are calculated. The first parameter is the Time.frameCount at which the objects were rendered. This may be called many frames after the frame in which the objects were rendered.
/// 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 frame in which the objects were rendered.
/// </summary>
public event Action < int , NativeArray < RenderedObjectInfo > > renderedObjectInfosCalculated ;
public int FrameCount ;
public AsyncAnnotation SegmentationAsyncAnnotation ;
public AsyncMetric ClassCountAsyncMetric ;
public AsyncMetric VisiblePixels AsyncMetric;
public AsyncMetric RenderedObjectInfo AsyncMetric;
public AsyncAnnotation BoundingBoxAsyncMetric ;
}
ClassCountValue [ ] m_ClassCountValues ;
BoundingBoxValue [ ] m_BoundingBoxValues ;
VisiblePixels Value[ ] m_VisiblePixelsValues ;
RenderedObjectInfo Value[ ] m_VisiblePixelsValues ;
#if HDRP_PRESENT
InstanceSegmentationPass m_SegmentationPass ;
AnnotationDefinition m_BoundingBoxAnnotationDefinition ;
AnnotationDefinition m_SegmentationAnnotationDefinition ;
MetricDefinition m_VisiblePixels MetricDefinition ;
MetricDefinition m_RenderedObjectInfo MetricDefinition ;
static ProfilerMarker s_WriteFrame = new ProfilerMarker ( "Write Frame (PerceptionCamera)" ) ;
static ProfilerMarker s_FlipY = new ProfilerMarker ( "Flip Y (PerceptionCamera)" ) ;
static ProfilerMarker s_BoundingBoxCallback = new ProfilerMarker ( "OnBoundingBoxesReceived" ) ;
static ProfilerMarker s_ProduceVisiblePixels Metric = new ProfilerMarker ( "ProduceVisiblePixels Metric" ) ;
static ProfilerMarker s_ProduceRenderedObjectInfo Metric = new ProfilerMarker ( "ProduceRenderedObjectInfo Metric" ) ;
[SuppressMessage("ReSharper", "InconsistentNaming")]
struct SemanticSegmentationSpec
( frameCount , data , tex ) = > OnSemanticSegmentationImageRead ( frameCount , data ) ) ;
}
if ( produceObjectCountAnnotations | | produceBoundingBoxAnnotations )
if ( produceObjectCountAnnotations | | produceBoundingBoxAnnotations | | produceRenderedObjectInfoMetric )
{
var labelingMetricSpec = LabelingConfiguration . LabelingConfigurations . Select ( ( l , index ) = > new ObjectCountSpec ( )
{
if ( produceBoundingBoxAnnotations )
{
m_BoundingBoxAnnotationDefinition = SimulationManager . RegisterAnnotationDefinition ( "bounding box" , labelingMetricSpec , "Bounding boxe for each labeled object visible to the sensor" , id : new Guid ( boundingBoxId ) ) ;
m_BoundingBoxAnnotationDefinition = SimulationManager . RegisterAnnotationDefinition ( "bounding box" , labelingMetricSpec , "Bounding box for each labeled object visible to the sensor" , id : new Guid ( boundingBoxId ) ) ;
if ( produceVisiblePixels Metric )
m_VisiblePixels MetricDefinition = SimulationManager . RegisterMetricDefinition ( "visible pixels " , labelingMetricSpec , "Visible pixels for each visible object " , id : new Guid ( visiblePixels Id) ) ;
if ( produceRenderedObjectInfo Metric )
m_RenderedObjectInfo MetricDefinition = SimulationManager . RegisterMetricDefinition ( "rendered object info " , labelingMetricSpec , "Information about each labeled object visible to the sensor " , id : new Guid ( renderedObjectInfo Id) ) ;
m_RenderedObjectInfoGenerator = new RenderedObjectInfoGenerator ( LabelingConfiguration ) ;
World . DefaultGameObjectInjectionWorld . GetExistingSystem < GroundTruthLabelSetupSystem > ( ) . Activate ( m_RenderedObjectInfoGenerator ) ;
if ( produceBoundingBoxAnnotations )
ProduceBoundingBoxesAnnotation ( renderedObjectInfos , LabelingConfiguration . LabelingConfigurations , frameCount ) ;
if ( produceVisiblePixels Metric )
ProduceVisiblePixels Metric ( renderedObjectInfos , frameCount ) ;
if ( produceRenderedObjectInfo Metric )
ProduceRenderedObjectInfo Metric ( renderedObjectInfos , frameCount ) ;
} ) ;
}
// ReSharper disable InconsistentNaming
struct VisiblePixels Value
struct RenderedObjectInfo Value
{
[UsedImplicitly]
public int label_id ;
}
// ReSharper restore InconsistentNaming
void ProduceVisiblePixels Metric ( NativeArray < RenderedObjectInfo > renderedObjectInfos , int frameCount )
void ProduceRenderedObjectInfo Metric ( NativeArray < RenderedObjectInfo > renderedObjectInfos , int frameCount )
using ( s_ProduceVisiblePixels Metric . Auto ( ) )
using ( s_ProduceRenderedObjectInfo Metric . Auto ( ) )
var visiblePixelsAsyncM etric = asyncCaptureInfo . VisiblePixels AsyncMetric;
if ( ! visiblePixelsAsyncM etric. IsValid )
var m etric = asyncCaptureInfo . RenderedObjectInfo AsyncMetric;
if ( ! m etric. IsValid )
m_VisiblePixelsValues = new VisiblePixels Value[ renderedObjectInfos . Length ] ;
m_VisiblePixelsValues = new RenderedObjectInfo Value[ renderedObjectInfos . Length ] ;
for ( var i = 0 ; i < renderedObjectInfos . Length ; i + + )
{
m_VisiblePixelsValues [ i ] = new VisiblePixels Value
m_VisiblePixelsValues [ i ] = new RenderedObjectInfo Value
{
label_id = labelId ,
instance_id = objectInfo . instanceId ,
visiblePixelsAsyncM etric. ReportValues ( m_VisiblePixelsValues ) ;
m etric. ReportValues ( m_VisiblePixelsValues ) ;
}
}
m_AsyncCaptureInfos . RemoveSwapBack ( i = >
! i . SegmentationAsyncAnnotation . IsPending & &
! i . BoundingBoxAsyncMetric . IsPending & &
! i . VisiblePixels AsyncMetric. IsPending & &
! i . RenderedObjectInfo AsyncMetric. IsPending & &
if ( produceSegmentationImages | | produceObjectCountAnnotations | | produceBoundingBoxAnnotations | | produceVisiblePixels Metric )
if ( produceSegmentationImages | | produceObjectCountAnnotations | | produceBoundingBoxAnnotations | | produceRenderedObjectInfo Metric )
{
var captureInfo = new AsyncCaptureInfo ( )
{
if ( produceBoundingBoxAnnotations )
captureInfo . BoundingBoxAsyncMetric = SensorHandle . ReportAnnotationAsync ( m_BoundingBoxAnnotationDefinition ) ;
if ( produceVisiblePixels Metric )
captureInfo . VisiblePixels AsyncMetric = SensorHandle . ReportMetricAsync ( m_VisiblePixels MetricDefinition ) ;
if ( produceRenderedObjectInfo Metric )
captureInfo . RenderedObjectInfo AsyncMetric = SensorHandle . ReportMetricAsync ( m_RenderedObjectInfo MetricDefinition ) ;
m_AsyncCaptureInfos . Add ( captureInfo ) ;
}