浏览代码

make the datasets compatible with pyrception - manually transferred the code from branch fod_generator_randomization_changes commit fce50a

/pyrception-integration
leopoldo-zugasti 4 年前
当前提交
4a56d6f4
共有 4 个文件被更改,包括 40 次插入0 次删除
  1. 5
      com.unity.perception/Runtime/GroundTruth/DatasetCapture.cs
  2. 6
      com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
  3. 10
      com.unity.perception/Runtime/GroundTruth/SimulationState.cs
  4. 19
      com.unity.perception/Runtime/GroundTruth/SimulationState_Json.cs

5
com.unity.perception/Runtime/GroundTruth/DatasetCapture.cs


return ego;
}
public static void AddMetadata(string key, object value)
{
SimulationState.AddMetadata(key, value);
}
/// <summary>
/// Register a new sensor under the given ego.
/// </summary>

6
com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs


inMatrix[2,0],inMatrix[2,1], inMatrix[2,2]);
}
int m_CaptureCount = 0;
void CaptureRgbData(Camera cam)
{
if (!captureRgbImages)

#else
CaptureCamera.Capture(cam, colorFunctor, flipY: flipY);
#endif
DatasetCapture.AddMetadata("image_width", attachedCamera.pixelWidth);
DatasetCapture.AddMetadata("image_height", attachedCamera.pixelHeight);
DatasetCapture.AddMetadata("dataset_size", ++m_CaptureCount);
Profiler.EndSample();
}

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


Dictionary<SensorHandle, SensorData> m_Sensors = new Dictionary<SensorHandle, SensorData>();
HashSet<EgoHandle> m_Egos = new HashSet<EgoHandle>();
HashSet<Guid> m_Ids = new HashSet<Guid>();
Dictionary<string, object> m_Metadata = new Dictionary<string, object>();
Guid m_SequenceId = Guid.NewGuid();
// Always use the property SequenceTimeMs instead

m_Ids.Add(egoHandle.Id);
}
public void AddMetadata(string key, object value)
{
if (!m_Metadata.ContainsKey(key)) m_Metadata[key] = null;
m_Metadata[key] = value;
}
public bool IsEnabled(SensorHandle sensorHandle) => m_ActiveSensors.Contains(sensorHandle);

Debug.LogError($"Simulation ended with pending metrics: {string.Join(", ", m_PendingMetrics.Select(c => $"id:{c.MetricId} step:{c.Step}"))}");
WriteReferences();
// TODO write metadata here
WriteMetadata();
Time.captureDeltaTime = 0;
IsRunning = false;
}

19
com.unity.perception/Runtime/GroundTruth/SimulationState_Json.cs


{
const Formatting k_Formatting = Formatting.Indented;
public void WriteMetadata()
{
var metadata = new JObject();
metadata["version"] = DatasetCapture.SchemaVersion;
metadata["per_file_size"] = k_MinPendingMetricsBeforeWrite;
foreach (var md in m_Metadata)
{
metadata[md.Key] = JToken.FromObject(md.Value);
}
//metadata["dataset_size"] = 500;
//metadata["per_file_size"] = 150;
//metadata["image_width"] = 1024;
//metadata["image_height"] = 768;
WriteJObjectToFile(metadata, "metadata.json");
}
/// <summary>
/// Writes sensors.json, egos.json, metric_definitions.json, and annotation_definitions.json
/// </summary>

正在加载...
取消
保存