Skip to content

Commit 86a1fa4

Browse files
Fix keypoint issues (#259)
* Fixing two bugs in KeypointLabeler: AISV-1254 - Some keypoints fall outside of the image bounds AISV-1257 - Partially visible characters with no visible keypoints are not reported * Adding JointLabelEditor with message about Labeling requirement * Reorganizing keypoint docs and elaborating on setup requirements. * Updating PerceptionCamera.md * Fixing issues on 2020.2 and failing test * Add object filtering modes to keypoint labeler * Updating docs for object filtering * Adding link to tutorial * Moving KeypointLabeler.md to proper directory * Update TUTORIAL.md * Updating capitalization Co-authored-by: Mohsen K <[email protected]> * Apply doc suggestions Co-authored-by: Mohsen K <[email protected]> * Update PerceptionCamera.md based on feedback * Update CHANGELOG.md Co-authored-by: Mohsen K <[email protected]>
1 parent b4eb140 commit 86a1fa4

File tree

10 files changed

+459
-117
lines changed

10 files changed

+459
-117
lines changed

com.unity.perception/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1414
### Added
1515

1616
### Changed
17+
Expanded documentation on the Keypoint Labeler
18+
Updated Keypoint Labeler logic to only report keypoints for visible objects by default
1719

1820
### Deprecated
1921

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Keypoint Labeler
2+
3+
The Keypoint Labeler captures the screen locations of specific points on labeled GameObjects. The typical use of this Labeler is capturing human pose estimation data, but it can be used to capture points on any kind of object. The Labeler uses a [Keypoint Template](#KeypointTemplate) which defines the keypoints to capture for the model and the skeletal connections between those keypoints. The positions of the keypoints are recorded in pixel coordinates.
4+
5+
## Data Format
6+
The keypoints captured each frame are in the following format:
7+
```
8+
keypoints {
9+
label_id: <int> -- Integer identifier of the label
10+
instance_id: <str> -- UUID of the instance.
11+
template_guid: <str> -- UUID of the keypoint template
12+
pose: <str> -- Current pose
13+
keypoints [ -- Array of keypoint data, one entry for each keypoint defined in associated template file.
14+
{
15+
index: <int> -- Index of keypoint in template
16+
x: <float> -- X pixel coordinate of keypoint
17+
y: <float> -- Y pixel coordinate of keypoint
18+
state: <int> -- Visibility state
19+
}, ...
20+
]
21+
}
22+
```
23+
24+
The `state` entry has three possible values:
25+
* 0 - the keypoint either does not exist or is outside of the image's bounds
26+
* 1 - the keypoint exists inside of the image bounds but cannot be seen because the object is not visible at its location in the image
27+
* 2 - the keypoint exists and the object is visible at its location
28+
29+
The annotation definition, captured by the Keypoint Labeler once in each dataset, describes points being captured and their skeletal connections. These are defined by the [Keypoint Template](#KeypointTemplate).
30+
```
31+
annotation_definition.spec {
32+
template_id: <str> -- The UUID of the template
33+
template_name: <str> -- Human readable name of the template
34+
key_points [ -- Array of joints defined in this template
35+
{
36+
label: <str> -- The label of the joint
37+
index: <int> -- The index of the joint
38+
}, ...
39+
]
40+
skeleton [ -- Array of skeletal connections (which joints have connections between one another) defined in this template
41+
{
42+
joint1: <int> -- The first joint of the connection
43+
joint2: <int> -- The second joint of the connection
44+
}, ...
45+
]
46+
}
47+
```
48+
49+
## Setup
50+
The Keypoint Labeler captures keypoints each frame from each object in the scene that meets the following conditions:
51+
52+
* The object or its children are at least partially visible in the frame
53+
* The _Object Filter_ option on the Keypoint Labeler can be used to also include fully occluded or off-screen objects
54+
* The root object has a `Labeling` component
55+
* The object matches at least one entry in the Keypoint Template by either:
56+
* Containing an Animator with a [humanoid avatar](https://docs.unity3d.com/Manual/ConfiguringtheAvatar.html) whose rig matches a keypoint OR
57+
* Containing children with Joint Label components whose labels match keypoints
58+
59+
For a tutorial on setting up your project for keypoint labeling, see the [Human Pose Labeling and Randomization Tutorial](../HPTutorial/TUTORIAL.md).
60+
61+
## Keypoint Template
62+
63+
Keypoint Templates are used to define the keypoints and skeletal connections captured by the Keypoint Labeler. The Keypoint Template takes advantage of Unity's humanoid animation rig, and allows the user to automatically associate template keypoints to animation rig joints. Additionally, the user can choose to ignore the rigged points, or add points not defined in the rig.
64+
65+
A [COCO](https://cocodataset.org/#home) Keypoint Template is included in the Perception package.
66+
67+
### Editor
68+
69+
The Keypoint Template editor allows the user to create/modify a Keypoint Template. The editor consists of the header information, the keypoint array, and the skeleton array.
70+
71+
![Header section of the keypoint template](../images/keypoint_template_header.png)
72+
<br/>_Header section of the keypoint template_
73+
74+
In the header section, a user can change the name of the template and supply textures that they would like to use for the keypoint visualization.
75+
76+
![The keypoint section of the keypoint template](../images/keypoint_template_keypoints.png)
77+
<br/>_Keypoint section of the keypoint template_
78+
79+
The keypoint section allows the user to create/edit keypoints and associate them with Unity animation rig points. Each keypoint record
80+
has 4 fields: label (the name of the keypoint), Associate to Rig (a boolean value which, if true, automatically maps the keypoint to
81+
the GameObject defined by the rig), Rig Label (only needed if Associate To Rig is true, defines which rig component to associate with
82+
the keypoint), and Color (RGB color value of the keypoint in the visualization).
83+
84+
![Skeleton section of the keypoint template](../images/keypoint_template_skeleton.png)
85+
<br/>_Skeleton section of the keypoint template_
86+
87+
The skeleton section allows the user to create connections between joints, basically defining the skeleton of a labeled object.
88+
89+
#### Animation Pose Label
90+
91+
This file is used to define timestamps in an animation to a pose label.

com.unity.perception/Documentation~/HPTutorial/TUTORIAL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ You can now check out the output dataset to see what the annotations look like.
248248
}
249249
```
250250

251-
In the above annotation, all of the 18 joints defined in the COCO template we used are listed. For each joint that is present in our character, you can see the X and Y coordinates within the captured frame. However, you may notice three of the joints are listed with (0,0) coordinates. These joints are not present in our character. A fact that is also denoted by the `state` field. A state of **0** means the joint was not present, **1** denotes a joint that is present but not visible (to be implemented in a later version of the package), and **2** means the joint was present and visible.
251+
In the above annotation, all of the 18 joints defined in the COCO template we used are listed. For each joint that is present in our character, you can see the X and Y coordinates within the captured frame. However, you may notice three of the joints are listed with (0,0) coordinates. These joints are not present in our character. A fact that is also denoted by the `state` field. A state of **0** means the joint either does not exist or is outside of the image's bounds, **1** denotes a joint that is inside of the image but cannot be seen because the part of the object it belongs to is not visible in the image, and **2** means the joint was present and visible.
252252

253253
You may also note that the `pose` field has a value of `unset`. This is because we have not defined poses for our animation clip and `Perception Camera` yet. We will do this next.
254254

com.unity.perception/Documentation~/PerceptionCamera.md

Lines changed: 4 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -75,83 +75,13 @@ The ObjectCountLabeler records object counts for each label you define in the Id
7575
```
7676
_Example rendered object info for a single object_
7777

78-
The RenderedObjectInfoLabeler records a list of all objects visible in the Camera image, including its instance ID, resolved label ID and visible pixels. If Unity cannot resolve objects to a label in the IdLabelConfig, it does not record these objects.
78+
The `RenderedObjectInfoLabeler` records a list of all objects visible in the camera image, including their instance IDs, resolved label IDs, and visible pixel counts. If Unity cannot resolve objects to a label in the `IdLabelConfig`, it does not record these objects.
7979

80-
### KeypointLabeler
80+
### Keypoint Labeler
8181

82-
The keypoint labeler captures keypoints of a labeled gameobject. The typical use of this labeler is capturing human pose estimation data. The labeler uses a [keypoint template](#KeypointTemplate) which defines the keypoints to capture for the model and the skeletal connections between those keypoints. The positions of the keypoints are recorded in pixel coordinates. Each keypoint has a state value: 0 - the keypoint either does not exist or is outside of the image's bounds, 1 - the keypoint exists and is inside of the image's bounds but cannot be seen because it is occluded by another object, and 2 - the keypoint exists and is visible.
82+
The keypoint labeler captures the screen locations of specific points on labeled GameObjects. The typical use of this Labeler is capturing human pose estimation data, but it can be used to capture points on any kind of object. The Labeler uses a [Keypoint Template](#KeypointTemplate) which defines the keypoints to capture for the model and the skeletal connections between those keypoints. The positions of the keypoints are recorded in pixel coordinates.
8383

84-
```
85-
keypoints {
86-
label_id: <int> -- Integer identifier of the label
87-
instance_id: <str> -- UUID of the instance.
88-
template_guid: <str> -- UUID of the keypoint template
89-
pose: <str> -- Pose ground truth information
90-
keypoints [ -- Array of keypoint data, one entry for each keypoint defined in associated template file.
91-
{
92-
index: <int> -- Index of keypoint in template
93-
x: <float> -- X pixel coordinate of keypoint
94-
y: <float> -- Y pixel coordinate of keypoint
95-
state: <int> -- 0: keypoint does not exist, 1: keypoint exists but is not visible, 2: keypoint exists and is visible
96-
}, ...
97-
]
98-
}
99-
```
100-
101-
#### Keypoint Template
102-
103-
keypoint templates are used to define the keypoints and skeletal connections captured by the KeypointLabeler. The keypoint
104-
template takes advantage of Unity's humanoid animation rig, and allows the user to automatically associate template keypoints
105-
to animation rig joints. Additionally, the user can choose to ignore the rigged points, or add points not defined in the rig.
106-
A Coco keypoint template is included in the perception package.
107-
108-
##### Editor
109-
110-
The keypoint template editor allows the user to create/modify a keypoint template. The editor consists of the header information,
111-
the keypoint array, and the skeleton array.
112-
113-
![Header section of the keypoint template](images/keypoint_template_header.png)
114-
<br/>_Header section of the keypoint template_
115-
116-
In the header section, a user can change the name of the template and supply textures that they would like to use for the keypoint
117-
visualization.
118-
119-
![The keypoint section of the keypoint template](images/keypoint_template_keypoints.png)
120-
<br/>_Keypoint section of the keypoint template_
121-
122-
The keypoint section allows the user to create/edit keypoints and associate them with Unity animation rig points. Each keypoint record
123-
has 4 fields: label (the name of the keypoint), Associate to Rig (a boolean value which, if true, automatically maps the keypoint to
124-
the gameobject defined by the rig), Rig Label (only needed if Associate To Rig is true, defines which rig component to associate with
125-
the keypoint), and Color (RGB color value of the keypoint in the visualization).
126-
127-
![Skeleton section of the keypoint template](images/keypoint_template_skeleton.png)
128-
<br/>_Skeleton section of the keypoint template_
129-
130-
The skeleton section allows the user to create connections between joints, basically defining the skeleton of a labeled object.
131-
132-
##### Format
133-
```
134-
annotation_definition.spec {
135-
template_id: <str> -- The UUID of the template
136-
template_name: <str> -- Human readable name of the template
137-
key_points [ -- Array of joints defined in this template
138-
{
139-
label: <str> -- The label of the joint
140-
index: <int> -- The index of the joint
141-
}, ...
142-
]
143-
skeleton [ -- Array of skeletal connections (which joints have connections between one another) defined in this template
144-
{
145-
joint1: <int> -- The first joint of the connection
146-
joint2: <int> -- The second joint of the connection
147-
}, ...
148-
]
149-
}
150-
```
151-
152-
#### Animation Pose Label
153-
154-
This file is used to define timestamps in an animation to a pose label.
84+
For more information, see [Keypoint Labeler](GroundTruth/KeypointLabeler.md) or the [Human Pose Labeling and Randomization Tutorial](HPTutorial/TUTORIAL.md)
15585

15686
## Limitations
15787

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System.Linq;
2+
using UnityEngine;
3+
using UnityEngine.Perception.GroundTruth;
4+
5+
namespace UnityEditor.Perception.GroundTruth
6+
{
7+
[CustomEditor(typeof(JointLabel))]
8+
public class JointLabelEditor : Editor
9+
{
10+
public override void OnInspectorGUI()
11+
{
12+
base.OnInspectorGUI();
13+
#if UNITY_2020_1_OR_NEWER
14+
//GetComponentInParent<T>(bool includeInactive) only exists on 2020.1 and later
15+
if (targets.Any(t => ((Component)t).gameObject.GetComponentInParent<Labeling>(true) == null))
16+
#else
17+
if (targets.Any(t => ((Component)t).GetComponentInParent<Labeling>() == null))
18+
#endif
19+
EditorGUILayout.HelpBox("No Labeling component detected on parents. Keypoint labeling requires a Labeling component on the root of the object.", MessageType.Info);
20+
}
21+
}
22+
}

com.unity.perception/Editor/GroundTruth/JointLabelEditor.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)