OrganIdentificationParameter.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using System.Text.Json.Serialization;
  3. using Vinno.AI.CommonSDK.Enums;
  4. using Vinno.AI.CommonSDK.Interfaces;
  5. namespace Vinno.AI.OrganIdentificationSDK.Models
  6. {
  7. public class OrganIdentificationParameter : IAIParameter
  8. {
  9. /// <summary>
  10. /// 性能配置
  11. /// </summary>
  12. public AIEnumPerformance Performance { get; }
  13. /// <summary>
  14. /// 检测模式
  15. /// </summary>
  16. public AIEnumDetectMode DetectMode { get; set; }
  17. /// <summary>
  18. /// 图像是否被裁剪
  19. /// </summary>
  20. public bool IsCropped { get; set; }
  21. /// <summary>
  22. /// 当检测模式为EnumDetectMode.TimesPerSecond时,指每秒的图片吞吐量,DetectTps必须大于0
  23. /// </summary>
  24. public int DetectTps { get; set; }
  25. /// <summary>
  26. /// 当检测模式为当检测模式为EnumDetectMode.PeriodicIntervals时,指检测的间隔时间.必须大于等于0
  27. /// </summary>
  28. public int IntervalTime { get; set; }
  29. public OrganIdentificationParameter(AIEnumPerformance performance, bool isCropped)
  30. {
  31. Performance = performance;
  32. IsCropped = isCropped;
  33. DetectMode = AIEnumDetectMode.TimesPerSecond;
  34. DetectTps = 2;
  35. IntervalTime = 200;
  36. }
  37. [JsonConstructor]
  38. public OrganIdentificationParameter(AIEnumPerformance performance = AIEnumPerformance.Low, AIEnumDetectMode detectMode = AIEnumDetectMode.TimesPerSecond, bool isCropped = false, int detectTps = 2, int intervalTime = 350)
  39. {
  40. if (detectTps <= 0)
  41. {
  42. throw new ArgumentOutOfRangeException($"Detect Tps must >0,Detect Tps is {detectTps}");
  43. }
  44. if (intervalTime < 0)
  45. {
  46. throw new ArgumentOutOfRangeException($"interval Time must >= 0,Interval Time is {intervalTime}");
  47. }
  48. Performance = performance;
  49. DetectMode = detectMode;
  50. IsCropped = isCropped;
  51. DetectTps = detectTps;
  52. IntervalTime = intervalTime;
  53. }
  54. }
  55. }