| | | 1 | | using ReFlex.Core.Interactivity.Util; |
| | | 2 | | |
| | | 3 | | namespace ReFlex.Server.Data.Config |
| | | 4 | | { |
| | | 5 | | public struct SmoothingParameter |
| | | 6 | | { |
| | 54 | 7 | | public int InteractionHistorySize { get; set; } |
| | | 8 | | |
| | 54 | 9 | | public int NumSmoothingSamples { get; set; } |
| | | 10 | | |
| | | 11 | | private double? _contactRetentionSeconds; |
| | | 12 | | private double? _legacyRetentionSeconds; |
| | | 13 | | |
| | | 14 | | /// <summary>Retention after a completed observation no longer detects a contact.</summary> |
| | | 15 | | public double ContactRetentionSeconds |
| | | 16 | | { |
| | 62 | 17 | | get => _contactRetentionSeconds ?? _legacyRetentionSeconds ?? .1; |
| | 30 | 18 | | set => _contactRetentionSeconds = double.IsFinite(value) && value >= 0 ? value : |
| | 30 | 19 | | throw new ArgumentOutOfRangeException(nameof(value)); |
| | | 20 | | } |
| | | 21 | | |
| | | 22 | | private double? _observationTimeoutSeconds; |
| | | 23 | | /// <summary>Maximum sensor/processing silence and acceptable observation age. Separate from missing-contact ret |
| | | 24 | | public double ObservationTimeoutSeconds |
| | | 25 | | { |
| | 32 | 26 | | get => _observationTimeoutSeconds ?? 1; |
| | 22 | 27 | | set => _observationTimeoutSeconds = double.IsFinite(value) && value >= 0 ? value : |
| | 22 | 28 | | throw new ArgumentOutOfRangeException(nameof(value)); |
| | | 29 | | } |
| | | 30 | | |
| | | 31 | | /// <summary>Deserialization-only migration of legacy configuration, assuming 30 Hz. |
| | | 32 | | /// Explicit seconds take precedence regardless of JSON property order. Never serialized.</summary> |
| | 16 | 33 | | public int MaxNumEmptyFramesBetween { set => _legacyRetentionSeconds = Math.Max(0, value) / 30.0; } |
| | | 34 | | |
| | | 35 | | private float? _confidenceGainPerSecond; |
| | | 36 | | private float? _confidenceDecayPerSecond; |
| | | 37 | | public float ConfidenceGainPerSecond |
| | | 38 | | { |
| | 42 | 39 | | get => _confidenceGainPerSecond ?? 30; |
| | 22 | 40 | | set => _confidenceGainPerSecond = float.IsFinite(value) && value >= 0 ? value : |
| | 22 | 41 | | throw new ArgumentOutOfRangeException(nameof(value)); |
| | | 42 | | } |
| | | 43 | | public float ConfidenceDecayPerSecond |
| | | 44 | | { |
| | 42 | 45 | | get => _confidenceDecayPerSecond ?? 30; |
| | 22 | 46 | | set => _confidenceDecayPerSecond = float.IsFinite(value) && value >= 0 ? value : |
| | 22 | 47 | | throw new ArgumentOutOfRangeException(nameof(value)); |
| | | 48 | | } |
| | | 49 | | |
| | 54 | 50 | | public float TouchMergeDistance2D { get; set; } |
| | | 51 | | |
| | 54 | 52 | | public float DepthScale { get; set; } |
| | | 53 | | |
| | 54 | 54 | | public FilterType Type { get; set; } |
| | | 55 | | |
| | | 56 | | public SmoothingParameter(int historySize = 0, int numSmoothing = 0, float distance2D = 64f, double contactReten |
| | 0 | 57 | | { |
| | 0 | 58 | | this = default; |
| | 0 | 59 | | InteractionHistorySize = historySize; |
| | 0 | 60 | | NumSmoothingSamples = numSmoothing; |
| | 0 | 61 | | TouchMergeDistance2D = distance2D; |
| | 0 | 62 | | ContactRetentionSeconds = contactRetentionSeconds; |
| | 0 | 63 | | Type = type; |
| | 0 | 64 | | DepthScale = depthScale; |
| | 0 | 65 | | } |
| | | 66 | | |
| | | 67 | | public string GetSmoothingSettingsString() |
| | 0 | 68 | | { |
| | 0 | 69 | | var result = $"===== {nameof(SmoothingParameter)} ====={Environment.NewLine}"; |
| | 0 | 70 | | result += $" {nameof(InteractionHistorySize)}: {InteractionHistorySize} | "; |
| | 0 | 71 | | result += $" {nameof(NumSmoothingSamples)}: {NumSmoothingSamples} | "; |
| | 0 | 72 | | result += $" {nameof(TouchMergeDistance2D)}: {TouchMergeDistance2D} | "; |
| | 0 | 73 | | result += $" {nameof(ContactRetentionSeconds)}: {ContactRetentionSeconds} | "; |
| | 0 | 74 | | result += $" {nameof(ObservationTimeoutSeconds)}: {ObservationTimeoutSeconds} | "; |
| | 0 | 75 | | result += $" {nameof(DepthScale)}: {DepthScale} | "; |
| | 0 | 76 | | result += $" {nameof(Type)}: {Type}{Environment.NewLine}"; |
| | 0 | 77 | | return result; |
| | 0 | 78 | | } |
| | | 79 | | } |
| | | 80 | | } |