Browse Source

documented more parameters

Daniel Kauth 10 years ago
parent
commit
086fead0a9
2 changed files with 130 additions and 2 deletions
  1. 121 1
      bbiwarg/Parameters.cs
  2. 9 1
      bbiwarg/Recognition/HandRecognition/HandDetector.cs

+ 121 - 1
bbiwarg/Parameters.cs

@@ -44,7 +44,7 @@ namespace bbiwarg
         /// <summary>
         /// the input source type
         /// </summary>
-        public static readonly InputType InputSource = InputType.Movie;
+        public static readonly InputType InputSource = InputType.Camera;
 
         /// <summary>
         /// path to the movie file used as input source
@@ -214,13 +214,44 @@ namespace bbiwarg
 
         #region finger tracking
 
+        /// <summary>
+        /// number of frames a finger needs to be detected before it is tracked
+        /// </summary>
         public static readonly int FingerTrackerNumFramesDetectedUntilTracked = 5;
+
+        /// <summary>
+        /// number of frames a finger needs to be lost before it is deleted
+        /// </summary>
         public static readonly int FingerTrackerNumFramesLostUntilDeleted = 10;
+
+        /// <summary>
+        /// xx entry for the measurement noise covariance matrix for the kalman filter used to smooth the finger hand and tip points
+        /// </summary>
         public static readonly float FingermXX = 0.000005f;
+
+        /// <summary>
+        /// xy and yx entry for the measurement noise covariance matrix for the kalman filter used to smooth the finger hand and tip points
+        /// </summary>
         public static readonly float FingermXY = 0.0f;
+
+        /// <summary>
+        /// yy entry for the measurement noise covariance matrix for the kalman filter used to smooth the finger hand and tip points
+        /// </summary>
         public static readonly float FingermYY = 0.000005f;
+
+        /// <summary>
+        /// number of finger slice directions used to compute the mean finger direction
+        /// </summary>
         public static readonly int FingerTrackerNumDirectionsForMeanDirection = 10;
+
+        /// <summary>
+        /// if the tip point of a finger moves this relative amount it will have a similarity of 0 to itself at the previous position
+        /// </summary>
         public static readonly float FingerTrackerMaxTipPointRelativeMove = TrackerMaxRelativeMove;
+
+        /// <summary>
+        /// if the hand point of a finger moves this relative amount it will have a similarity of 0 to itself at the previous position
+        /// </summary>
         public static readonly float FingerTrackerMaxHandPointRelativeMove = TrackerMaxRelativeMove;
 
         #endregion
@@ -228,12 +259,36 @@ namespace bbiwarg
 
         #region hand detection
         
+        /// <summary>
+        /// number of colors used to draw hands
+        /// </summary>
         public static readonly int HandNumColors = 3;
+
+        /// <summary>
+        /// maximum downwards depth difference between a pixel and a neighboring pixel belonging to the same hand
+        /// </summary>
         public static readonly int HandFloodFillDownDiff = 2;
+
+        /// <summary>
+        /// maximum upwards depth difference between a pixel and a neighboring pixel belonging to the same hand
+        /// </summary>
         public static readonly int HandFloodFillUpDiff = 2;
+
+        /// <summary>
+        /// maximum size of a hand relative to the whole image
+        /// </summary>
         public static readonly float HandMaxSize = 0.6f;
+
+        /// <summary>
+        /// minimum size of a hand realtive to the whole image
+        /// </summary>
         public static readonly float HandMinSize = 0.01f;
+
+        /// <summary>
+        /// maximum size of a hand extension mask relative to the whole image
+        /// </summary>
         public static readonly float HandExtensionMaxRelativeSize = 0.5f * HandMaxSize;
+
         public static readonly int HandExtendMaxDifference = 40;
         public static readonly float HandThumbDefectMaxDistanceToThumb = Parameters.FingerMaxWidth2D;
         public static readonly float HandThumbDefectMinThumbShortLengthRatio = 0.75f;
@@ -246,11 +301,34 @@ namespace bbiwarg
 
         #region hand tracker
 
+        /// <summary>
+        /// number of frames a hand needs to be detected before it is tracked
+        /// </summary>
         public static readonly int HandTrackerNumFramesDetectedUntilTracked = 5;
+
+        /// <summary>
+        /// number of frames a hand needs to be lost before it is deleted
+        /// </summary>
         public static readonly int HandTrackerNumFramesLostUntilDeleted = 5;
+
+        /// <summary>
+        /// if the centroid of a hand moves this relative amount it will have a similarity of 0 to itself at the previous position
+        /// </summary>
         public static readonly float HandTrackerMaxCentroidRelativeMove = TrackerMaxRelativeMove;
+
+        /// <summary>
+        /// xx entry for the measurement noise covariance matrix for the kalman filter used to smooth the hand centroid
+        /// </summary>
         public static readonly float HandmXX = 0.0005f;
