Skip to content

Commit 909fcec

Browse files
JonathanHUnityWesley201mkamalzamrpropellersPriyeshWani
authored
Merge master to 0.8.0 (#265)
* addressed feedback - new test for keypoint labeler - added ClearMaterialProperties method to IGroundTruthGenerator - Other fixes * docs clarification * Update CHANGELOG.md * added missing interface method implementation for HDRP * Amending dataset schema to describe correct coordinate system (#255) The summary for the 3d bounding box states the coordinates are from the sensor's reference frame, but the string for the translational component says it's global. I *think* this is just a typo in the doc, so correcting the description to match the summary for this type of entry. * Adding supported version badges (#256) * Cloud rendering support (#227) * Adding support for cloud rendering in the run simulation window * minor fixes * minor update * Update BoundingBox3DLabeler.cs * Update BoundingBox3DLabeler.cs * inner mesh scaling and disabled renderes * A fix that prevents normal sampler returning values outside of min max (#258) * Update pull_request_template.md (#257) * Update com.unity.perception/CHANGELOG.md * Increasing color variety in instance segmentation. (#261) * Increasing color variety in instance segmentation. * Fixing duplicated color issues in InstanceIdToColorMapping introduced after expanding range. * Using other constants in constant for cleanliness Co-authored-by: Mohsen Kamalzadeh <> Co-authored-by: Wesley Smith <wesley@unity3d.com> Co-authored-by: Mohsen K <mohsen.kamalzadeh@unity3d.com> Co-authored-by: Devin Miller (Unity) <mrpropellers@users.noreply.github.com> Co-authored-by: PriyeshWani <priyesh@unity3d.com> Co-authored-by: Steve Borkman <66975693+StevenBorkman@users.noreply.github.com>
1 parent 86a1fa4 commit 909fcec

File tree

20 files changed

+313
-164
lines changed

20 files changed

+313
-164
lines changed

.github/pull_request_template.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Peer Review Information:
2-
Information on any code, feature, documentation changes here
32

43
## Editor / Package versioning:
5-
**Editor Version Target (i.e. 19.3, 20.1)**: 2019.3
4+
**Editor Version Target**: 2019.4
65

76
## Dev Testing:
87
**Tests Added**:
@@ -11,8 +10,7 @@ Information on any code, feature, documentation changes here
1110

1211
**At Risk Areas**:
1312

14-
**Notes + Expectations**:
15-
1613
## Checklist
1714
- [ ] - Updated docs
1815
- [ ] - Updated changelog
16+
- [ ] - Updated test rail

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
[![license badge](https://img.shields.io/badge/license-Apache--2.0-green.svg)](LICENSE.md)
88

9+
<img src="https://img.shields.io/badge/unity-2019.4-green.svg?style=flat-square" alt="unity 2019.4">
10+
<img src="https://img.shields.io/badge/unity-2020.2-green.svg?style=flat-square" alt="unity 2020.2">
11+
912
> com.unity.perception is in active development. Its features and API are subject to significant change as development progresses.
1013
1114

TestProjects/PerceptionHDRP/Packages/packages-lock.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"com.unity.collections": "0.9.0-preview.6",
8282
"com.unity.nuget.newtonsoft-json": "1.1.2",
8383
"com.unity.render-pipelines.core": "7.1.6",
84-
"com.unity.simulation.capture": "0.0.10-preview.19",
84+
"com.unity.simulation.capture": "0.0.10-preview.20",
8585
"com.unity.simulation.client": "0.0.10-preview.10",
8686
"com.unity.simulation.core": "0.0.10-preview.22"
8787
}
@@ -126,7 +126,7 @@
126126
"url": "https://packages.unity.com"
127127
},
128128
"com.unity.simulation.capture": {
129-
"version": "0.0.10-preview.19",
129+
"version": "0.0.10-preview.20",
130130
"depth": 1,
131131
"source": "registry",
132132
"dependencies": {

com.unity.perception/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1616
### Changed
1717
Expanded documentation on the Keypoint Labeler
1818
Updated Keypoint Labeler logic to only report keypoints for visible objects by default
19+
Increased color variety in instance segmentation images
1920

2021
### Deprecated
2122

@@ -25,6 +26,8 @@ Updated Keypoint Labeler logic to only report keypoints for visible objects by d
2526

2627
Fixed compiler warnings in projects with HDRP on 2020.1 and later
2728

29+
Fixed a bug in the Normal Sampler where it would return values less than the passed in minimum value, or greater than the passed in maximum value, for random values very close to 0 or 1 respectively.
30+
2831
## [0.8.0-preview.2] - 2021-03-15
2932

3033
### Upgrade Notes
@@ -33,6 +36,8 @@ All appearances of the term `KeyPoint` have been renamed to `Keypoint`. If you h
3336

3437
`ScenarioBase`'s `Awake()`, `Start()`, and `Update()` functions are now private. If you previously used these, replace the usages with `OnAwake()`, `OnStart()`, and `OnUpdate()`.
3538

39+
The interface `IGroundTruthGenerator` now contains a new method named `ClearMaterialProperties` for disabling ground truth generation on a `Labeling` component or its associated `MaterialPropertyBlock`. Update your implementing classes to including this method.
40+
3641
### Known Issues
3742

3843
### Added
@@ -55,7 +60,7 @@ The newly added `LabelManager` class now enables custom Labelers to access the l
5560

5661
Improved UI for `KeypointTemplate` and added useful default colors for keypoint and skeleton definitions.
5762

58-
Added the ability to switch ground-truth labeling on or off for an object at runtime by enabling or disabling its `Labeling` component.
63+
Added the ability to switch ground truth generation on or off for an object at runtime by enabling or disabling its `Labeling` component. A new method named `ClearMaterialProperties()` in `IGroundTruthGenerator` handles this functionality.
5964

6065
### Changed
6166

com.unity.perception/Documentation~/Schema/Synthetic_Dataset_Schema.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ bounding_box_3d {
216216
label_id: <int> -- Integer identifier of the label
217217
label_name: <str> -- String identifier of the label
218218
instance_id: <str> -- UUID of the instance.
219-
translation { -- 3d bounding box's center location in meters with respect to global coordinate system.
219+
translation { -- 3d bounding box's center location in meters with respect to the sensor's coordinate system
220220
x: <float> -- The x coordinate
221221
y: <float> -- The y coordinate
222222
z: <float> -- The z coordinate

com.unity.perception/Editor/Randomization/Editors/RunInUnitySimulationWindow.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class RunInUnitySimulationWindow : EditorWindow
3535
Label m_PrevExecutionIdLabel;
3636
RunParameters m_RunParameters;
3737

38+
const string m_SupportedGPUString = "NVIDIA";
39+
3840
[MenuItem("Window/Run in Unity Simulation")]
3941
static void ShowWindow()
4042
{
@@ -166,6 +168,15 @@ static string IncrementRunName(string runName)
166168

167169
async void RunInUnitySimulation()
168170
{
171+
#if PLATFORM_CLOUD_RENDERING
172+
if (!m_SysParamDefinitions[m_SysParamIndex].description.Contains(m_SupportedGPUString))
173+
{
174+
EditorUtility.DisplayDialog("Unsupported Sysparam",
175+
"The current selection of the Sysparam " + m_SysParamDefinitions[m_SysParamIndex].description +
176+
" is not supported by this build target. Please select a sysparam with GPU", "Ok");
177+
return;
178+
}
179+
#endif
169180
m_RunParameters = new RunParameters
170181
{
171182
runName = m_RunNameField.value,
@@ -228,7 +239,11 @@ void CreateLinuxBuildAndZip()
228239
{
229240
scenes = new[] { m_RunParameters.currentOpenScenePath },
230241
locationPathName = Path.Combine(projectBuildDirectory, $"{m_RunParameters.runName}.x86_64"),
242+
#if PLATFORM_CLOUD_RENDERING
243+
target = BuildTarget.CloudRendering,
244+
#else
231245
target = BuildTarget.StandaloneLinux64
246+
#endif
232247
};
233248
var report = BuildPipeline.BuildPlayer(buildPlayerOptions);
234249
var summary = report.summary;

com.unity.perception/Runtime/GroundTruth/IGroundTruthGenerator.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@ namespace UnityEngine.Perception.GroundTruth
88
public interface IGroundTruthGenerator
99
{
1010
/// <summary>
11-
/// Called by <see cref="LabelManager"/> when first registered or when a Labeling is created at runtime.
11+
/// Enables ground truth generation for a <see cref="Labeling"/> component or its associated <see cref="MaterialPropertyBlock"/>. This function is called by <see cref="LabelManager"/> when a <see cref="Labeling"/> component is registered, created, or enabled.
1212
/// </summary>
13-
/// <param name="mpb">The MaterialPropertyBlock for the given meshRenderer. Can be used to set properties for custom rendering.</param>
14-
/// <param name="renderer">The Renderer under the given Labeling.</param>
15-
/// <param name="labeling">The Labeling component created</param>
16-
/// <param name="instanceId">The instanceId assigned to the given Labeling instance.</param>
13+
/// <param name="mpb">The <see cref="MaterialPropertyBlock"/> for the given <see cref="MeshRenderer"/>. Can be used to set properties for custom rendering.</param>
14+
/// <param name="renderer">The <see cref="Renderer"/> under the given <see cref="LabelManager"/>.</param>
15+
/// <param name="labeling">The <see cref="LabelManager"/> component that was registered, created, or enabled</param>
16+
/// <param name="instanceId">The instanceId assigned to the given <see cref="LabelManager"/> instance.</param>
1717
void SetupMaterialProperties(MaterialPropertyBlock mpb, Renderer renderer, Labeling labeling, uint instanceId);
18+
19+
/// <summary>
20+
/// Disables ground truth generation for a <see cref="Labeling"/> component or its associated <see cref="MaterialPropertyBlock"/>. This function is called by <see cref="LabelManager"/> when a <see cref="Labeling"/> component is disabled.
21+
/// </summary>
22+
/// <param name="mpb">The <see cref="MaterialPropertyBlock"/> for the given <see cref="MeshRenderer"/>. Can be used to set properties for custom rendering.</param>
23+
/// <param name="renderer">The <see cref="Renderer"/> under the given <see cref="LabelManager"/>.</param>
24+
/// <param name="labeling">The <see cref="LabelManager"/> component for which ground-truth generation should stop.</param>
25+
/// <param name="instanceId">The instanceId assigned to the given <see cref="LabelManager"/> instance.</param>
26+
void ClearMaterialProperties(MaterialPropertyBlock mpb, Renderer renderer, Labeling labeling, uint instanceId);
1827
}
1928
}

com.unity.perception/Runtime/GroundTruth/InstanceIdToColorMapping.cs

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using Unity.Profiling;
34

45
namespace UnityEngine.Perception.GroundTruth
56
{
@@ -21,42 +22,53 @@ public static class InstanceIdToColorMapping
2122
/// </summary>
2223
public const uint maxId = uint.MaxValue - ((256 * 256 * 256) * 2) + k_HslCount;
2324

24-
static Dictionary<uint, uint> s_IdToColorCache;
25+
static uint[] s_IdToColorCache;
2526
static Dictionary<uint, uint> s_ColorToIdCache;
26-
const uint k_HslCount = 64;
27+
const uint k_HslCount = 1024;
2728
const uint k_ColorsPerAlpha = 256 * 256 * 256;
2829
const uint k_InvalidPackedColor = 255; // packed uint for color (0, 0, 0, 255);
29-
public static readonly Color32 invalidColor = new Color(0, 0, 0, 255);
3030
static readonly float k_GoldenRatio = (1 + Mathf.Sqrt(5)) / 2;
31-
const int k_HuesInEachValue = 30;
32-
33-
static void InitializeMaps()
34-
{
31+
const int k_HuesInEachValue = 64;
32+
const uint k_Values = k_HslCount / k_HuesInEachValue;
3533

36-
s_IdToColorCache = new Dictionary<uint, uint>();
37-
s_ColorToIdCache = new Dictionary<uint, uint>();
38-
39-
s_IdToColorCache[0] = k_InvalidPackedColor;
40-
s_IdToColorCache[k_InvalidPackedColor] = 0;
34+
/// <summary>
35+
/// The color returned when an instanceId is not mapped to any color, and for clearing ground truth material properties on a <see cref="MaterialPropertyBlock"/>.
36+
/// </summary>
37+
public static readonly Color32 invalidColor = new Color(0, 0, 0, 255);
4138

42-
for (uint i = 1; i <= k_HslCount; i++)
39+
private static ProfilerMarker k_InitializeMapsMarker = new ProfilerMarker(nameof(InitializeMaps));
40+
internal static void InitializeMaps()
41+
{
42+
using (k_InitializeMapsMarker.Auto())
4343
{
44-
var color = GenerateHSLValueForId(i);
45-
s_IdToColorCache[i] = color;
46-
s_ColorToIdCache[color] = i;
44+
s_IdToColorCache = new uint[k_HslCount + 1];
45+
s_ColorToIdCache = new Dictionary<uint, uint>();
46+
47+
s_IdToColorCache[0] = k_InvalidPackedColor;
48+
s_ColorToIdCache[k_InvalidPackedColor] = 0;
49+
50+
for (uint i = 1; i <= k_HslCount; i++)
51+
{
52+
var color = GenerateHSLValueForId(i);
53+
s_IdToColorCache[i] = color;
54+
s_ColorToIdCache.Add(color, i);
55+
}
4756
}
4857
}
4958

5059
static uint GenerateHSLValueForId(uint count)
5160
{
5261
count -= 1;
5362

54-
var ratio = count * k_GoldenRatio;
63+
// assign hue based on golden ratio
64+
var hueId = count % k_HuesInEachValue;
65+
var ratio = hueId * k_GoldenRatio;
5566
var hue = ratio - Mathf.Floor(ratio);
5667

57-
count /= k_HuesInEachValue;
58-
ratio = count * k_GoldenRatio;
59-
var value = 1 - (ratio - Mathf.Floor(ratio));
68+
var valueId = count / k_HuesInEachValue;
69+
70+
// avoid value 0
71+
var value = 1 - (float)valueId / (k_Values + 1);
6072

6173
var color = (Color32)Color.HSVToRGB(hue, 1f, value);
6274
color.a = 255;

com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBox3DLabeler.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ void ProcessLabel(Labeling labeledEntity)
248248
// Need to convert all bounds into labeling mesh space...
249249
foreach (var mesh in meshFilters)
250250
{
251+
if (!mesh.GetComponent<Renderer>().enabled)
252+
continue;
253+
251254
var currentTransform = mesh.gameObject.transform;
252255
// Grab the bounds of the game object from the mesh, although these bounds are axis-aligned,
253256
// they are axis-aligned with respect to the current component's coordinate space. This, in theory
@@ -260,6 +263,8 @@ void ProcessLabel(Labeling labeledEntity)
260263
// Apply the transformations on this object until we reach the labeled transform
261264
while (currentTransform != labelTransform)
262265
{
266+
transformedBounds.center = Vector3.Scale(transformedBounds.center, currentTransform.localScale);
267+
transformedBounds.center = currentTransform.localRotation * transformedBounds.center;
263268
transformedBounds.center += currentTransform.localPosition;
264269
transformedBounds.extents = Vector3.Scale(transformedBounds.extents, currentTransform.localScale);
265270
transformedRotation *= currentTransform.localRotation;
@@ -287,7 +292,7 @@ void ProcessLabel(Labeling labeledEntity)
287292

288293
// Convert the combined bounds into world space
289294
combinedBounds.center = labelTransform.TransformPoint(combinedBounds.center);
290-
combinedBounds.extents = Vector3.Scale(combinedBounds.extents, labelTransform.localScale);
295+
combinedBounds.extents = Vector3.Scale(combinedBounds.extents, labelTransform.lossyScale);
291296

292297
// Now convert all points into camera's space
293298
var cameraCenter = cameraTransform.InverseTransformPoint(combinedBounds.center);

0 commit comments

Comments
 (0)