您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

3.3 KiB

FAQ and Code Samples

This page covers a variety of topics, including common questions and issues that may arise while using the Perception package, as well as code samples and recommendations for a number of popular workflows and use-cases.

Labeling

Q: How can I disable or enable labeling on an object at runtime?

A: You can turn labeling on and off on a GameObject by switching the enabled state of its Labeling component. For example:

gameObject.GetComponent<Labeling>().enabled = false;  
Q: How can I remove or add new labels to objects at runtime?

This can be achieved through modifying the labels list of the Labeling component. The key is to call RefreshLabeling on the component after making any changes to the labels. Example:

var labeling = gameObject.GetComponent<Labeling>();
labeling.labels.Clear();
labeling.labels.Add("new-label");
labeling.RefreshLabeling();

Keep in mind that any new label added with this method should already be present in the LabelConfig attached to the Labeler that is supposed to label this object.

Q: Is it possible to label only parts of an object or assign different labels to different parts of objects?

Labeling works on the GameObject level, so to achieve the scenarios described here, you will need to break down your main object into multiple GameObjects parented to the same root object, and add Labeling components to each of the inner objects, as shown below.

Alternatively, in cases where parts of the surface of the object need to be labeled (e.g. decals on objects), you can add labeled invisible surfaces on top of these sections. These invisible surfaces need to have a fully transparent material. To create an invisible material:

  • Create a new material (Assets -> Create -> Material) and name it TransparentMaterial
  • Set the Surface Type for the material to Transparent, and set the alpha channel of the Base Map color to 0.
    • For HDRP: In addition to the above, disable Preserve specular lighting

An example labeled output for an object with separate labels on inner objects is shown below:

Q:

When visible surfaces of two objects are fully aligned, the bounding boxes seem to blink in and out of existence from one frame to another. Why is that?

This is due to a common graphics problem called z-fighting. This occurs when the shader can't decide which of the two surfaces to draw on top of the other, since they both have the exact same distance from the camera. To fix this, simply move one of the objects slightly so that the two problematic surfaces do not fully align.

Randomization

Q:

I need to randomize the rotation of my objects in such a way that they always face the camera, but rotate in other directions. How can I achieve that with a Randomizer?

Perception Camera

Capture and Dataset Format

Miscellaneous