using BBIWARG.Utility; using System; using System.Drawing; namespace BBIWARG { /// /// type of input source /// public enum InputType { Camera, Movie } /// /// Defines all parameters used in the whole program. /// internal static class Parameters { #region console /// /// height of the console in mono space characters /// public static readonly int ConsoleHeight = 30; /// /// with of the console in mono space characters /// public static readonly int ConsoleWidth = 90; #endregion console #region input /// /// path to the movie file used as input source /// public static readonly String InputMoviePath = "..\\..\\videos\\touch\\4.skv"; /// /// the input source type /// public static readonly InputType InputSource = InputType.Camera; #endregion input #region Logger /// /// bit field which specifies which subjects should be logged /// public static readonly LogSubject LoggerEnabledSubjects = LogSubject.None; /// /// true iff the timer output should be shown /// public static readonly bool LoggerTimerOutputEnabled = false; #endregion Logger #region DebugWindow /// /// true iff the debug window is enabled /// public static readonly bool DebugWindowEnabled = true; /// /// the title of the debug window /// public static readonly String DebugWindowTitle = "BBIWARG - DebugOutput"; /// /// the update interval for the debug window /// public static readonly int DebugWindowUpdateIntervall = 1000 / 30; // 30fps #endregion DebugWindow #region GlassesWindow /// /// true iff the glasses window is enabled /// public static readonly bool GlassesWindowEnabled = false; /// /// number of calibration points /// public static readonly int GlassesWindowNumCalibrationPoints = 20; /// /// the title of the debug window /// public static readonly String GlassesWindowTitle = "BBIWARG - GlassesOutput"; /// /// the update interval for the glasses window /// public static readonly int GlassesWindowUpdateInterval = 1000 / 30; // 30fps #endregion GlassesWindow #region tuio /// /// the default ip address of the tuio server /// public static readonly String TuioDefaultIP = "127.0.0.1"; /// /// the default port of the tuio server /// public static readonly Int16 TuioDefaultPort = 3333; /// /// true iff the tuio server is enabled /// public static readonly bool TuioEnabledByDefault = true; #endregion tuio #region ConfidenceImage /// /// the minimum confidence threshold for pixel values to be considered correct /// public static readonly int ConfidenceImageMinThreshold = 500; #endregion ConfidenceImage #region DepthImage /// /// the depth range which is considered important (in mm) (must be smaller than 255) /// public static readonly int DepthImageDepthRange = 200; /// /// the size of the median filter used to filter the depth image /// public static readonly int DepthImageMedianSize = 5; #endregion DepthImage #region EdgeImage /// /// linking threshold for the canny edge detector used to detect edges in the depth image /// public static readonly int EdgeImageCannyLinkingThreshold = 60; /// /// filter size for the canny edge detector used to detect edges in the depth image /// public static readonly int EdgeImageCannySize = 3; /// /// start threshold for the canny edge detector used to detect edges in the depth image /// public static readonly int EdgeImageCannyStartThreshold = 80; /// /// number of dilation iterations to generate the rough edge image from the edge image /// public static readonly int EdgeImageRoughNumDilationIterations = 1; #endregion EdgeImage #region general tracking /// /// if a tracked object moves this relative amount it will have a similarity of 0 to itself at the previous position /// public static readonly float TrackerMaxRelativeMove = 0.25f; #endregion general tracking #region finger detection /// /// the contour margin around the finger /// public static readonly int FingerContourMargin = 4; /// /// the maximum depth difference between the finger and a point beside the finger /// public static readonly int FingerMaxCrippleDifference = 20; /// /// the number of missed slices until the trail expansion stops /// public static readonly int FingerMaxGapCounter = 3; /// /// the maximum slice length difference of two consecutive slices (used to drop outliers) /// public static readonly int FingerMaxSliceLengthDifferencePerStep = 5; /// /// maximum finger slice length (in pixels) /// public static readonly int FingerMaxWidth2D = 30; /// /// maximum finger slice length (in mm) /// public static readonly float FingerMaxWidth3D = 35f; /// /// the minimum number of slices a finger must have /// public static readonly int FingerMinNumSlices = 20; // TODO remove and replace with 3Dwidth /// /// minimum finger slice length (in pixels) /// public static readonly int FingerMinWidth2D = 2; /// /// the number of slices used to calculate the start and end directions /// public static readonly int FingerNumSlicesForRelativeDirection = 5; /// /// the distance of a point to be considered beside the finger (in pixels) /// public static readonly int FingerOutMargin = 6; /// /// the number of slices that are removed when the finger expansion starts in opposite direction (because initial slices don't have the correct direction) /// public static readonly int FingerRemoveNumSlicesForCorrection = 10; #endregion finger detection #region finger tracking /// /// xx entry for the measurement noise covariance matrix for the kalman filter used to smooth the finger hand and tip points /// public static readonly float FingermXX = 0.000005f; /// /// xy and yx entry for the measurement noise covariance matrix for the kalman filter used to smooth the finger hand and tip points /// public static readonly float FingermXY = 0.0f; /// /// yy entry for the measurement noise covariance matrix for the kalman filter used to smooth the finger hand and tip points /// public static readonly float FingermYY = 0.000005f; /// /// if the hand point of a finger moves this relative amount it will have a similarity of 0 to itself at the previous position /// public static readonly float FingerTrackerMaxHandPointRelativeMove = TrackerMaxRelativeMove; /// /// if the tip point of a finger moves this relative amount it will have a similarity of 0 to itself at the previous position /// public static readonly float FingerTrackerMaxTipPointRelativeMove = TrackerMaxRelativeMove; /// /// number of finger slice directions used to compute the mean finger direction /// public static readonly int FingerTrackerNumDirectionsForMeanDirection = 10; /// /// number of frames a finger needs to be detected before it is tracked /// public static readonly int FingerTrackerNumFramesDetectedUntilTracked = 5; /// /// number of frames a finger needs to be lost before it is deleted /// public static readonly int FingerTrackerNumFramesLostUntilDeleted = 10; #endregion finger tracking #region hand detection /// /// maximum depth difference below which two sections of a hand which are separated by a finger are considered to belong to the same hand /// public static readonly int HandExtendMaxDifference = 40; /// /// maximum size of a hand extension mask relative to the whole image /// public static readonly float HandExtensionMaxRelativeSize = 0.5f * HandMaxSize; /// /// maximum downwards depth difference between a pixel and a neighboring pixel belonging to the same hand /// public static readonly int HandFloodFillDownDiff = 2; /// /// maximum upwards depth difference between a pixel and a neighboring pixel belonging to the same hand /// public static readonly int HandFloodFillUpDiff = 2; /// /// maximum size of a hand relative to the whole image /// public static readonly float HandMaxSize = 0.6f; /// /// minimum size of a hand relative to the whole image /// public static readonly float HandMinSize = 0.01f; /// /// number of colors used to draw hands /// public static readonly int HandNumColors = 3; /// /// the maximum distance of the thumb tip point to the outer short point of a convexity defect for possible thumb defects /// public static readonly float HandThumbDefectMaxDistanceToThumb = Parameters.FingerMaxWidth2D; /// /// the maximum ratio of the length from the depth point to the outer short point to /// the length from the depth point to the outer long point of a convexity defect for possible thumb defects /// public static readonly float HandThumbDefectMaxShortLongLengthRatio = 0.7f; /// /// the maximum ratio of the thumb length to the length from the depth point to the outer short point of a convexity defect for possible thumb defects /// public static readonly float HandThumbDefectMaxThumbShortLengthRatio = 1.1f; /// /// the minimum ratio of the length from the depth point to the outer short point to /// the length from the depth point to the outer long point of a convexity defect for possible thumb defects /// public static readonly float HandThumbDefectMinShortLongLengthRatio = 0.3f; /// /// the minimum ratio of the thumb length to the length from the depth point to the outer short point of a convexity defect for possible thumb defects /// public static readonly float HandThumbDefectMinThumbShortLengthRatio = 0.75f; #endregion hand detection #region hand tracker /// /// xx entry for the measurement noise covariance matrix for the kalman filter used to smooth the hand centroid /// public static readonly float HandmXX = 0.0005f; /// /// xy and yx entry for the measurement noise covariance matrix for the kalman filter used to smooth the hand centroid /// public static readonly float HandmXY = 0.0f; /// /// yy entry for the measurement noise covariance matrix for the kalman filter used to smooth the hand centroid /// public static readonly float HandmYY = 0.0005f; /// /// if the centroid of a hand moves this relative amount it will have a similarity of 0 to itself at the previous position /// public static readonly float HandTrackerMaxCentroidRelativeMove = TrackerMaxRelativeMove; /// /// number of frames a hand needs to be detected before it is tracked /// public static readonly int HandTrackerNumFramesDetectedUntilTracked = 5; /// /// number of frames a hand needs to be lost before it is deleted /// public static readonly int HandTrackerNumFramesLostUntilDeleted = 5; #endregion hand tracker #region palm detection /// /// relative tolerance which specifies when a point is considered to be in the palm grid /// public static readonly float PalmInsideTolerance = 0.1f; /// /// number of positions along the forefinger used as starting points to detect the palm width /// public static readonly int PalmNumPositionsForPalmWidth = 5; #endregion palm detection #region palm tracker /// /// xx entry for the measurement noise covariance matrix for the kalman filter used to smooth the palm grid points /// public static readonly float PalmmXX = 0.00005f; /// /// xy and yx entry for the measurement noise covariance matrix for the kalman filter used to smooth the palm grid points /// public static readonly float PalmmXY = 0.0f; /// /// yy entry for the measurement noise covariance matrix for the kalman filter used to smooth the palm grid points /// public static readonly float PalmmYY = 0.00005f; /// /// if the lower finger point of the palm grid moves this relative amount it will have a similarity of 0 to itself at the previous position /// public static readonly float PalmTrackerMaxFingersLowerRelativeMove = TrackerMaxRelativeMove; /// /// if the upper finger point of the palm grid moves this relative amount it will have a similarity of 0 to itself at the previous position /// public static readonly float PalmTrackerMaxFingersUpperRelativeMove = TrackerMaxRelativeMove; /// /// if the lower wrist point of the palm grid moves this relative amount it will have a similarity of 0 to itself at the previous position /// public static readonly float PalmTrackerMaxWristLowerRelativeMove = TrackerMaxRelativeMove; /// /// if the upper wrist point of the palm grid moves this relative amount it will have a similarity of 0 to itself at the previous position /// public static readonly float PalmTrackerMaxWristUpperRelativeMove = TrackerMaxRelativeMove; /// /// number of frames a palm needs to be detected before it is tracked /// public static readonly int PalmTrackerNumFramesDetectedUntilTracked = 5; /// /// number of frames a palm needs to be lost before it is deleted /// public static readonly int PalmTrackerNumFramesLostUntilDeleted = 5; #endregion palm tracker #region palm grid /// /// default number of palm grid columns /// public static readonly int PalmGridDefaultNumColumns = 4; /// /// default number of palm grid rows /// public static readonly int PalmGridDefaultNumRows = 3; #endregion palm grid #region touch detection /// /// the size of the quadrant around the touch positions that is used to determine the touch value /// public static readonly int TouchAreaSize = 30; /// /// the maximum downwards difference for the flood fill operation /// public static readonly int TouchFloodfillDownDiff = 1; /// /// the maximum upwards difference for the flood fill operation /// public static readonly int TouchFloodfillUpDiff = 3; /// /// the threshold number of pixels affected by the flood fill (in percentage) to be considered as a touch /// public static readonly float TouchMinTouchValue = 0.3f; /// /// the position adjustment for the start point of the flood fill operation /// public static readonly int TouchTipInsideFactor = 2; /// /// the position adjustment for the position of the actual touch event /// public static readonly int TouchTipOutsideFactor = 7; #endregion touch detection #region touch tracking /// /// xx entry for the measurement noise covariance matrix for the kalman filter used to smooth touch events /// public static readonly float TouchmXX = 0.003f; /// /// xy and yx entry for the measurement noise covariance matrix for the kalman filter used to smooth touch events /// public static readonly float TouchmXY = 0.0f; /// /// yy entry for the measurement noise covariance matrix for the kalman filter used to smooth touch events /// public static readonly float TouchmYY = 0.00165f; /// /// value used for all entries in the process noise covariance matrix for the kalman filter used to smooth touch events /// public static readonly float TouchProcessNoise = 3.0e-4f; /// /// 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 /// public static readonly float TouchTrackerMaxAbsolutePositionRelativeMove = TrackerMaxRelativeMove; /// /// number of frames an object needs to be detected before it is tracked /// public static readonly int TouchTrackerNumFramesDetectedUntilTracked = 1; /// /// number of frames an object needs to be lost before it is deleted /// public static readonly int TouchTrackerNumFramesLostUntilDeleted = 5; #endregion touch tracking #region TouchEventVisualizer /// /// time in milliseconds after which old touch events are removed from the touch event visualizer /// public static readonly int TouchEventVisualizerFadeOutTime = 1500; #endregion TouchEventVisualizer #region homographyExport /// /// file name of the file to which the homography is written /// public static readonly String HomographyFileName = "homography.txt"; #endregion homographyExport #region colors #region general /// /// color used to draw detected objects /// public static readonly Color ColorDetected = Color.Turquoise; /// /// color used to draw tracked objects /// public static readonly Color ColorTracked = Color.Yellow; #endregion general #region images /// /// color used to specify which color channels the depth image is drawn to /// public static readonly Color DepthImageColor = Color.White; /// /// color used to specify which color channels the edge image is drawn to /// public static readonly Color EdgeImageColor = Color.Blue; /// /// color used to draw the borders of the output images /// public static readonly Color OutputImageBorderColor = Color.White; #endregion images #region finger /// /// color used to draw the finger contour /// public static readonly Color FingerContourColor = Color.Red; /// /// color used to draw the detected fingers /// public static readonly Color FingerDetectedColor = ColorDetected; /// /// color used to draw the finger hand point /// public static readonly Color FingerHandColor = Color.Yellow; /// /// color used to draw the text for the finger id /// public static readonly Color FingerIDColor = Color.White; /// /// color used to draw the finger slices /// public static readonly Color FingerSliceColor = Color.Magenta; /// /// color used to draw the finger tip point /// public static readonly Color FingerTipColor = Color.Blue; /// /// color used to draw the tracked fingers /// public static readonly Color FingerTrackedColor = ColorTracked; #endregion finger #region touch /// /// color used to draw detected touch events /// public static readonly Color TouchEventDetectedColor = ColorDetected; /// /// color used to draw tracked touch events /// public static readonly Color TouchEventTrackedColor = ColorTracked; #endregion touch #region TouchEventVisualizer /// /// color used to highlight the active block in the touch event visualizer /// public static readonly Color TouchEventVisualizerActiveBlockColor = Color.DarkSlateGray; /// /// color used to draw the grid in the touch event visualizer /// public static readonly Color TouchEventVisualizerGridColor = Color.White; /// /// color used to draw the lines between touch events in the touch event visualizer /// public static readonly Color TouchEventVisualizerLineColor = Color.Yellow; /// /// color used to draw the touch event points in the touch event visualizer /// public static readonly Color TouchEventVisualizerPointColor = Color.Red; /// /// color used to draw the text in the touch event visualizer /// public static readonly Color TouchEventVisualizerTextColor = Color.White; #endregion TouchEventVisualizer #region palm /// /// color used to draw the palm grid in the palm /// public static readonly Color PalmGridColor = Color.CornflowerBlue; /// /// color used to draw the palm quadrangle /// public static readonly Color PalmQuadColor = Color.Blue; #endregion palm #region hand /// /// color used to draw the hand centroid /// public static readonly Color HandCentroidColor = Color.Yellow; /// /// colors used to draw the hands (element is a color which specifies the color channels used to draw the hand) /// public static readonly Color[] HandColors = new Color[3] { Color.Red, Color.Blue, Color.Green }; /// /// color used to draw the hand id text /// public static readonly Color HandIDColor = Color.White; /// /// color used to draw the lines of the thumb defects /// public static readonly Color HandThumbDefectLineColor = Color.CornflowerBlue; /// /// color used to draw the points of the thumb defects /// public static readonly Color HandThumbDefectPointColor = Color.Lime; #endregion hand #region calibration /// /// color used to draw the calibration points in the glasses window /// public static readonly Color CalibrationPointColor = Color.Yellow; #endregion calibration #endregion colors } }