浏览代码

Compile in 2019

/coco_export
Steve Borkman 3 年前
当前提交
92e591ca
共有 4 个文件被更改,包括 49 次插入27 次删除
  1. 13
      com.unity.perception/Runtime/GroundTruth/Exporters/Coco/AnnotationHandler.cs
  2. 29
      com.unity.perception/Runtime/GroundTruth/Exporters/Coco/CocoExporter.cs
  3. 12
      com.unity.perception/Runtime/GroundTruth/Exporters/IDatasetExporter.cs
  4. 22
      com.unity.perception/Runtime/GroundTruth/SimulationState.cs

13
com.unity.perception/Runtime/GroundTruth/Exporters/Coco/AnnotationHandler.cs


{
public static object HandleAnnotation(AsyncAnnotation asyncAnnotation, object annotation)
{
object converted = annotation switch
switch (annotation)
BoundingBox2DLabeler.BoundingBoxValue bbox => CocoTypes.ObjectDetectionAnnotation.FromBoundingBoxValue(bbox),
KeypointLabeler.KeypointEntry keypoint => CocoTypes.KeypointAnnotation.FromKeypointValue(keypoint),
_ => null
};
case BoundingBox2DLabeler.BoundingBoxValue bbox:
return CocoTypes.ObjectDetectionAnnotation.FromBoundingBoxValue(bbox);
case KeypointLabeler.KeypointEntry keypoint:
return CocoTypes.KeypointAnnotation.FromKeypointValue(keypoint);
}
return converted;
return null;
}
public static CocoTypes.KeypointCategory ToKeypointCategory(KeypointLabeler.KeypointJson keypointJson)

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


m_RgbCaptureStream = File.CreateText(m_RgbCaptureFilename);
m_ObjectDetectionFilename = Path.Combine(m_DirectoryName, m_SessionGuid + "_coco_box_annotations.json");
m_ObjectDetectionStream = File.CreateText(m_ObjectDetectionFilename);
if (m_ReportingObjectDetection)
{
m_ObjectDetectionStream = File.CreateText(m_ObjectDetectionFilename);
m_ObjectDetectionCategoryFilename = Path.Combine(m_DirectoryName, m_SessionGuid + "_coco_obj_detection_categories.json");
}
m_KeypointDetectionStream = File.CreateText(m_KeypointFilename);
m_ObjectDetectionCategoryFilename = Path.Combine(m_DirectoryName, m_SessionGuid + "_coco_obj_detection_categories.json");
m_KeypointCategoryFilename = Path.Combine(m_DirectoryName, m_SessionGuid + "_coco_keypoint_categories.json");
if (m_ReportingKeypoints)
{
m_KeypointDetectionStream = File.CreateText(m_KeypointFilename);
m_KeypointCategoryFilename = Path.Combine(m_DirectoryName, m_SessionGuid + "_coco_keypoint_categories.json");
}
m_Initialized = true;
}

using var sr = new StreamReader(filename);
var sr = new StreamReader(filename);
var length = (int)sr.BaseStream.Length;
var start = 0;

}
aggregated.Append(buffer, start, length);
sr.Dispose();
}
async Task WriteObjectDetectionFile()

var filename = Path.Combine(m_DirectoryName, "coco_keypoint_annotations.json");
var cocoStream = File.CreateText(filename);
await cocoStream.WriteAsync(json);
cocoStream.Close();
cocoStream.Dispose();
Manager.Instance.ConsumerFileProduced(filename);

public void OnAnnotationRegistered<TSpec>(Guid annotationId, TSpec[] values)
{
InitializeCaptureFiles();
if (annotationId.ToString() == BoundingBox2DLabeler.annotationId)
{
m_ReportingObjectDetection = true;

await m_ObjectDetectionWritingTask;
if (boxJson != string.Empty)
{
InitializeCaptureFiles();
}
{
InitializeCaptureFiles();
}
}
static Dictionary<int, CocoTypes.ObjectDetectionAnnotation> ProcessBoundingBoxAnnotations(IEnumerable<object> annotations)

12
com.unity.perception/Runtime/GroundTruth/Exporters/IDatasetExporter.cs


{
public interface IDatasetExporter
{
public string GetRgbCaptureFilename(params(string, object)[] additionalSensorValues);
string GetRgbCaptureFilename(params(string, object)[] additionalSensorValues);
public void OnSimulationBegin(string directoryName);
public void OnSimulationEnd();
void OnSimulationBegin(string directoryName);
void OnSimulationEnd();
public void OnAnnotationRegistered<TSpec>(Guid annotationId, TSpec[] values);
void OnAnnotationRegistered<TSpec>(Guid annotationId, TSpec[] values);
public Task ProcessPendingCaptures(List<SimulationState.PendingCapture> pendingCaptures, SimulationState simState);
Task ProcessPendingCaptures(List<SimulationState.PendingCapture> pendingCaptures, SimulationState simState);
public Task OnCaptureReported(int frame, int width, int height, string filename);
Task OnCaptureReported(int frame, int width, int height, string filename);
}
}

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


}
#else
Debug.Log($"SS - Sim State setting active reporter: {mode}");
_ActiveReporter = mode switch
switch (mode)
nameof(PerceptionExporter) => new PerceptionExporter(),
nameof(CocoExporter) => new CocoExporter(),
nameof(PerceptionNewExporter) => new PerceptionNewExporter(),
_ => new PerceptionExporter()
};
case nameof(PerceptionExporter):
_ActiveReporter = new PerceptionExporter();
break;
case nameof(CocoExporter):
_ActiveReporter = new CocoExporter();
break;
case nameof(PerceptionNewExporter):
_ActiveReporter = new PerceptionNewExporter();
break;
default:
_ActiveReporter = new PerceptionExporter();
break;
}
#endif
Debug.Log("Calling SS::OnSimulationBegin");
_ActiveReporter?.OnSimulationBegin(Manager.Instance.GetDirectoryFor(m_OutputDirectoryName));

正在加载...
取消
保存