Skip to content

Commit 4deadb5

Browse files
RC 0.11.1-preview.1
1 parent 0a6113c commit 4deadb5

37 files changed

+2091
-201
lines changed

com.unity.perception/CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,30 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2121

2222
### Fixed
2323

24+
## [0.11.1-preview.1] - 2022-04-13
25+
26+
### Added
27+
28+
Added the ability to define the output of a standalone player with an '--output-path' command line argument
29+
30+
### Changed
31+
32+
Exceptions thrown in randomizers will now end the run
33+
34+
Duplicates in categorical parameters are checked and reported
35+
36+
User output paths are now written out in user's settings
37+
38+
### Fixed
39+
40+
Fixed captured RGB images being upside down or dark in various cases
41+
42+
Fixed UI when there are many randomizers in the project
43+
44+
Fixed Scenario UI when the last randomizer is removed
45+
46+
Fixed the Visualizer installation bug, Visualizer can be installed and opened properly now.
47+
2448
## [0.10.0-preview.1] - 2022-03-09
2549

2650
### Upgrade Notes

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

Lines changed: 75 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,55 +14,90 @@ You can register custom sensors using `DatasetCapture.RegisterSensor()`. The `si
1414
`Time.captureDeltaTime` is set at every frame in order to precisely fall on the next sensor that requires simulation, and this includes multi-sensor simulations. For instance, if one sensor has a `simulationDeltaTime` of 2 and another 3, the first five values for `Time.captureDeltaTime` will be 2, 1, 1, 2, and 3, meaning simulation will happen on the timestamps 0, 2, 3, 4, 6, and 9.
1515

1616
## Custom annotations and metrics
17-
In addition to the common annotations and metrics produced by [PerceptionCamera](PerceptionCamera.md), scripts can produce their own via `DatasetCapture`. You must first register annotation and metric definitions using `DatasetCapture.RegisterAnnotationDefinition()` or `DatasetCapture.RegisterMetricDefinition()`. These return `AnnotationDefinition` and `MetricDefinition` instances which you can then use to report values during runtime.
17+
In addition to the common annotations and metrics produced by [PerceptionCamera](PerceptionCamera.md), scripts can produce their own via `DatasetCapture`. You must first create and register annotation and metric definitions using `DatasetCapture.RegisterAnnotationDefinition()` or `DatasetCapture.RegisterMetric()`. These are used~~~~ to report values during runtime.
1818

1919
Annotations and metrics are always associated with the frame they are reported in. They may also be associated with a specific sensor by using the `Report*` methods on `SensorHandle`.
2020

2121
### Example
22-
<!-- If you change this, change it in PerceptionURP/Assets/Examples/CustomAnnotationAndMetricReporter.cs as well -->
2322
```csharp
2423
using System;
2524
using UnityEngine;
2625
using UnityEngine.Perception.GroundTruth;
26+
using UnityEngine.Perception.GroundTruth.DataModel;
27+
using UnityEngine.Rendering;
2728

