using ThyroidSectionClassificaionLib; using Vinno.AI.CommonSDK.Enums; using Vinno.AI.CommonSDK.Models; using Vinno.AI.Service.Common.Tools; using Vinno.AI.ThyroidClassificationSDK.Enums; using Vinno.AI.ThyroidClassificationSDK.Models; namespace Vinno.AI.ThyroidClassificationService.Tools { internal static class AIConvertHelper { internal static AIThyroidSectionResult ConvertThyroidSectionResultToAIThyroidSectionResult(ThyroidSectionResult result) { if (result == null) { return null; } var sectionType = (AIEnumThyroidSectionType)result.ThyroidSectionType; var scroe = result.Score; AIModelRecognizedObjectInfo[] recognizedObjectInfos; if (result.RecognizedObjectsInfo == null) { recognizedObjectInfos = null; } else { recognizedObjectInfos = new AIModelRecognizedObjectInfo[result.RecognizedObjectsInfo.Length]; for (int i = 0; i < result.RecognizedObjectsInfo.Length; i++) { recognizedObjectInfos[i] = ConvertModelRecognizedObjectInfoToAIModelRecognizedObjectInfo(result.RecognizedObjectsInfo[i]); } } return new AIThyroidSectionResult(sectionType, scroe, recognizedObjectInfos); } private static AIModelRecognizedObjectInfo ConvertModelRecognizedObjectInfoToAIModelRecognizedObjectInfo(ModelRecognizedObjectInfo modelRecognizedObjectInfo) { if (modelRecognizedObjectInfo == null) { return null; } var modelRecognizedObjectType = (AIEnumModelRecognizedObjectType)modelRecognizedObjectInfo.ModelRecognizedObjectType; var confidence = modelRecognizedObjectInfo.Confidence; AIPoint2D[] contour; if (modelRecognizedObjectInfo.Contour == null) { contour = null; } else { contour = new AIPoint2D[modelRecognizedObjectInfo.Contour.Length]; for (int i = 0; i < modelRecognizedObjectInfo.Contour.Length; i++) { contour[i] = AICommonServiceConvertHelper.ConvertPoint2DToAIPoint2D(modelRecognizedObjectInfo.Contour[i]); } } return new AIModelRecognizedObjectInfo(modelRecognizedObjectType, confidence, contour); } } }