浏览代码

fixes for crash and local json workflow

- Fixed an exception that happened when semantic or instance segmentation labelers where active in the scene, causing coco export to crash
- Made it possible to test the outputFormat scenario constant locally with a json config
/coco_perception_output_hybrid
Mohsen Kamalzadeh 3 年前
当前提交
4872a778
共有 2 个文件被更改,包括 63 次插入47 次删除
  1. 105
      com.unity.perception/Runtime/GroundTruth/Exporters/Coco/CocoExporter.cs
  2. 5
      com.unity.perception/Runtime/Randomization/Scenarios/UnitySimulationScenario.cs

105
com.unity.perception/Runtime/GroundTruth/Exporters/Coco/CocoExporter.cs


var boxJson = string.Empty;
var keypointJson = string.Empty;
foreach (var cap in pendingCaptures)
try
var boxes = new Dictionary<int, CocoTypes.ObjectDetectionAnnotation>();
foreach (var annotation in cap.Annotations)
foreach (var cap in pendingCaptures)
var tmp = ProcessBoundingBoxAnnotations(annotation.Item2.RawValues);
var boxes = new Dictionary<int, CocoTypes.ObjectDetectionAnnotation>();
foreach (var box in tmp.Values)
foreach (var annotation in cap.Annotations)
boxes[box.id] = box;
if (annotation.Item2.RawValues == null)
continue;
var tmp = ProcessBoundingBoxAnnotations(annotation.Item2.RawValues);
if (m_FirstBoxAnnotation)
foreach (var box in tmp.Values)
boxJson = "[";
m_FirstBoxAnnotation = false;
boxes[box.id] = box;
if (m_FirstBoxAnnotation)
{
boxJson = "[";
m_FirstBoxAnnotation = false;
}
else
boxJson += ",";
boxJson += JsonUtility.ToJson(box);
else
boxJson += ",";
boxJson += JsonUtility.ToJson(box);
}
foreach (var annotation in cap.Annotations)
{
if (annotation.Item2.RawValues == null)
continue;
foreach (var annotation in cap.Annotations)
{
var keypoints = ProcessKeypointAnnotations(annotation.Item2.RawValues, boxes);
var keypoints = ProcessKeypointAnnotations(annotation.Item2.RawValues, boxes);
foreach (var kp in keypoints.Values)
{
if (m_FirstKeypointAnnotation)
foreach (var kp in keypoints.Values)
keypointJson = "[";
m_FirstKeypointAnnotation = false;
}
else
keypointJson += ",";
if (m_FirstKeypointAnnotation)
{
keypointJson = "[";
m_FirstKeypointAnnotation = false;
}
else
keypointJson += ",";
var builder = new StringBuilder();
var stringWriter = new StringWriter(builder);
var builder = new StringBuilder();
var stringWriter = new StringWriter(builder);
var serializer = new JsonSerializer();
var serializer = new JsonSerializer();
using (var writer = new JsonTextWriter(stringWriter))
{
serializer.Serialize(writer, kp);
}
using (var writer = new JsonTextWriter(stringWriter))
{
serializer.Serialize(writer, kp);
}
keypointJson += builder.ToString();
keypointJson += builder.ToString();
}
}
if (m_ObjectDetectionWritingTask != null)
await m_ObjectDetectionWritingTask;
if (m_ObjectDetectionWritingTask != null)
await m_ObjectDetectionWritingTask;
if (boxJson != string.Empty)
{
InitializeCaptureFiles();
m_ObjectDetectionWritingTask = m_ObjectDetectionStream.WriteAsync(boxJson);
}
if (boxJson != string.Empty)
{
InitializeCaptureFiles();
m_ObjectDetectionWritingTask = m_ObjectDetectionStream.WriteAsync(boxJson);
}
if (m_KeypointDetectionWritingTask != null)
await m_KeypointDetectionWritingTask;
if (m_KeypointDetectionWritingTask != null)
await m_KeypointDetectionWritingTask;
if (keypointJson != string.Empty)
if (keypointJson != string.Empty)
{
InitializeCaptureFiles();
m_KeypointDetectionWritingTask = m_KeypointDetectionStream.WriteAsync(keypointJson);
}
}
catch (Exception e)
InitializeCaptureFiles();
m_KeypointDetectionWritingTask = m_KeypointDetectionStream.WriteAsync(keypointJson);
Debug.LogException(e);
}
}

5
com.unity.perception/Runtime/Randomization/Scenarios/UnitySimulationScenario.cs


{
var filePath = new Uri(Configuration.Instance.SimulationConfig.app_param_uri).LocalPath;
LoadConfigurationFromFile(filePath);
PlayerPrefs.SetString(SimulationState.outputFormatMode, constants.outputFormat);
}
else
{

base.DeserializeConfiguration();
if (Configuration.Instance.IsSimulationRunningInCloud())
constants.instanceIndex = int.Parse(Configuration.Instance.GetInstanceId()) - 1;
if (constants.outputFormat != string.Empty)
PlayerPrefs.SetString(SimulationState.outputFormatMode, constants.outputFormat);
currentIteration = constants.instanceIndex;
}

正在加载...
取消
保存