28-
[RequireComponent(typeof(PerceptionCamera))]
29-
public class CustomAnnotationAndMetricReporter : MonoBehaviour
29+
public class CustomLabeler : CameraLabeler
3030
{
31+
public override string description => "Demo labeler";
32+
public override string labelerId => "Demo labeler";
33+
protected override bool supportsVisualization => false;
34+
3135
public GameObject targetLight;
3236
public GameObject target;
3337

3438
MetricDefinition lightMetricDefinition;
35-
AnnotationDefinition boundingBoxAnnotationDefinition;
36-
SensorHandle cameraSensorHandle;
39+
AnnotationDefinition targetPositionDef;
3740

38-
public void Start()
41+
class TargetPositionDef : AnnotationDefinition
3942
{
40-
//Metrics and annotations are registered up-front
41-
lightMetricDefinition = DatasetCapture.RegisterMetricDefinition(
42-
"Light position",
43-
"The world-space position of the light",
44-
Guid.Parse("1F6BFF46-F884-4CC5-A878-DB987278FE35"));
45-
boundingBoxAnnotationDefinition = DatasetCapture.RegisterAnnotationDefinition(
46-
"Target bounding box",
47-
"The position of the target in the camera's local space",
48-
id: Guid.Parse("C0B4A22C-0420-4D9F-BAFC-954B8F7B35A7"));
43+
public TargetPositionDef(string id)
44+
: base(id) { }
45+
46+
public override string modelType => "targetPosDef";
47+
public override string description => "The position of the target in the camera's local space";
4948
}
5049

51-
public void Update()
50+
[Serializable]
51+
class TargetPosition : Annotation
52+
{
53+
public TargetPosition(AnnotationDefinition definition, string sensorId, Vector3 pos)
54+
: base(definition, sensorId)
55+
{
56+
position = pos;
57+
}
58+
59+
public Vector3 position;
60+
61+
public override void ToMessage(IMessageBuilder builder)
62+
{
63+
base.ToMessage(builder);
64+
builder.AddFloatArray("position", MessageBuilderUtils.ToFloatVector(position));
65+
}
66+
67+
public override bool IsValid() => true;
68+
69+
}
70+
71+
protected override void Setup()
72+
{
73+
lightMetricDefinition =
74+
new MetricDefinition(
75+
"LightMetric",
76+
"lightMetric1",
77+
"The world-space position of the light");
78+
DatasetCapture.RegisterMetric(lightMetricDefinition);
79+
80+
targetPositionDef = new TargetPositionDef("target1");
81+
DatasetCapture.RegisterAnnotationDefinition(targetPositionDef);
82+
}
83+
84+
protected override void OnBeginRendering(ScriptableRenderContext scriptableRenderContext)
5285
{
5386
//Report the light's position by manually creating the json array string.
5487
var lightPos = targetLight.transform.position;
55-
DatasetCapture.ReportMetric(lightMetricDefinition,
56-
$@"[{{ ""x"": {lightPos.x}, ""y"": {lightPos.y}, ""z"": {lightPos.z} }}]");
88+
var metric = new GenericMetric(new[] { lightPos.x, lightPos.y, lightPos.z }, lightMetricDefinition);
89+
DatasetCapture.ReportMetric(lightMetricDefinition, metric);
90+
5791
//compute the location of the object in the camera's local space
58-
Vector3 targetPos = transform.worldToLocalMatrix * target.transform.position;
92+
Vector3 targetPos = perceptionCamera.transform.worldToLocalMatrix * target.transform.position;
93+
5994
//Report using the PerceptionCamera's SensorHandle if scheduled this frame
60-
var sensorHandle = GetComponent<PerceptionCamera>().SensorHandle;
95+
var sensorHandle = perceptionCamera.SensorHandle;
96+
6197
if (sensorHandle.ShouldCaptureThisFrame)
6298
{
63-
sensorHandle.ReportAnnotationValues(
64-
boundingBoxAnnotationDefinition,
65-
new[] { targetPos });
99+
var annotation = new TargetPosition(targetPositionDef, sensorHandle.Id, targetPos);
100+
sensorHandle.ReportAnnotation(targetPositionDef, annotation);
66101
}
67102
}
68103
}
@@ -73,21 +108,26 @@ public class CustomAnnotationAndMetricReporter : MonoBehaviour
73108
// "annotation_id": null,
74109
// "sequence_id": "9768671e-acea-4c9e-a670-0f2dba5afe12",
75110
// "step": 1,
76-
// "metric_definition": "1f6bff46-f884-4cc5-a878-db987278fe35",
77-
// "values": [{ "x": 96.1856, "y": 192.676, "z": -193.8386 }]
111+
// "metric_definition": "lightMetric1",
112+
// "values": [
113+
// 96.1856,
114+
// 192.675964,
115+
// -193.838638
116+
// ]
78117
// },
79118
80119
// Example annotation that is added to each capture in the dataset:
81120
// {
82-
// "id": "33f5a3aa-3e5e-48f1-8339-6cbd64ed4562",
83-
// "annotation_definition": "c0b4a22c-0420-4d9f-bafc-954b8f7b35a7",
84-
// "values": [
85-
// [
86-
// -1.03097284,
87-
// 0.07265166,
88-
// -6.318692
121+
// "annotation_id": "target1",
122+
// "model_type": "targetPosDef",
123+
// "description": "The position of the target in the camera's local space",
124+
// "sensor_id": "camera",
125+
// "id": "target1",
126+
// "position": [
127+
// 1.85350215,
128+
// -0.253945172,
129+
// -5.015307
89130
// ]
90-
// ]
91131
// }
92132
93-
```
133+
```

