Notes of Unity Perception Package

Setup

Perception 是Unity官方提供的,用以生成计算机视觉相关内容的包。Synthetichumans 是用来快速生成多个人物的资源包。

Perception

通过查阅官方文档完成设置。

  • Click on the plus (+) sign at the top-left corner of the Package Manager window and then choose the option Add package from git URL….
  • 🟢 Action: Enter the address com.unity.perception and click Add.

导入完成,并打开项目后需要更改项目相关设置:

Open Edit -> Project Settings -> Editor, and disable Asynchronous Shader Compilation.

Search for and select the asset named HDRP High Fidelity in your project, and set Lit Shader Mode to Both.

Synthetichumans

通过查阅官方文档完成设置。
因为整个包体积较大,实际采用先Clone后添加的到项目Package列表中的办法。

Add package from disk

在manifest.json中加入以下条目

1
2
"com.unity.cv.synthetichumans": "file:../../com.unity.cv.synthetichumans",
"com.unity.perception": "file:../../com.unity.perception",

Usage

Perception Camera

为相机添加Perception Camera组件,让此相机拥有相关能力。

Camera Labelers & Labeling

对于所需要的ground-truth数据,可以在Camera Labelers中注明。

labeler可以自己创建,Perception 包为我们已经为我们提供了以下常用的labelers:

keypoint labeling, 3D bounding boxes, 2D bounding boxes, object counts, object information (pixel counts and ids), instance segmentation, semantic segmentation, occlusion, depth, normals, and more.

对于一些labelers来说,可以在Unity中实时展示。Show Labeler Visulizations打上勾即可

我们需要告诉Perception Camera应该标记哪些物体。例如,我们想生成一个苹果的ground truth,我们就需要告诉Unity场景中的什么是苹果。场景中的苹果,应该带有”苹果“的标签。
image-20230227201610587 我们可以注意到,Camera Labelers中有ID Label Config字段,这是Perception Camera会去留意的标签的一些配置

创建一个ID Label Config

In the Project tab, right-click the Assets folder, then click Create → Perception → ID Label Config.
image-20230227202819009

我们可以将这个新创建的ID Label Config传给对应的Labeler

对于我们想要被标注的物体, 我们将为其添加Labeling组件。Labeling 表示此物体将携带一些与对应Label Config相联系的标签。可以看到,此处有Use Automatic Labeling字段,勾选时,将用一些规则(通常是此物体所在的文件夹名或资产名),使得此物体自动携带上标签。不勾选时,我们可以手动选择一些建议的标签,或者新建标签。在随后我们可以点击Add to Label Config将此标签添加到对应的Label Config

image-20230227203553862

每个物体都可以携带多个Labels,这样就可以实现不同的物体可以与不同的Camera Labelers交互。例如,我可以将苹果带上水果和苹果的标签,使得一种只关注水果的Camera Labelers获得信息,一种能够希望区分香蕉和苹果Camera Labelers获得相应的信息

我们可以使用Assets → Perception → Create Prefabs from Selected Models来快速导入.fbx的模型文件

Randomizers

随机器generation1

Inspect Synthetic Data

一般的,数据集将以SOLO的格式(数据的保存结构),通过一下方法,我们可以调节相关的设置

Open the Project Settings window, by selecting the menu Edit → Project Settings. Select Perception from the left panel. This will bring up the Perception Settings pane.