Parameters.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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. /// <summary>
  12. /// type of input source
  13. /// </summary>
  14. public enum InputType
  15. {
  16. Camera,
  17. Movie
  18. }
  19. /// <summary>
  20. /// Defines all parameters used in the whole program.
  21. /// </summary>
  22. static class Parameters
  23. {
  24. #region console
  25. /// <summary>
  26. /// with of the console in monospace characters
  27. /// </summary>
  28. public static readonly int ConsoleWidth = 90;
  29. /// <summary>
  30. /// height of the console in monospace characters
  31. /// </summary>
  32. public static readonly int ConsoleHeight = 30;
  33. #endregion
  34. #region input
  35. /// <summary>
  36. /// the input source type
  37. /// </summary>
  38. public static readonly InputType InputSource = InputType.Movie;
  39. /// <summary>
  40. /// path to the movie file used as input source
  41. /// </summary>
  42. public static readonly String InputMoviePath = "..\\..\\videos\\touch\\4.skv";
  43. #endregion
  44. #region Logger
  45. /// <summary>
  46. /// true iff the timer output should be shown
  47. /// </summary>
  48. public static readonly bool LoggerTimerOutputEnabled = true;
  49. /// <summary>
  50. /// bitfield which specifies which subjects should be logged
  51. /// </summary>
  52. public static readonly LogSubject LoggerEnabledSubjects = LogSubject.None;
  53. #endregion
  54. #region DebugWindow
  55. /// <summary>
  56. /// true iff the debug window is enabled
  57. /// </summary>
  58. public static readonly bool DebugWindowEnabled = true;
  59. /// <summary>
  60. /// the update interval for the debug window
  61. /// </summary>
  62. public static readonly int DebugWindowUpdateIntervall = 1000 / 30; // 30fps
  63. /// <summary>
  64. /// the title of the debug window
  65. /// </summary>
  66. public static readonly String DebugWindowTitle = "BBIWARG - DebugOutput";
  67. #endregion
  68. #region GlassesWindow
  69. /// <summary>
  70. /// true iff the glasses window is enabled
  71. /// </summary>
  72. public static readonly bool GlassesWindowEnabled = false;
  73. /// <summary>
  74. /// the update interval for the glasses window
  75. /// </summary>
  76. public static readonly int GlassesWindowUpdateInterval = 1000 / 30; // 30fps
  77. /// <summary>
  78. /// the titel of the debug window
  79. /// </summary>
  80. public static readonly String GlassesWindowTitle = "BBIWARG - GlassesOutput";
  81. /// <summary>
  82. /// number of calibration points
  83. /// </summary>
  84. public static readonly int GlassesWindowNumCalibrationPoints = 20;
  85. #endregion
  86. #region tuio
  87. /// <summary>
  88. /// true iff the tuio server is enabled
  89. /// </summary>
  90. public static readonly bool TuioEnabledByDefault = true;
  91. /// <summary>
  92. /// the default ip address of the tuio server
  93. /// </summary>
  94. public static readonly String TuioDefaultIP = "127.0.0.1";
  95. /// <summary>
  96. /// the default port of the tuio server
  97. /// </summary>
  98. public static readonly Int16 TuioDefaultPort = 3333;
  99. #endregion
  100. #region ConfidenceImage
  101. /// <summary>
  102. /// the minimum confidence threshold for pixel values to be considered correct
  103. /// </summary>
  104. public static readonly int ConfidenceImageMinThreshold = 500;
  105. #endregion
  106. #region DepthImage
  107. /// <summary>
  108. /// the size of the median filter used to filter the depth image
  109. /// </summary>
  110. public static readonly int DepthImageMedianSize = 5;
  111. /// <summary>
  112. /// the depth range which is considered important (in mm)
  113. /// </summary>
  114. public static readonly int DepthImageDepthRange = 200; // <255
  115. #endregion
  116. #region EdgeImage
  117. /// <summary>
  118. /// start threshold for the canny edge detector used to detect edges in the depth image
  119. /// </summary>
  120. public static readonly int EdgeImageCannyStartThreshold = 80;
  121. /// <summary>
  122. /// linking threshold for the canny edge detector used to detect edges in the depth image
  123. /// </summary>
  124. public static readonly int EdgeImageCannyLinkingThreshold = 60;
  125. /// <summary>
  126. /// filter size for the canny edge detector used to detect edges in the depth image
  127. /// </summary>
  128. public static readonly int EdgeImageCannySize = 3;
  129. /// <summary>
  130. /// number of dilation iterations to generate the rough edge image from the edge image
  131. /// </summary>
  132. public static readonly int EdgeImageRoughNumDilationIterations = 1;
  133. #endregion
  134. #region general tracking
  135. /// <summary>
  136. /// if a tracked object moves this relative amount it will have a similarity of 0 to itself at the previous position
  137. /// </summary>
  138. public static readonly float TrackerMaxRelativeMove = 0.25f;
  139. #endregion
  140. #region finger detection
  141. public static readonly int FingerStepSize = 1;
  142. public static readonly int FingerMaxGapCounter = 3;
  143. public static readonly int FingerMaxSliceDifferencePerStep = 5;
  144. public static readonly int FingerMinNumSlices = 20 / FingerStepSize;
  145. public static readonly float FingerMaxWidth3D = 35f;
  146. public static readonly int FingerMaxWidth2D = 30; // TODO remove and replace with 3Dwidth
  147. public static readonly int FingerMinWidth2D = 2;
  148. public static readonly int FingerRemoveNumSlicesForCorrection = 10 / FingerStepSize;
  149. public static readonly int FingerNumSlicesForRelativeDirection = FingerRemoveNumSlicesForCorrection;
  150. public static readonly int FingerOutMargin = 6;
  151. public static readonly int FingerMaxCrippleDifference = 20;
  152. public static readonly int FingerContourMargin = 4;
  153. #endregion
  154. #region finger tracking
  155. public static readonly int FingerTrackerNumFramesDetectedUntilTracked = 5;
  156. public static readonly int FingerTrackerNumFramesLostUntilDeleted = 10;
  157. public static readonly float FingermXX = 0.000005f;
  158. public static readonly float FingermXY = 0.0f;
  159. public static readonly float FingermYY = 0.000005f;
  160. public static readonly int FingerTrackerNumDirectionsForMeanDirection = 10;
  161. public static readonly float FingerTrackerMaxTipPointRelativeMove = TrackerMaxRelativeMove;
  162. public static readonly float FingerTrackerMaxHandPointRelativeMove = TrackerMaxRelativeMove;
  163. #endregion
  164. #region hand detection
  165. public static readonly int HandNumColors = 3;
  166. public static readonly int HandFloodFillDownDiff = 2;
  167. public static readonly int HandFloodFillUpDiff = 2;
  168. public static readonly float HandMaxSize = 0.6f;
  169. public static readonly float HandMinSize = 0.01f;
  170. public static readonly float HandExtensionMaxRelativeSize = 0.5f * HandMaxSize;
  171. public static readonly int HandExtendMaxDifference = 40;
  172. public static readonly float HandThumbDefectMaxDistanceToThumb = Parameters.FingerMaxWidth2D;
  173. public static readonly float HandThumbDefectMinThumbShortLengthRatio = 0.75f;
  174. public static readonly float HandThumbDefectMaxThumbShortLengthRatio = 1.1f;
  175. public static readonly float HandThumbDefectMinShortLongLengthRatio = 0.3f;
  176. public static readonly float HandThumbDefectMaxShortLongLengthRatio = 0.7f;
  177. #endregion
  178. #region hand tracker
  179. public static readonly int HandTrackerNumFramesDetectedUntilTracked = 5;
  180. public static readonly int HandTrackerNumFramesLostUntilDeleted = 5;
  181. public static readonly float HandTrackerMaxCentroidRelativeMove = TrackerMaxRelativeMove;
  182. public static readonly float HandmXX = 0.0005f;
  183. public static readonly float HandmXY = 0.0f;
  184. public static readonly float HandmYY = 0.0005f;
  185. #endregion
  186. #region palm detection
  187. public static readonly int PalmNumPositionsForPalmWidth = 5;
  188. public static readonly float PalmInsideTolerance = 0.1f;
  189. #endregion
  190. #region palm tracker
  191. public static readonly int PalmTrackerNumFramesDetectedUntilTracked = 5;
  192. public static readonly int PalmTrackerNumFramesLostUntilDeleted = 5;
  193. public static readonly float PalmTrackerMaxWristUpperRelativeMove = TrackerMaxRelativeMove;
  194. public static readonly float PalmTrackerMaxWristLowerRelativeMove = TrackerMaxRelativeMove;
  195. public static readonly float PalmTrackerMaxFingersUpperRelativeMove = TrackerMaxRelativeMove;
  196. public static readonly float PalmTrackerMaxFingersLowerRelativeMove = TrackerMaxRelativeMove;
  197. public static readonly float PalmmXX = 0.00005f;
  198. public static readonly float PalmmXY = 0.0f;
  199. public static readonly float PalmmYY = 0.00005f;
  200. #endregion
  201. #region palm grid
  202. /// <summary>
  203. /// default number of palm grid rows
  204. /// </summary>
  205. public static readonly int PalmGridDefaultNumRows = 3;
  206. /// <summary>
  207. /// default number of palm grid columns
  208. /// </summary>
  209. public static readonly int PalmGridDefaultNumColumns = 4;
  210. #endregion
  211. #region touch
  212. public static readonly float TouchMinTouchValue = 0.3f;
  213. public static readonly int TouchAreaSize = 30;
  214. public static readonly int TouchFloodfillDownDiff = 1;
  215. public static readonly int TouchFloodfillUpDiff = 3;
  216. public static readonly int TouchTipInsideFactor = 2;
  217. public static readonly int TouchTipOutsideFactor = 7;
  218. #endregion
  219. #region touch tracking
  220. /// <summary>
  221. /// number of frames an object needs to be detected before it is tracked
  222. /// </summary>
  223. public static readonly int TouchTrackerNumFramesDetectedUntilTracked = 1;
  224. /// <summary>
  225. /// number of frames an object needs to be lost before it is deleted
  226. /// </summary>
  227. public static readonly int TouchTrackerNumFramesLostUntilDeleted = 5;
  228. /// <summary>
  229. /// if the absolute position of a tracked touch event moves this relative amount it will have a similarity of 0 to itself at the previous position
  230. /// </summary>
  231. public static readonly float TouchTrackerMaxAbsolutePositionRelativeMove = TrackerMaxRelativeMove;
  232. /// <summary>
  233. /// xx entry for the measurement noise covariance matrix for the kalman filter used to smooth touch events
  234. /// </summary>
  235. public static readonly float TouchmXX = 0.003f;
  236. /// <summary>
  237. /// xy and yx entry for the measurement noise covariance matrix for the kalman filter used to smooth touch events
  238. /// </summary>
  239. public static readonly float TouchmXY = 0.0f;
  240. /// <summary>
  241. /// yy entry for the measurement noise covariance matrix for the kalman filter used to smooth touch events
  242. /// </summary>
  243. public static readonly float TouchmYY = 0.00165f;
  244. /// <summary>
  245. /// value used for all entries in the process noise covariance matrix for the kalman filter used to smooth touch events
  246. /// </summary>
  247. public static readonly float TouchProcessNoise = 3.0e-4f;
  248. #endregion
  249. #region TouchEventVisualizer
  250. /// <summary>
  251. /// time in ms after which old touch events are removed from the touch event visualizer
  252. /// </summary>
  253. public static readonly int TouchEventVisualizerFadeOutTime = 1500;
  254. #endregion
  255. #region homographyExport
  256. /// <summary>
  257. /// file name of the file to which the homography is written
  258. /// </summary>
  259. public static readonly String HomographyFileName = "homography.txt";
  260. #endregion
  261. #region colors
  262. #region general
  263. /// <summary>
  264. /// color used to draw detected objects
  265. /// </summary>
  266. public static readonly Color ColorDetected = Color.Turquoise;
  267. /// <summary>
  268. /// color used to draw tracked objects
  269. /// </summary>
  270. public static readonly Color ColorTracked = Color.Yellow;
  271. #endregion
  272. #region images
  273. /// <summary>
  274. /// color used to specify which color channels the depth image is drawn to
  275. /// </summary>
  276. public static readonly Color DepthImageColor = Color.White;
  277. /// <summary>
  278. /// color used to specify which color channels the edge image is drawn to
  279. /// </summary>
  280. public static readonly Color EdgeImageColor = Color.Blue;
  281. /// <summary>
  282. /// color used to draw the borders of the output images
  283. /// </summary>
  284. public static readonly Color OutputImageBorderColor = Color.White;
  285. #endregion
  286. #region finger
  287. /// <summary>
  288. /// color used to draw the finger slices
  289. /// </summary>
  290. public static readonly Color FingerSliceColor = Color.Magenta;
  291. /// <summary>
  292. /// color used to draw the detected fingers
  293. /// </summary>
  294. public static readonly Color FingerDetectedColor = ColorDetected;
  295. /// <summary>
  296. /// color used to draw the tracked fingers
  297. /// </summary>
  298. public static readonly Color FingerTrackedColor = ColorTracked;
  299. /// <summary>
  300. /// color used to draw the finger tip point
  301. /// </summary>
  302. public static readonly Color FingerTipColor = Color.Blue;
  303. /// <summary>
  304. /// color used to draw the finger hand point
  305. /// </summary>
  306. public static readonly Color FingerHandColor = Color.Yellow;
  307. /// <summary>
  308. /// color used to draw the finger contour
  309. /// </summary>
  310. public static readonly Color FingerContourColor = Color.Red;
  311. /// <summary>
  312. /// color used to draw the text for the finger id
  313. /// </summary>
  314. public static readonly Color FingerIDColor = Color.White;
  315. #endregion
  316. #region touch
  317. /// <summary>
  318. /// color used to draw detected touch events
  319. /// </summary>
  320. public static readonly Color TouchEventDetectedColor = ColorDetected;
  321. /// <summary>
  322. /// color used to draw tracked touch events
  323. /// </summary>
  324. public static readonly Color TouchEventTrackedColor = ColorTracked;
  325. #endregion
  326. #region TouchEventVisualizer
  327. /// <summary>
  328. /// color used to draw the lines between touch events in the touch event visualizer
  329. /// </summary>
  330. public static readonly Color TouchEventVisualizerLineColor = Color.Yellow;
  331. /// <summary>
  332. /// color used to draw the touch event points in the touch event visualizer
  333. /// </summary>
  334. public static readonly Color TouchEventVisualizerPointColor = Color.Red;
  335. /// <summary>
  336. /// color used to draw the grid in the touch event visualizer
  337. /// </summary>
  338. public static readonly Color TouchEventVisualizerGridColor = Color.White;
  339. /// <summary>
  340. /// color used to draw the text in the touch event visualizer
  341. /// </summary>
  342. public static readonly Color TouchEventVisualizerTextColor = Color.White;
  343. /// <summary>
  344. /// color used to highlight the active block in the touch event visualizer
  345. /// </summary>
  346. public static readonly Color TouchEventVisualizerActiveBlockColor = Color.DarkSlateGray;
  347. #endregion
  348. #region palm
  349. /// <summary>
  350. /// color used to draw the plam quadrangle
  351. /// </summary>
  352. public static readonly Color PalmQuadColor = Color.Blue;
  353. /// <summary>
  354. /// color used to draw the palm grid in the palm
  355. /// </summary>
  356. public static readonly Color PalmGridColor = Color.CornflowerBlue;
  357. #endregion
  358. #region hand
  359. /// <summary>
  360. /// colors used to draw the hands (ith element is a color which specifies the color channels used to draw the ith hand)
  361. /// </summary>
  362. public static readonly Color[] HandColors = new Color[3] { Color.Red, Color.Blue, Color.Green };
  363. /// <summary>
  364. /// color used to draw the hand centroid
  365. /// </summary>
  366. public static readonly Color HandCentroidColor = Color.Yellow;
  367. /// <summary>
  368. /// color used to draw the hand id text
  369. /// </summary>
  370. public static readonly Color HandIDColor = Color.White;
  371. /// <summary>
  372. /// color used to draw the points of the thumb defects
  373. /// </summary>
  374. public static readonly Color HandThumbDefectPointColor = Color.Lime;
  375. /// <summary>
  376. /// color used to draw the lines of the thumb defects
  377. /// </summary>
  378. public static readonly Color HandThumbDefectLineColor = Color.CornflowerBlue;
  379. #endregion
  380. #region calibration
  381. /// <summary>
  382. /// color used to draw the calibration points in the glasses window
  383. /// </summary>
  384. public static readonly Color CalibrationPointColor = Color.Yellow;
  385. #endregion
  386. #endregion
  387. }
  388. }