com.unity.perception/Editor/Randomization/Uxml/Randomizer/AddRandomizerMenu.uxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<TextElement name="directory-label-text" text="Randomizers" style="-unity-font-style: bold; padding: 3px;"/>
88
<VisualElement/>
99
</VisualElement>
10-
<VisualElement name="menu-options"/>
10+
<ScrollView name="menu-options"/>
1111
<VisualElement class="randomizer__menu-search-icon"/>
1212
</VisualElement>
1313
</UXML>

com.unity.perception/Editor/Randomization/VisualElements/Randomizer/RandomizerList.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ void RefreshList()
6666
return;
6767
}
6868

69+
if (m_Property.arraySize == 0)
70+
{
71+
var textElement = new TextElement()
72+
{
73+
text = "No randomizers added. Add any to resume"
74+
};
75+
textElement.AddToClassList("scenario__error-box");
76+
m_Container.Add(textElement);
77+
}
78+
6979
for (var i = 0; i < m_Property.arraySize; i++)
7080
m_Container.Add(new RandomizerElement(m_Property.GetArrayElementAtIndex(i), this));
7181
}

com.unity.perception/Editor/Visualizer/VisualizerInstaller.cs

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,34 +41,48 @@ const string k_NameOfVisualizerProcess
4141
#elif UNITY_EDITOR_WIN
4242
= "datasetvisualizer";
4343
#endif
44-
45-
internal static Task InstallationCommand(ref int exitCode, string packagesPath)
44+
45+
internal static Task InstallationCommand(ref int exitCode, string packagesPath, bool forcePublic)
46+
{
47+
var exitCodeCopy = exitCode;
48+
var pythonPath = Path.Combine(Directory.GetParent(packagesPath)?.ToString() ?? string.Empty, "python.exe");
49+
50+
var indexURL = forcePublic ? string.Empty : GetIndexURL();
51+
52+
#if UNITY_EDITOR_WIN
53+
var task = Task.Run(() => ExecuteCmd($"{pythonPath} -m pip install --upgrade --no-warn-script-location unity-cv-datasetvisualizer {indexURL}", ref exitCodeCopy));
54+
#elif UNITY_EDITOR_OSX
55+
var task = Task.Run(() => ExecuteCmd($"cd {packagesPath}; ./python3.7 -m pip install --upgrade unity-cv-datasetvisualizer {indexURL}", ref exitCodeCopy));
56+
#endif
57+
exitCode = exitCodeCopy;
58+
return task;
59+
}
60+
61+
internal static Task UninstallCommand(ref int exitCode, string packagesPath)
4662
{
4763
var exitCodeCopy = exitCode;
48-
var pythonPath = packagesPath + "\\..\\python.exe";
49-
var index_url = get_index_url();
64+
var pythonPath = Path.Combine(Directory.GetParent(packagesPath)?.ToString() ?? string.Empty, "Scripts");
5065
#if UNITY_EDITOR_WIN
51-
var task = Task.Run(() => ExecuteCmd($"\"{pythonPath}\" -m pip install --upgrade --no-warn-script-location unity-cv-datasetvisualizer\"{index_url}\"", ref exitCodeCopy));
66+
var task = Task.Run(() => ExecuteCmd($"cd {pythonPath} && pip uninstall -y unity-cv-datasetvisualizer", ref exitCodeCopy));
5267
#elif UNITY_EDITOR_OSX
53-
var task = Task.Run(() => ExecuteCmd($"cd \'{packagesPath}\'; ./python3.7 -m pip install --upgrade unity-cv-datasetvisualizer \'{index_url}'", ref exitCodeCopy));
68+
var task = Task.Run(() => ExecuteCmd($"cd {packagesPath}; ./python3.7 pip uninstall unity-cv-datasetvisualizer", ref exitCodeCopy));
5469
#endif
5570
exitCode = exitCodeCopy;
5671
return task;
5772
}
5873

