Parameters.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Net;
  8. using bbiwarg.Utility;
  9. namespace bbiwarg
  10. {
  11. public enum InputType
  12. {
  13. Camera,
  14. Movie
  15. }
  16. class Parameters
  17. {
  18. // input
  19. public static readonly InputType InputSource = InputType.Movie;
  20. public static readonly String InputMoviePath = "..\\..\\videos\\touch\\4.skv";
  21. // Logger
  22. public static readonly LogSubject EnabledLogSubjects = LogSubject.None;
  23. public static readonly int ConsoleWidth = 90;
  24. public static readonly int ConsoleHeight = 30;
  25. // Debug window
  26. public static readonly bool DebugWindowEnabled = true;
  27. public static readonly int DebugWindowUpdateRate = 30;
  28. public static readonly int DebugWindowRenderRate = 30;
  29. public static readonly int DebugWindowNumImages = 5;
  30. public static readonly int DebugWindowNumImagesPerRow = 3;
  31. public static readonly float DebugWindowScaleFactor = 1f; // output window size is scaled by this factor (from necessary size for images)
  32. public static readonly String DebugWindowTitle = "BBIWARG - DebugOutput";
  33. // glasses window
  34. public static readonly bool GlassesWindowEnabled = true;
  35. public static readonly int GlassesWindowUpdateRate = 30;
  36. public static readonly int GlassesWindowRenderRate = 30;
  37. public static readonly int GlassesWindowWidth = 1280;
  38. public static readonly int GlassesWindowHeight = 720;
  39. public static readonly String GlassesWindowTitle = "BBIWARG - GlassesOutput";
  40. // TUIO
  41. public static bool TuioEnabled { get; private set; }
  42. public static IPAddress TuioIP { get; private set; }
  43. public static Int16 TuioPort { get; private set; }
  44. // image
  45. public static int ImageWidth { get; private set; }
  46. public static int ImageHeight { get; private set; }
  47. public static int ImageNumPixels { get; private set; }
  48. public static Vector2D ImageMaxPixel { get; private set; }
  49. public static float ImageDiagonalLength { get; private set; }
  50. public static float ImageAspectRatio { get; private set; }
  51. // confidence image
  52. public static readonly int ConfidenceImageMinThreshold = 500;
  53. // depth image
  54. public static readonly int DepthImageMedianSize = 5;
  55. public static readonly int DepthImageDepthRange = 200; // <255
  56. // edge image
  57. public static readonly int EdgeImageCannyStartThreshold = 80;
  58. public static readonly int EdgeImageCannyLinkingThreshold = 60;
  59. public static readonly int EdgeImageCannySize = 3;
  60. public static readonly int EdgeImageRoughNumDilationIterations = 1;
  61. // general tracking
  62. public static readonly float TrackerMaxRelativeMove = 0.25f;
  63. // finger detection
  64. public static readonly int FingerStepSize = 1;
  65. public static readonly int FingerMaxGapCounter = 3;
  66. public static readonly int FingerMaxSliceDifferencePerStep = 5;
  67. public static readonly int FingerMinNumSlices = 25 / FingerStepSize;
  68. public static readonly int FingerMaxWidth = 30;
  69. public static readonly int FingerMinWidth = 2;
  70. public static readonly int FingerRemoveNumSlicesForCorrection = 10 / FingerStepSize;
  71. public static readonly int FingerNumSlicesForRelativeDirection = FingerRemoveNumSlicesForCorrection;
  72. public static readonly int FingerOutMargin = 8;
  73. public static readonly int FingerMaxCrippleDifference = 20;
  74. public static readonly int FingerContourMargin = 4;
  75. // finger tracking
  76. public static readonly int FingerTrackerNumFramesDetectedUntilTracked = 5;
  77. public static readonly int FingerTrackerNumFramesLostUntilDeleted = 10;
  78. public static readonly float FingermXX = 0.000005f;
  79. public static readonly float FingermXY = 0.0f;
  80. public static readonly float FingermYY = 0.000005f;
  81. public static readonly int FingerTrackerNumDirectionsForMeanDirection = 10;
  82. public static readonly float FingerTrackerMaxTipPointRelativeMove = TrackerMaxRelativeMove;
  83. public static readonly float FingerTrackerMaxHandPointRelativeMove = TrackerMaxRelativeMove;
  84. // hand detection
  85. public static readonly int HandNumColors = 3;
  86. public static readonly int HandFloodFillDownDiff = 2;
  87. public static readonly int HandFloodFillUpDiff = 2;
  88. public static readonly float HandMaxSize = 0.6f;
  89. public static readonly float HandMinSize = 0.01f;
  90. public static readonly float HandExtensionMaxSize = 0.5f * HandMaxSize;
  91. public static readonly int HandExtendMaxDifference = 40;
  92. public static readonly float HandThumbDefectMaxDistanceToThumb = FingerMaxWidth;
  93. public static readonly float HandThumbDefectMinThumbShortLengthRatio = 0.75f;
  94. public static readonly float HandThumbDefectMaxThumbShortLengthRatio = 1.1f;
  95. public static readonly float HandThumbDefectMinShortLongLengthRatio = 0.3f;
  96. public static readonly float HandThumbDefectMaxShortLongLengthRatio = 0.7f;
  97. // hand tracker
  98. public static readonly int HandTrackerNumFramesDetectedUntilTracked = 5;
  99. public static readonly int HandTrackerNumFramesLostUntilDeleted = 5;
  100. public static readonly float HandTrackerMaxCentroidRelativeMove = TrackerMaxRelativeMove;
  101. public static readonly float HandmXX = 0.0005f;
  102. public static readonly float HandmXY = 0.0f;
  103. public static readonly float HandmYY = 0.0005f;
  104. // palm detection
  105. public static readonly int PalmNumPositionsForPalmWidth = 5;
  106. public static readonly float PalmInsideTolerance = 0.1f;
  107. // palm tracker
  108. public static readonly int PalmTrackerNumFramesDetectedUntilTracked = 5;
  109. public static readonly int PalmTrackerNumFramesLostUntilDeleted = 5;
  110. public static readonly float PalmTrackerMaxWristUpperRelativeMove = TrackerMaxRelativeMove;
  111. public static readonly float PalmTrackerMaxWristLowerRelativeMove = TrackerMaxRelativeMove;
  112. public static readonly float PalmTrackerMaxFingersUpperRelativeMove = TrackerMaxRelativeMove;
  113. public static readonly float PalmTrackerMaxFingersLowerRelativeMove = TrackerMaxRelativeMove;
  114. public static readonly float PalmmXX = 0.00005f;
  115. public static readonly float PalmmXY = 0.0f;
  116. public static readonly float PalmmYY = 0.00005f;
  117. //palm Grid
  118. public static int PalmGridNumRows { get; private set; }
  119. public static int PalmGridNumColumns { get; private set; }
  120. // touch detection
  121. public static readonly float TouchMinTouchValue = 0.3f;
  122. public static readonly int TouchAreaSize = 30;
  123. public static readonly int TouchFloodfillDownDiff = 1;
  124. public static readonly int TouchFloodfillUpDiff = 3;
  125. public static readonly int TouchTipInsideFactor = 2;
  126. public static readonly int TouchTipOutsideFactor = 7;
  127. // touch tracking
  128. public static readonly int TouchTrackerNumFramesDetectedUntilTracked = 1;
  129. public static readonly int TouchTrackerNumFramesLostUntilDeleted = 5;
  130. public static readonly float TouchTrackerMaxAbsolutePositionRelativeMove = TrackerMaxRelativeMove;
  131. public static readonly float TouchmXX = 0.003f;
  132. public static readonly float TouchmXY = 0.0f;
  133. public static readonly float TouchmYY = 0.00165f;
  134. public static readonly float TouchProcessNoise = 3.0e-4f;
  135. // touchEventVisualizer
  136. public static readonly int TouchEventVisualizerFadeOutTime = 1500;
  137. // colors
  138. public static readonly Color ColorDetected = Color.Turquoise;
  139. public static readonly Color ColorTracked = Color.Yellow;
  140. public static readonly Color DepthImageColor = Color.White;
  141. public static readonly Color EdgeImageColor = Color.Blue;
  142. public static readonly Color OutputImageBorderColor = Color.White;
  143. public static readonly Color FingerSliceColor = Color.Magenta;
  144. public static readonly Color FingerDetectedColor = ColorDetected;
  145. public static readonly Color FingerTrackedColor = ColorTracked;
  146. public static readonly Color FingerTipColor = Color.Blue;
  147. public static readonly Color FingerHandColor = Color.Yellow;
  148. public static readonly Color FingerContourColor = Color.Red;
  149. public static readonly Color FingerIDColor = Color.White;
  150. public static readonly Color TouchEventDetectedColor = ColorDetected;
  151. public static readonly Color TouchEventTrackedColor = ColorTracked;
  152. public static readonly Color TouchEventAreaMatchedSubtractColor = Color.DarkOrange;
  153. public static readonly Color TouchEventAreaNonMatchedSubtractColor = Color.DarkSlateGray;
  154. public static readonly Color TouchEventStatusBarColor = Color.Green;
  155. public static readonly Color TouchEventVisualizerLineColor = Color.Yellow;
  156. public static readonly Color TouchEventVisualizerPointColor = Color.Red;
  157. public static readonly Color TouchEventVisualizerGridColor = Color.White;
  158. public static readonly Color TouchEventVisualizerTextColor = Color.White;
  159. public static readonly Color TouchEventVisualizerActiveBlockColor = Color.DarkSlateGray;
  160. public static readonly Color PalmQuadColor = Color.Blue;
  161. public static readonly Color PalmGridColor = Color.CornflowerBlue;
  162. public static readonly Color[] HandColors = new Color[3] { Color.Red, Color.Blue, Color.Green };
  163. public static readonly Color HandCentroidColor = Color.Yellow;
  164. public static readonly Color HandIDColor = Color.White;
  165. public static readonly Color HandThumbDefectPointColor = Color.Lime;
  166. public static readonly Color HandThumbDefectLineColor = Color.CornflowerBlue;
  167. static Parameters()
  168. {
  169. setImageParameters(320, 240);
  170. setTuioParameters(true, new IPAddress(new byte[4] { 127, 0, 0, 1 }), 3333);
  171. setPalmGridParameters(3, 4);
  172. }
  173. public static void setImageParameters(int width, int height)
  174. {
  175. ImageWidth = width;
  176. ImageHeight = height;
  177. ImageNumPixels = ImageWidth * ImageHeight;
  178. ImageMaxPixel = new Vector2D(ImageWidth - 1, ImageHeight - 1);
  179. ImageDiagonalLength = ImageMaxPixel.Length;
  180. ImageAspectRatio = (float)ImageWidth / (float)ImageHeight;
  181. }
  182. public static void setTuioParameters(bool enabled, IPAddress ipAddress, Int16 port)
  183. {
  184. TuioEnabled = enabled;
  185. TuioIP = ipAddress;
  186. TuioPort = port;
  187. }
  188. public static void setPalmGridParameters(int numRows, int numColumns)
  189. {
  190. PalmGridNumRows = numRows;
  191. PalmGridNumColumns = numColumns;
  192. }
  193. }
  194. }