| | | 1 | | using System; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using System.Threading.Tasks; |
| | | 4 | | using ReFlex.Core.Common.Components; |
| | | 5 | | using ReFlex.Core.Common.Util; |
| | | 6 | | using ReFlex.Core.Interactivity.Util; |
| | | 7 | | |
| | | 8 | | namespace ReFlex.Core.Interactivity.Interfaces |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// |
| | | 12 | | /// </summary> |
| | | 13 | | public interface IInteractionObserver |
| | | 14 | | { |
| | | 15 | | /// <summary> |
| | | 16 | | /// Gets the type. |
| | | 17 | | /// </summary> |
| | | 18 | | /// <value> |
| | | 19 | | /// The type. |
| | | 20 | | /// </value> |
| | | 21 | | ObserverType Type { get; } |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Gets or sets the distance. |
| | | 25 | | /// </summary> |
| | | 26 | | /// <value> |
| | | 27 | | /// The distance. |
| | | 28 | | /// </value> |
| | | 29 | | float Distance { get; set; } |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// Gets or sets the minimum depth. |
| | | 33 | | /// </summary> |
| | | 34 | | /// <value> |
| | | 35 | | /// The maximum depth. |
| | | 36 | | /// </value> |
| | | 37 | | float MinDistance { get; set; } |
| | | 38 | | |
| | | 39 | | /// <summary> |
| | | 40 | | /// Gets or sets the minimum angle. |
| | | 41 | | /// </summary> |
| | | 42 | | /// <value> |
| | | 43 | | /// The minimum angle. |
| | | 44 | | /// </value> |
| | | 45 | | float MinAngle { get; set; } |
| | | 46 | | |
| | | 47 | | /// <summary> |
| | | 48 | | /// Gets or sets the minimum confidence. |
| | | 49 | | /// </summary> |
| | | 50 | | /// <value> |
| | | 51 | | /// The minimum confidence. |
| | | 52 | | /// </value> |
| | | 53 | | float MinConfidence { get; set; } |
| | | 54 | | |
| | | 55 | | /// <summary> |
| | | 56 | | /// Gets or sets the maximum confidence. |
| | | 57 | | /// </summary> |
| | | 58 | | /// <value> |
| | | 59 | | /// The maximum confidence. |
| | | 60 | | /// </value> |
| | | 61 | | float MaxConfidence { get; set; } |
| | | 62 | | |
| | | 63 | | /// <summary> |
| | | 64 | | /// Gets or sets the maximum depth. |
| | | 65 | | /// </summary> |
| | | 66 | | /// <value> |
| | | 67 | | /// The maximum depth. |
| | | 68 | | /// </value> |
| | | 69 | | float MaxDistance { get; set; } |
| | | 70 | | |
| | | 71 | | /// <summary> |
| | | 72 | | /// Number of frames retained for tracking. Negative values are clamped to zero. |
| | | 73 | | /// Zero publishes current measurements with fresh IDs in every frame and disables smoothing. |
| | | 74 | | /// </summary> |
| | | 75 | | int InteractionHistorySize { get; set; } |
| | | 76 | | double PredictionHorizonSeconds { get; set; } |
| | | 77 | | bool UseVelocityPrediction { get; set; } |
| | | 78 | | /// <summary>Gets effective capacity limited by history; sets the requested capacity, preserved across history c |
| | | 79 | | /// Actual motion fitting uses only available real measurements; acceleration needs at least three.</summary> |
| | | 80 | | int NumFramesForPrediction { get; set; } |
| | | 81 | | bool UseSecondDerivation { get; set; } |
| | | 82 | | float SecondDerivationMagnitude { get; set; } |
| | | 83 | | event EventHandler<IList<InteractionVelocity>> NewVelocities; |
| | | 84 | | |
| | | 85 | | /// <summary> |
| | | 86 | | /// Number of frames for smoothing, clamped to [0, InteractionHistorySize]. Zero disables smoothing. |
| | | 87 | | /// </summary> |
| | | 88 | | int NumSmoothingFrames { get; set; } |
| | | 89 | | |
| | | 90 | | /// <summary> |
| | | 91 | | /// Maximum elapsed seconds since the last measurement (inclusive), finite and non-negative. |
| | | 92 | | /// Independent of history capacity. After expiry a returning contact receives a new ID. |
| | | 93 | | /// </summary> |
| | | 94 | | double ContactRetentionSeconds { get; set; } |
| | | 95 | | double ObservationTimeoutSeconds { get; set; } |
| | | 96 | | bool UseMinimumCostAssignment { get; set; } |
| | | 97 | | float AssignmentMissCost { get; set; } |
| | | 98 | | float AssignmentBirthCost { get; set; } |
| | | 99 | | float ConfidenceGainPerSecond { get; set; } |
| | | 100 | | float ConfidenceDecayPerSecond { get; set; } |
| | | 101 | | |
| | | 102 | | /// <summary> |
| | | 103 | | /// Strict Manhattan-distance gate in sensor pixels for recognizing the same contact. |
| | | 104 | | /// The legacy Point3.Squared2DDistance helper computes abs(dx) + abs(dy). |
| | | 105 | | /// </summary> |
| | | 106 | | float TouchMergeDistance2D { get; set; } |
| | | 107 | | |
| | | 108 | | /// <summary> |
| | | 109 | | /// defines the squared distance to closest points to be recognized as same point |
| | | 110 | | /// </summary> |
| | | 111 | | float DepthScale { get; set; } |
| | | 112 | | |
| | | 113 | | /// <summary> |
| | | 114 | | /// Specifies the Type to be used for smoothing interactions |
| | | 115 | | /// </summary> |
| | | 116 | | FilterType FilterType { get; set; } |
| | | 117 | | |
| | | 118 | | /// <summary> |
| | | 119 | | /// Gets or sets the point cloud. |
| | | 120 | | /// </summary> |
| | | 121 | | /// <value> |
| | | 122 | | /// The point cloud. |
| | | 123 | | /// </value> |
| | | 124 | | PointCloud3 PointCloud { get; set; } |
| | | 125 | | |
| | | 126 | | /// <summary> |
| | | 127 | | /// Gets or sets the vector field. |
| | | 128 | | /// </summary> |
| | | 129 | | /// <value> |
| | | 130 | | /// The vector field. |
| | | 131 | | /// </value> |
| | | 132 | | VectorField2 VectorField { get; set; } |
| | | 133 | | |
| | | 134 | | /// <summary> |
| | | 135 | | /// defines how many points should be checked to determine the type of the extremum |
| | | 136 | | /// </summary> |
| | | 137 | | int ExtremumTypeCheckNumSamples { get; set; } |
| | | 138 | | |
| | | 139 | | /// <summary> |
| | | 140 | | /// The pixel radius in which the points are sampled for deriving the type of the local extremum |
| | | 141 | | /// </summary> |
| | | 142 | | int ExtremumTypeCheckRadius { get; set; } |
| | | 143 | | |
| | | 144 | | float ExtremumMergeRadius { get; set; } |
| | | 145 | | |
| | | 146 | | /// <summary> |
| | | 147 | | /// Which ratio of "correctly aligned" points should match to distinguish between Undefined or Minimum/Maximum ? |
| | | 148 | | /// </summary> |
| | | 149 | | float ExtremumTypeCheckFittingPercentage { get; set; } |
| | | 150 | | |
| | | 151 | | /// <summary> |
| | | 152 | | /// Defines how neighboring the points are sampled for determining the type of extremum. |
| | | 153 | | /// </summary> |
| | | 154 | | ExtremumTypeCheckMethod ExtremumTypeCheckMethod { get; set; } |
| | | 155 | | |
| | | 156 | | /// <summary> |
| | | 157 | | /// Occurs when new interactions are detected. |
| | | 158 | | /// </summary> |
| | | 159 | | event EventHandler<IList<Interaction>> NewInteractions; |
| | | 160 | | |
| | | 161 | | /// <summary> |
| | | 162 | | /// Occurs when interaction history is updated. |
| | | 163 | | /// </summary> |
| | | 164 | | event EventHandler<IList<InteractionFrame>> InteractionHistoryUpdated; |
| | | 165 | | |
| | | 166 | | /// <summary> |
| | | 167 | | /// Updates the observer to generate a new interaction. |
| | | 168 | | /// </summary> |
| | | 169 | | Task<ProcessingResult> Update(); |
| | | 170 | | |
| | | 171 | | /// <summary>Processes the observation while its rasters are reserved for this update.</summary> |
| | | 172 | | /// <remarks>Finish reading the input before the task completes. Copy data needed by later work.</remarks> |
| | 0 | 173 | | Task<ProcessingResult> Update(TrackingObservation observation) => Update(); |
| | | 174 | | |
| | 0 | 175 | | void AdvanceTime(double timestampSeconds) { } |
| | | 176 | | |
| | | 177 | | |
| | | 178 | | /// <summary> |
| | | 179 | | /// Calculates the average distance of al valid and not filtered points to |
| | | 180 | | /// automatically determine the distance of the zero plane |
| | | 181 | | /// </summary> |
| | | 182 | | /// <returns>the average z-depth of the surface provided by the given points</returns> |
| | | 183 | | float CalculateAverageDistance(); |
| | | 184 | | } |
| | | 185 | | } |