浏览代码

Merge branch 'coco_perception_output_hybrid' into h-i

/h-i
Mohsen Kamalzadeh 3 年前
当前提交
78613087
共有 3 个文件被更改,包括 64 次插入58 次删除
  1. 105
      com.unity.perception/Runtime/GroundTruth/Exporters/Coco/CocoExporter.cs
  2. 12
      com.unity.perception/Runtime/GroundTruth/SimulationState.cs
  3. 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);
}
}

12
com.unity.perception/Runtime/GroundTruth/SimulationState.cs


}
}
List<object> values2 = null;
if (values != null)
{
values2 = new List<object>();
foreach (var v in values)
{
values2.Add(v);
}
}
ReportAsyncAnnotationResult(asyncAnnotation, filename, jArray, values:values2);
ReportAsyncAnnotationResult(asyncAnnotation, filename, jArray, values?.Cast<object>().ToList() ?? null);
}
void ReportAsyncAnnotationResult(AsyncAnnotation asyncAnnotation, string filename, JArray jArray, IEnumerable<object> values = null)

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;
}

正在加载...
取消
保存