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