123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using System.Collections.Generic;
- using Vinno.AI.CommonSDK.Enums;
- using Vinno.AI.CommonSDK.Models;
- using Vinno.AI.Service.Common.Tools;
- using AIDiagResultPerImg = global::AI.DiagSystem.AIDiagResultPerImg;
- using AIDiagResultPerOrgan = global::AI.DiagSystem.AIDiagResultPerOrgan;
- namespace Vinno.AI.OrganIdentificationService.Tools
- {
- internal static class AIConvertHelper
- {
- internal static TransAIDiagResultPerImg ConvertAIDiagResultPerImgToTransAIDiagResultPerImg(AIDiagResultPerImg data)
- {
- if (data == null)
- {
- return null;
- }
- var priorityScore = data.PriorityScore;
- TransAIDiagResultPerOrgan[] aiDiagResultPerOrgans;
- if (data.DiagResultsForEachOrgan == null)
- {
- aiDiagResultPerOrgans = null;
- }
- else
- {
- aiDiagResultPerOrgans = new TransAIDiagResultPerOrgan[data.DiagResultsForEachOrgan.Length];
- for (int cursor = 0; cursor < data.DiagResultsForEachOrgan.Length; cursor++)
- {
- aiDiagResultPerOrgans[cursor] = ConvertAIDiagResultPerOrganToTransAIDiagResultPerOrgan(data.DiagResultsForEachOrgan[cursor]);
- }
- }
- return new TransAIDiagResultPerImg(aiDiagResultPerOrgans, priorityScore);
- }
- private static TransAIDiagResultPerOrgan ConvertAIDiagResultPerOrganToTransAIDiagResultPerOrgan(AIDiagResultPerOrgan data)
- {
- if (data == null)
- {
- return null;
- }
- var organ = (AIEnumOrgans)data.Organ;
- var organBoundBox = AICommonServiceConvertHelper.ConvertRectToAIRect(data.OrganBoundBox);
- AIPoint2D[][] organContours;
- if (data.OrganContours == null)
- {
- organContours = null;
- }
- else
- {
- organContours = new AIPoint2D[data.OrganContours.Length][];
- for (int cursorX = 0; cursorX < data.OrganContours.Length; cursorX++)
- {
- organContours[cursorX] = new AIPoint2D[data.OrganContours[cursorX].Length];
- for (int cursorY = 0; cursorY < data.OrganContours[cursorX].Length; cursorY++)
- {
- organContours[cursorX][cursorY] = AICommonServiceConvertHelper.ConvertPoint2DToAIPoint2D(data.OrganContours[cursorX][cursorY]);
- }
- }
- }
- List<byte[]> descriptions;
- if (data.OrganDescriptions == null)
- {
- descriptions = null;
- }
- else
- {
- descriptions = new List<byte[]>();
- for (int cursor = 0; cursor < data.OrganDescriptions.Length; cursor++)
- {
- var description = AICommonServiceConvertHelper.ConvertDescriptionToTransAIDescription(data.OrganDescriptions[cursor]);
- if (description != null)
- {
- descriptions.Add(description);
- }
- }
- }
- TransAIDetectedObject[] detectedObjects;
- if (data.DetectedObjects == null)
- {
- detectedObjects = null;
- }
- else
- {
- detectedObjects = new TransAIDetectedObject[data.DetectedObjects.Length];
- for (int cursor = 0; cursor < data.DetectedObjects.Length; cursor++)
- {
- detectedObjects[cursor] = AICommonServiceConvertHelper.ConvertDetectedObjectsToTransAIDetectedObject(data.DetectedObjects[cursor]);
- }
- }
- return new TransAIDiagResultPerOrgan(organ, organBoundBox, organContours, descriptions, detectedObjects);
- }
- }
- }
|