|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Labelers should set this in their setup to define if they support realtime
|
|
|
|
/// visualization of their data.
|
|
|
|
/// visualization of their data.
|
|
|
|
/// </summary>
|
|
|
|
protected abstract bool supportsVisualization |
|
|
|
{ |
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Static counter shared by all lableler classes. If any visualizers are
|
|
|
|
/// active then perception camera cannot operate in asynchronous mode.
|
|
|
|
/// active then perception camera cannot operate in asynchronous mode.
|
|
|
|
private static VisualizationCanvas m_Canvas = null; |
|
|
|
|
|
|
|
/// Retrieve a handle to the visualization canvas <see cref="VisualizationCanvas". This is the specific canvas that all visualization
|
|
|
|
/// Retrieve a handle to the visualization canvas <see cref="VisualizationCanvas"/>. This is the specific canvas that all visualization
|
|
|
|
public VisualizationCanvas canvas |
|
|
|
{ |
|
|
|
get |
|
|
|
{ |
|
|
|
if (m_Canvas == null) |
|
|
|
{ |
|
|
|
m_Canvas = GameObject.Instantiate(Resources.Load<GameObject>("VisualizationUI")).GetComponent<VisualizationCanvas>(); |
|
|
|
}; |
|
|
|
return m_Canvas; |
|
|
|
} |
|
|
|
} |
|
|
|
public VisualizationCanvas visualizationCanvas { get; private set; } |
|
|
|
public ControlPanel controlPanel |
|
|
|
{ |
|
|
|
get |
|
|
|
{ |
|
|
|
return canvas.controlPanel; |
|
|
|
} |
|
|
|
} |
|
|
|
public ControlPanel controlPanel => visualizationCanvas != null ? visualizationCanvas.controlPanel : null; |
|
|
|
public HUDPanel hudPanel |
|
|
|
{ |
|
|
|
get |
|
|
|
{ |
|
|
|
return canvas.hudPanel; |
|
|
|
} |
|
|
|
} |
|
|
|
public HUDPanel hudPanel => visualizationCanvas != null ? visualizationCanvas.hudPanel : null; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The <see cref="PerceptionCamera"/> that contains this labeler.
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Called when the labeler's visualization capability is turned on or off.
|
|
|
|
/// </summary>
|
|
|
|
protected virtual void OnVisualizerActiveStateChanged(bool enabled) {} |
|
|
|
protected virtual void OnVisualizerEnabledChanged(bool enabled) {} |
|
|
|
/// <summary>
|
|
|
|
/// Called during the Update each frame the the labeler is enabled and <see cref="SensorHandle.ShouldCaptureThisFrame"/> is true.
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
|
|
|
internal void InternalSetup() => Setup(); |
|
|
|
internal void InternalPopulateVisualizationPanel(GameObject panel) => PopulateVisualizationPanel(controlPanel); |
|
|
|
internal void InternalVisualizerActiveStateChanged(bool enabled) => OnVisualizerActiveStateChanged(enabled); |
|
|
|
internal void InternalVisualizerActiveStateChanged(bool enabled) => OnVisualizerEnabledChanged(enabled); |
|
|
|
private bool m_VisualizationEnabled = true; |
|
|
|
|
|
|
|
private bool m_VisualizationEnabled = false; |
|
|
|
|
|
|
|
/// Turns on/off the labeler's realtime visualization capability. If a labeler
|
|
|
|
/// does not support realtime visualization (<see cref="supportsVisualization"/>)
|
|
|
|
/// Turns on/off the labeler's realtime visualization capability. If a labeler does not support realtime
|
|
|
|
/// visualization (<see cref="supportsVisualization"/>) or visualization is not enabled on the PerceptionCamera
|
|
|
|
/// this will not function.
|
|
|
|
/// </summary>
|
|
|
|
protected bool visualizationEnabled |
|
|
|
|
|
|
set |
|
|
|
{ |
|
|
|
if (!supportsVisualization) return; |
|
|
|
if (visualizationCanvas == null) return; |
|
|
|
|
|
|
|
|
|
|
|
if (m_VisualizationEnabled) |
|
|
|
activeVisualizers++; |
|
|
|
else |
|
|
|
|
|
|
else |
|
|
|
CaptureOptions.useAsyncReadbackIfSupported = true; |
|
|
|
|
|
|
|
OnVisualizerActiveStateChanged(m_VisualizationEnabled); |
|
|
|
OnVisualizerEnabledChanged(m_VisualizationEnabled); |
|
|
|
|
|
|
|
internal void Init(PerceptionCamera newPerceptionCamera) |
|
|
|
|
|
|
|
internal void Init(PerceptionCamera newPerceptionCamera, VisualizationCanvas visualizationCanvas) |
|
|
|
this.visualizationCanvas = visualizationCanvas; |
|
|
|
if (supportsVisualization) |
|
|
|
if (supportsVisualization && visualizationCanvas != null) |
|
|
|
m_VisualizationEnabled = true; |
|
|
|
InitVisualizationUI(); |
|
|
|
} |
|
|
|
} |
|
|
|