+
+        /// <summary>
+        /// xy and yx entry for the measurement noise covariance matrix for the kalman filter used to smooth the hand centroid
+        /// </summary>
         public static readonly float HandmXY = 0.0f;
+
+        /// <summary>
+        /// yy entry for the measurement noise covariance matrix for the kalman filter used to smooth the hand centroid
+        /// </summary>
         public static readonly float HandmYY = 0.0005f;
 
         #endregion
@@ -258,7 +336,14 @@ namespace bbiwarg
 
         #region palm detection
 
+        /// <summary>
+        /// number of positions along the forefinger used as starting points to detect the palm width
+        /// </summary>
         public static readonly int PalmNumPositionsForPalmWidth = 5;
+
+        /// <summary>
+        /// relative tolerance which specifies when a point is considered to be in the palm grid
+        /// </summary>
         public static readonly float PalmInsideTolerance = 0.1f;
 
         #endregion
@@ -266,14 +351,49 @@ namespace bbiwarg
 
         #region palm tracker
 
+        /// <summary>
+        /// number of frames a palm needs to be detected before it is tracked
+        /// </summary>
         public static readonly int PalmTrackerNumFramesDetectedUntilTracked = 5;
+
+        /// <summary>
+        /// number of frames a palm needs to be lost before it is deleted
+        /// </summary>
         public static readonly int PalmTrackerNumFramesLostUntilDeleted = 5;
+
+        /// <summary>
+        /// 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
+        /// </summary>
         public static readonly float PalmTrackerMaxWristUpperRelativeMove = TrackerMaxRelativeMove;
+
+        /// <summary>
+        /// 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
+        /// </summary>
         public static readonly float PalmTrackerMaxWristLowerRelativeMove = TrackerMaxRelativeMove;
+
+        /// <summary>
+        /// 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
+        /// </summary>
         public static readonly float PalmTrackerMaxFingersUpperRelativeMove = TrackerMaxRelativeMove;
+
+        /// <summary>
+        /// 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
+        /// </summary>
         public static readonly float PalmTrackerMaxFingersLowerRelativeMove = TrackerMaxRelativeMove;
+
+        /// <summary>
+        /// xx entry for the measurement noise covariance matrix for the kalman filter used to smooth the palm grid points
+        /// </summary>
         public static readonly float PalmmXX = 0.00005f;
+
+        /// <summary>
+        /// xy and yx entry for the measurement noise covariance matrix for the kalman filter used to smooth the palm grid points
+        /// </summary>
         public static readonly float PalmmXY = 0.0f;
+
+        /// <summary>
+        /// yy entry for the measurement noise covariance matrix for the kalman filter used to smooth the palm grid points
+        /// </summary>
         public static readonly float PalmmYY = 0.00005f;
 
         #endregion

+ 9 - 1
bbiwarg/Recognition/HandRecognition/HandDetector.cs

@@ -92,6 +92,13 @@ namespace bbiwarg.Recognition.HandRecognition
                 if(!assignedFingers.Contains(finger)) {
                     Image<Gray, byte> handMask = getHandMask(finger.HandPoint);
 
+                    int numPixels = handMask.CountNonzero()[0];
+                    if (numPixels > Parameters.HandMaxSize * depthImage.Size.NumPixels)
+                    {
+                        assignedFingers.Add(finger);
+                        break;
+                    }
+
                     List<Finger> fingersOnHand = new List<Finger>();
                     List<Finger> fingersOnOtherHand = new List<Finger>();
 
@@ -121,7 +128,8 @@ namespace bbiwarg.Recognition.HandRecognition
         {
             Image<Gray, byte> mask = new Image<Gray, byte>(depthImage.Size.Width + 2, depthImage.Size.Height + 2);
             MCvConnectedComp comp = new MCvConnectedComp();
-            CvInvoke.cvFloodFill(modifiedHandDepthImage, p, new MCvScalar(255), new MCvScalar(Parameters.HandFloodFillDownDiff), new MCvScalar(Parameters.HandFloodFillUpDiff), out comp, Emgu.CV.CvEnum.CONNECTIVITY.FOUR_CONNECTED, Emgu.CV.CvEnum.FLOODFILL_FLAG.DEFAULT, mask);
+            CvInvoke.cvFloodFill(modifiedHandDepthImage, p, new MCvScalar(255), new MCvScalar(Parameters.HandFloodFillDownDiff), 
+                new MCvScalar(Parameters.HandFloodFillUpDiff), out comp, Emgu.CV.CvEnum.CONNECTIVITY.FOUR_CONNECTED, Emgu.CV.CvEnum.FLOODFILL_FLAG.DEFAULT, mask);
             return mask.Copy(new Rectangle(1, 1, depthImage.Size.Width, depthImage.Size.Height));
         }