5974
// return the internal artifactory index url if using the internal perception package
60-
static String get_index_url()
75+
static string GetIndexURL()
6176
{
62-
var pckName = "com.unity.perception.internal";
63-
if ( !File.Exists("Packages/manifest.json") )
64-
return "";
65-
string jsonText = File.ReadAllText("Packages/manifest.json");
66-
var hasPerceptionInternal = jsonText.Contains( pckName );
67-
if (hasPerceptionInternal)
77+
const string pckName = "com.unity.perception.internal";
78+
if (!File.Exists("Packages/manifest.json"))
6879
{
69-
return " --index-url=https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/unity-pypi-local/simple/";
80+
return string.Empty;
7081
}
71-
return "";
82+
83+
var jsonText = File.ReadAllText("Packages/manifest.json");
84+
var hasPerceptionInternal = jsonText.Contains( pckName );
85+
return hasPerceptionInternal ? "--index-url=https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/unity-pypi-local/simple/" : string.Empty;
7286
}
7387

7488
// ReSharper disable Unity.PerformanceAnalysis
@@ -117,8 +131,12 @@ static async Task SetupVisualizer()
117131

118132
EditorUtility.DisplayProgressBar("Setting up the Visualizer", "Installing Visualizer (This may take a few minutes)", 2f / steps);
119133

120-
await InstallationCommand(ref exitCode, packagesPath);
121-
134+
await InstallationCommand(ref exitCode, packagesPath, false);
135+
if (exitCode != 0)
136+
{
137+
Debug.LogWarning("Installing Public Visualizer");
138+
await InstallationCommand(ref exitCode, packagesPath, true);
139+
}
122140
if (exitCode != 0)
123141
{
124142
EditorUtility.ClearProgressBar();
@@ -231,7 +249,7 @@ public static async Task RunVisualizer(string project)
231249
{
232250
await SetupVisualizer();
233251
}
234-
252+
235253
var lastDataPath = GetLastDataPath();
236254
var (pythonPid, port, visualizerPid) = ReadEntry(lastDataPath);
237255

@@ -349,7 +367,7 @@ static void ExecuteVisualizer(string project)
349367
#elif UNITY_EDITOR_OSX
350368
var packagesPath = project.Replace("/Assets","/Library/PythonInstall/bin");
351369
#endif
352-
370+
353371
var pathToData = GetLastDataPath();
354372
#if UNITY_EDITOR_WIN
355373
packagesPath = packagesPath.Replace("/", "\\");
@@ -369,7 +387,7 @@ static void ExecuteVisualizer(string project)
369387
Debug.LogError("Failed launching the visualizer - Exit Code: " + exitCode);
370388
}
371389
}
372-
390+
373391
static string GetLastDataPath()
374392
{
375393
var lastEndpointType = PlayerPrefs.GetString(SimulationState.lastEndpointTypeKey, string.Empty);

com.unity.perception/Runtime/GroundTruth/Consumers/IFileSystemEndpoint.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ public interface IFileSystemEndpoint
1616
/// </summary>
1717
string defaultPathToken { get; }
1818

19-
/// <summary>
20-
/// The default path to user if a user does not set a custom storage directory
21-
/// </summary>
22-
string defaultPath { get; }
23-
2419
/// <summary>
2520
/// The runtime directory that the dataset will be written to.
2621
/// This directory may be different from the <see cref="basePath"/> in cases where the <see cref="basePath"/>

0 commit comments

Comments
 (0)