AnalysisParameters.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Runtime.CompilerServices;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using TeamAAS_VP.Enums;
  9. namespace TeamAAS_VP.Models
  10. {
  11. /// <summary>
  12. /// 输入参数
  13. /// </summary>
  14. public class AnalysisParameters : INotifyPropertyChanged
  15. {
  16. private FocusMethod _focusMethod = FocusMethod.Tenengrad;
  17. private AnalysisMode _analysisMode = AnalysisMode.AutoCheckerboard;
  18. private int _targetBrightness = 128;
  19. private double _sharpnessThreshold = 10;
  20. private double _contrastThreshold = 50;
  21. private bool _enableRealtimeAnalysis = true;
  22. private bool _autoAdjustBrightness = true;
  23. public FocusMethod FocusMethod
  24. {
  25. get => _focusMethod;
  26. set => SetField(ref _focusMethod, value);
  27. }
  28. public AnalysisMode AnalysisMode
  29. {
  30. get => _analysisMode;
  31. set => SetField(ref _analysisMode, value);
  32. }
  33. public int TargetBrightness
  34. {
  35. get => _targetBrightness;
  36. set => SetField(ref _targetBrightness, value);
  37. }
  38. public double SharpnessThreshold
  39. {
  40. get => _sharpnessThreshold;
  41. set => SetField(ref _sharpnessThreshold, value);
  42. }
  43. public double ContrastThreshold
  44. {
  45. get => _contrastThreshold;
  46. set => SetField(ref _contrastThreshold, value);
  47. }
  48. public bool EnableRealtimeAnalysis
  49. {
  50. get => _enableRealtimeAnalysis;
  51. set => SetField(ref _enableRealtimeAnalysis, value);
  52. }
  53. public bool AutoAdjustBrightness
  54. {
  55. get => _autoAdjustBrightness;
  56. set => SetField(ref _autoAdjustBrightness, value);
  57. }
  58. public event PropertyChangedEventHandler PropertyChanged;
  59. protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
  60. {
  61. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  62. }
  63. protected bool SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
  64. {
  65. if (EqualityComparer<T>.Default.Equals(field, value)) return false;
  66. field = value;
  67. OnPropertyChanged(propertyName);
  68. return true;
  69. }
  70. /// <summary>
  71. /// 重置为默认值
  72. /// </summary>
  73. public void ResetToDefaults()
  74. {
  75. FocusMethod = FocusMethod.Tenengrad;
  76. AnalysisMode = AnalysisMode.AutoCheckerboard;
  77. TargetBrightness = 128;
  78. SharpnessThreshold = 10;
  79. ContrastThreshold = 50;
  80. EnableRealtimeAnalysis = true;
  81. AutoAdjustBrightness = true;
  82. }
  83. }
  84. }