6.0 KiB
Getting started with Perception
This walkthrough shows you how to create a new scene in order to generate perception datasets including segmentation data and image captures.
Step 1: Create a project and install Perception
To install Perception in your project, follow the Installing the Perception package in your project guide.
Step 2 (for Universal Render Pipeline projects): Add GroundTruthRendererFeature
You can skip this step for HDRP projects.
- Select your project's ScriptableRenderer asset and open the Inspector window. In most projects it is located at
Assets/Settings/ForwardRenderer.asset
. - Select Add Renderer Feature and Ground Truth Renderer Feature.
Step 3: Create a new scene and camera
- Create a new scene using File > New Scene
- Ctrl+S to save the Scene and give it a name
- Select the Main Camera and reset the Position transform to 0
- In the Hierarchy window select the Main Camera
- In the Main Camera's Inspector window select Add Component
- Add a Perception Camera component
Step 4: Create labeled objects
- Create a cube by right-clicking in the Hierarchy window and selecting 3D Object > Cube
- Create two more cubes this way
- Change the names of the cubes to Cube, Box, and Crate
- Position the cubes in front of the Main Camera
Position of the cubes in front of the Main Camera
- On each cube, in the Inspector window, add a Labeling component
- Select Add (+)
- In the text field add the name of the object, for example Crate. Unity uses this label in the semantic segmentation images.
A labeling component, for example "Crate"
- Create and set up an IdLabelConfig
- In the Project window select Add (+), then Perception > ID Label Config
- In the Assets folder, select the new IdLabelConfig
- In the Inspector, select Add to list (+) three times
- In the three label text fields, add the text (Crate, Cube and Box) from the Labeling script on the objects you created in the Scene
IdLabelConfig with three labels
-
Create and set up a SemanticSegmentationLabelingConfiguration
- In the Project panel select Add (+), then Perception > Semantic Segmentation Label Config
- In the Assets folder, select the new SemanticSegmentationLabelingConfiguration
- In the Inspector, select Add to list (+) three times
- In the three label text fields, add the text (Cube, Crate and Box) from the Labeling script on the objects you created in the Scene
SemanticSegmentationLabelConfig with three labels and three colors
-
In the Hierarchy window select the Main Camera
-
Add the IdLabelConfig to the Perception Camera script
- In the Perception Camera script, find the following three Camera Labelers: BoundingBox2DLabeler, ObjectCountLabeler and RenderedObjectInfoLabeler. For each Camera Labeler, in the Id Label Config field (or Label Config field, for the ObjectCountLabeler Camera Labeler), click the circle button.
- In the Select IdLabelConfig window, select the IdLabelConfig you created.
-
Add the SemanticSegmentationLabelingConfiguration to the Perception Camera script
- In the Perception Camera script, find the SemanticSegmentationLabeler Camera Labeler. In its Label Config field, select the circle button.
- In the Select SemanticSegmentationLabelConfig window, select the SemanticSegmentationLabelConfig you created.
Step 5: Run simulation and generate dataset
- In the Editor, press the play button, allow the scene to run for 10 seconds, then exit Play mode.
- In the console log you see a Shutdown in Progress message that shows a file path to the location of the generated dataset.
Example file path on a Windows PC :
C:/Users/<User Name>/AppData/LocalLow/DefaultCompany/UnityTestFramework\2e10ec21-9d97-4cee-b5a2-7e95e299afa4\RGB18f61842-ef8d-4b31-acb5-cb1da36fb7b1
- You find the following data in the dataset folder:
- RGB captures
- Semantic segmentation images
- Logs
- JSON dataset
Optional Step: realtime visualization of labelers
The Perception package comes with the ability to show realtime results of the labeler in the scene. To enable this capability:
Example of Perception running with show visualizations enabled
- To use the visualizer, select the Main Camera, and in the Inspector window, in the Perception Camera component, enable Show Visualizations. This enables the built-in labelers which includes segmentation data, 2D bounding boxes, pixel and object counts.
- Enabling the visualizer creates new UI controls in the Editor's Game view. These controls allow you to control each of the individual visualizers. You can enable or disable individual visualizers. Some visualizers also include controls that let you change their output.
Visualization controls in action
Important Note: The Perception package uses asynchronous processing to ensure reasonable frame rates of a scene. A side effect of real-time visualization is that the labelers must be applied to the capture in its actual frame, which potentially adversely affects the Scene's framerate.