|
@@ -1,10 +1,10 @@
|
|
|
-using bbiwarg.Images;
|
|
|
-using bbiwarg.Input.InputHandling;
|
|
|
-using bbiwarg.Utility;
|
|
|
+using BBIWARG.Images;
|
|
|
+using BBIWARG.Input.InputHandling;
|
|
|
+using BBIWARG.Utility;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
-namespace bbiwarg.Recognition.FingerRecognition
|
|
|
+namespace BBIWARG.Recognition.FingerRecognition
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// Detects fingers in the given depth and edge images. The finger detection searches for edges in the edge image and tries to find an initial finger slice. For each found finger slice, the finger detector tries to move along the finger direction to extend the finger slice trail. If the trail reaches its end, the finger detector removes the first few slices and starts the trail expansion in opposite direction. If the complete slice trail is long enough, the finger slices are sorted into correct order and the edges around the finger are removed to increase performance for the next finger detection.
|
|
@@ -12,7 +12,7 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
internal class FingerDetector
|
|
|
{
|
|
|
/// <summary>
|
|
|
- /// the coordinateConverter (used to calculate finger width (in milimeters))
|
|
|
+ /// the coordinateConverter (used to calculate finger width (in millimeters))
|
|
|
/// </summary>
|
|
|
private CoordinateConverter coordinateConverter;
|
|
|
|
|
@@ -92,22 +92,22 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// Sorts the finger slices in correct order an checks if the finger is a valid finger (<see cref="isCrippleFinger(Finger)"/>). If it is valid the finger is added to the list of detected fingers. Afterwards the edges around the finger are removed to surpress a new finger search for the same finger.
|
|
|
+ /// Sorts the finger slices in correct order an checks if the finger is a valid finger (<see cref="isCrippleFinger(Finger)"/>). If it is valid the finger is added to the list of detected fingers. Afterwards the edges around the finger are removed to suppress a new finger search for the same finger.
|
|
|
/// </summary>
|
|
|
/// <param name="trail">the slice trail of the possible finger</param>
|
|
|
private void createFingerFromTrail(FingerSliceTrail trail)
|
|
|
{
|
|
|
- //bring finger in correct direction Tip->Hand
|
|
|
+ // bring finger in correct direction Tip->Hand
|
|
|
trail = orderTrailTipToHand(trail);
|
|
|
|
|
|
- //create finger
|
|
|
+ // create finger
|
|
|
Finger finger = new Finger(trail);
|
|
|
|
|
|
- //add finger
|
|
|
+ // add finger
|
|
|
if (!isCrippleFinger(finger))
|
|
|
fingers.Add(finger);
|
|
|
|
|
|
- //remove edges around detected finger to improve performance
|
|
|
+ // remove edges around detected finger to improve performance
|
|
|
edgeImageAdapted.removeEdgesInsidePolygon(finger.getContour(Parameters.FingerContourMargin).ToArray());
|
|
|
}
|
|
|
|
|
@@ -163,7 +163,7 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
/// </summary>
|
|
|
/// <param name="position">the position somewhere in the middle of the possible finger</param>
|
|
|
/// <param name="direction">the finger direction</param>
|
|
|
- /// <param name="reversed">indicates wether start and end should be swapped</param>
|
|
|
+ /// <param name="reversed">indicates whether start and end should be swapped</param>
|
|
|
/// <returns>the found finger slice or null</returns>
|
|
|
private FingerSlice findFingerSliceFromMid(Vector2D position, Vector2D direction, bool reversed = false)
|
|
|
{
|
|
@@ -249,21 +249,21 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
/// <summary>
|
|
|
/// Checks if a possible finger slice is located on a finger. To pass this test, the depth value at the mid has to be lower than on the outside (start and end).
|
|
|
/// </summary>
|
|
|
- /// <param name="slice">the possible finger slcie</param>
|
|
|
- /// <returns>wether the slice is located on a finger</returns>
|
|
|
+ /// <param name="slice">the possible finger slice</param>
|
|
|
+ /// <returns>whether the slice is located on a finger</returns>
|
|
|
private bool fingerSliceDepthTest(FingerSlice slice)
|
|
|
{
|
|
|
Int16 depthStart = depthImage.getDepthAt(slice.Start.moveWithinBound(depthImage.Size, slice.Direction.getInverse(), Parameters.FingerContourMargin));
|
|
|
Int16 depthMid = depthImage.getDepthAt(slice.Mid);
|
|
|
Int16 depthEnd = depthImage.getDepthAt(slice.End.moveWithinBound(depthImage.Size, slice.Direction, Parameters.FingerContourMargin));
|
|
|
- return (depthStart > depthMid && depthMid < depthEnd);
|
|
|
+ return depthStart > depthMid && depthMid < depthEnd;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// Gets the edge direction of the given edge point. The edge direction is either horizontal, vertical, diagonal (both) or null.
|
|
|
/// </summary>
|
|
|
/// <param name="edgePoint">the edge point</param>
|
|
|
- /// <returns>the edge directon at the given point</returns>
|
|
|
+ /// <returns>the edge direction at the given point</returns>
|
|
|
private Vector2D getEdgeDirection(Vector2D edgePoint)
|
|
|
{
|
|
|
int x = edgePoint.IntX;
|
|
@@ -277,10 +277,10 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// Checks wether the finger has enough space around itself (fingers from a closed hand shouldn't bee detected).
|
|
|
+ /// Checks whether the finger has enough space around itself (fingers from a closed hand shouldn't bee detected).
|
|
|
/// </summary>
|
|
|
/// <param name="finger">the finger</param>
|
|
|
- /// <returns>wether the finger has enough space around itself</returns>
|
|
|
+ /// <returns>whether the finger has enough space around itself</returns>
|
|
|
private bool isCrippleFinger(Finger finger)
|
|
|
{
|
|
|
FingerSlice midSlice = finger.SliceTrail.MidSlice;
|
|
@@ -292,11 +292,11 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
Int16 depthAtOut2 = depthImage.getDepthAt(out2);
|
|
|
int minDepthDifference = Math.Min(Math.Abs(depthAtFinger - depthAtOut1), Math.Abs(depthAtFinger - depthAtOut2));
|
|
|
|
|
|
- return (minDepthDifference < Parameters.FingerMaxCrippleDifference);
|
|
|
+ return minDepthDifference < Parameters.FingerMaxCrippleDifference;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// Sorts a slice trail in the corrent order, so that the start is at the finger tip and the end is at the hand. To guess the correct order the width of the first and last slice are compared.
|
|
|
+ /// Sorts a slice trail in the correct order, so that the start is at the finger tip and the end is at the hand. To guess the correct order the width of the first and last slice are compared.
|
|
|
/// </summary>
|
|
|
/// <param name="trail">the slice trail of the finger</param>
|
|
|
/// <returns>the slice trail of the finger in correct order</returns>
|