CarotidClassificationParameter.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.CarotidClassificationSDK.Models
  6. {
  7. public class CarotidClassificationParameter : IAIParameter
  8. {
  9. /// <summary>
  10. /// 用于CarotidClassification计算的CPU数
  11. /// </summary>
  12. public int CPUNumber { get; }
  13. /// <summary>
  14. /// 检测模式
  15. /// </summary>
  16. public AIEnumDetectMode DetectMode { get; set; }
  17. /// <summary>
  18. /// 当检测模式为EnumDetectMode.TimesPerSecond时,指每秒的图片吞吐量,DetectTps必须大于0
  19. /// </summary>
  20. public int DetectTps { get; set; }
  21. /// <summary>
  22. /// 当检测模式为当检测模式为EnumDetectMode.PeriodicIntervals时,指检测的间隔时间,当间隔时间<0时,则启动内置的时间间隔。
  23. /// </summary>
  24. public int IntervalTime { get; set; }
  25. /// <summary>
  26. /// 结果是否包含轮廓信息
  27. /// </summary>
  28. public bool IsIncludeContour { get; }
  29. public CarotidClassificationParameter(int cpuNumber, bool isIncludeContour)
  30. {
  31. CPUNumber = cpuNumber;
  32. IsIncludeContour = isIncludeContour;
  33. DetectMode = AIEnumDetectMode.TimesPerSecond;
  34. DetectTps = 2;
  35. IntervalTime = 200;
  36. }
  37. [JsonConstructor]
  38. public CarotidClassificationParameter(int cpuNumber, AIEnumDetectMode detectMode, int detectTps, int intervalTime, bool isIncludeContour)
  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. CPUNumber = cpuNumber;
  49. DetectMode = detectMode;
  50. DetectTps = detectTps;
  51. IntervalTime = intervalTime;
  52. IsIncludeContour = isIncludeContour;
  53. }
  54. }
  55. }