1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using AutoDFRCalculationLib;
- using Vinno.AI.AutoDFRDiagnosisSDK.Enums;
- using Vinno.AI.AutoDFRDiagnosisSDK.Models;
- using Vinno.AI.CommonSDK.Models;
- using Vinno.AI.Service.Common.Tools;
- namespace Vinno.AI.AutoDFRDiagnosisService.Tools
- {
- internal static class AIConvertHelper
- {
- internal static AIAutoDFRCalcResult ConvertAutoDFRCalcResultToAIAutoDFRCalcResult(AutoDFRCalcResult autoDFRCalcResult)
- {
- if (autoDFRCalcResult == null)
- {
- return null;
- }
- var measureMarks = ConvertDFRMeasurementsToAIDFRMeasurements(autoDFRCalcResult.Measurements);
- AIDFRRecognizedObjectInfo[] recognizedObjects;
- if (autoDFRCalcResult.recognizedObjectInfos == null)
- {
- recognizedObjects = null;
- }
- else
- {
- var recognizedObjectsLength = autoDFRCalcResult.recognizedObjectInfos.Length;
- recognizedObjects = new AIDFRRecognizedObjectInfo[recognizedObjectsLength];
- for (int i = 0; i < recognizedObjectsLength; i++)
- {
- recognizedObjects[i] = ConvertDFRRecognizedObjectInfoToAIDFRRecognizedObjectInfo(autoDFRCalcResult.recognizedObjectInfos[i]);
- }
- }
- return new AIAutoDFRCalcResult(measureMarks, recognizedObjects);
- }
- private static AIDFRMeasurements ConvertDFRMeasurementsToAIDFRMeasurements(DFRMeasurements measurements)
- {
- if (measurements == null)
- {
- return null;
- }
- var diaphragmPoint = ConvertMeasureMarksToAIMeasureMarks(measurements.DiaphragmPoint);
- var sideFlapPoint = ConvertMeasureMarksToAIMeasureMarks(measurements.SideFlapPoint);
- var mitralValveClosurePoint = ConvertMeasureMarksToAIMeasureMarks(measurements.MitralValveClosurePoint);
- return new AIDFRMeasurements(diaphragmPoint, sideFlapPoint, mitralValveClosurePoint);
- }
- private static AIMeasureMarks ConvertMeasureMarksToAIMeasureMarks(MeasureMarks measureMarks)
- {
- if (measureMarks == null)
- {
- return null;
- }
- var measureMarkPoint = AICommonServiceConvertHelper.ConvertPoint2DToAIPoint2D(measureMarks.MeasureMarkPoint);
- var score = measureMarks.MeasureMarkScore;
- return new AIMeasureMarks(measureMarkPoint, score);
- }
- private static AIDFRRecognizedObjectInfo ConvertDFRRecognizedObjectInfoToAIDFRRecognizedObjectInfo(DFRRecognizedObjectInfo recognizedObjectInfo)
- {
- if (recognizedObjectInfo == null)
- {
- return null;
- }
- var type = (AIEnumDFRRecognizedObjectType)recognizedObjectInfo.Type;
- var confidence = recognizedObjectInfo.Confidence;
- AIPoint2D[] contour;
- if (recognizedObjectInfo.Contour == null)
- {
- contour = null;
- }
- else
- {
- var contourLength = recognizedObjectInfo.Contour.Length;
- contour = new AIPoint2D[contourLength];
- for (int i = 0; i < contourLength; i++)
- {
- contour[i] = AICommonServiceConvertHelper.ConvertPoint2DToAIPoint2D(recognizedObjectInfo.Contour[i]);
- }
- }
- return new AIDFRRecognizedObjectInfo(type, confidence, contour);
- }
- }
- }
|