AIConvertHelper.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using ThyroidSectionClassificaionLib;
  2. using Vinno.AI.CommonSDK.Enums;
  3. using Vinno.AI.CommonSDK.Models;
  4. using Vinno.AI.Service.Common.Tools;
  5. using Vinno.AI.ThyroidClassificationSDK.Enums;
  6. using Vinno.AI.ThyroidClassificationSDK.Models;
  7. namespace Vinno.AI.ThyroidClassificationService.Tools
  8. {
  9. internal static class AIConvertHelper
  10. {
  11. internal static AIThyroidSectionResult ConvertThyroidSectionResultToAIThyroidSectionResult(ThyroidSectionResult result)
  12. {
  13. if (result == null)
  14. {
  15. return null;
  16. }
  17. var sectionType = (AIEnumThyroidSectionType)result.ThyroidSectionType;
  18. var scroe = result.Score;
  19. AIModelRecognizedObjectInfo[] recognizedObjectInfos;
  20. if (result.RecognizedObjectsInfo == null)
  21. {
  22. recognizedObjectInfos = null;
  23. }
  24. else
  25. {
  26. recognizedObjectInfos = new AIModelRecognizedObjectInfo[result.RecognizedObjectsInfo.Length];
  27. for (int i = 0; i < result.RecognizedObjectsInfo.Length; i++)
  28. {
  29. recognizedObjectInfos[i] = ConvertModelRecognizedObjectInfoToAIModelRecognizedObjectInfo(result.RecognizedObjectsInfo[i]);
  30. }
  31. }
  32. return new AIThyroidSectionResult(sectionType, scroe, recognizedObjectInfos);
  33. }
  34. private static AIModelRecognizedObjectInfo ConvertModelRecognizedObjectInfoToAIModelRecognizedObjectInfo(ModelRecognizedObjectInfo modelRecognizedObjectInfo)
  35. {
  36. if (modelRecognizedObjectInfo == null)
  37. {
  38. return null;
  39. }
  40. var modelRecognizedObjectType = (AIEnumModelRecognizedObjectType)modelRecognizedObjectInfo.ModelRecognizedObjectType;
  41. var confidence = modelRecognizedObjectInfo.Confidence;
  42. AIPoint2D[] contour;
  43. if (modelRecognizedObjectInfo.Contour == null)
  44. {
  45. contour = null;
  46. }
  47. else
  48. {
  49. contour = new AIPoint2D[modelRecognizedObjectInfo.Contour.Length];
  50. for (int i = 0; i < modelRecognizedObjectInfo.Contour.Length; i++)
  51. {
  52. contour[i] = AICommonServiceConvertHelper.ConvertPoint2DToAIPoint2D(modelRecognizedObjectInfo.Contour[i]);
  53. }
  54. }
  55. return new AIModelRecognizedObjectInfo(modelRecognizedObjectType, confidence, contour);
  56. }
  57. }
  58. }