|
@@ -43,12 +43,18 @@ namespace bbiwarg.Detectors.HandDetection
|
|
foreach (Finger finger in fingers)
|
|
foreach (Finger finger in fingers)
|
|
{
|
|
{
|
|
// TODO: connect contour with other edges
|
|
// TODO: connect contour with other edges
|
|
- //Contour<Point> contour = finger.getContour();
|
|
|
|
- //image.FillConvexPoly(contour.ToArray(), new Gray(0));
|
|
|
|
- //image.DrawPolyline(finger.getContour().ToArray(), false, new Gray(255), 1);
|
|
|
|
|
|
+ Contour<Point> contour = finger.getContour();
|
|
|
|
+ image.FillConvexPoly(contour.ToArray(), new Gray(0));
|
|
|
|
+ image.DrawPolyline(finger.getContour().ToArray(), true, new Gray(255), 1);
|
|
|
|
|
|
- FingerSlice slice = finger.SliceTrail.Slices[1];
|
|
|
|
- image.Draw(new Emgu.CV.Structure.LineSegment2D(slice.Start, slice.End), new Gray(255), 2);
|
|
|
|
|
|
+ FingerSlice slice = finger.SliceTrail.End;
|
|
|
|
+ Vector2D direction = slice.LineSegment.Line.Direction;
|
|
|
|
+ Vector2D start = slice.Start+(Constants.FingerContourMargin+Constants.FingerSliceOverlapFactor)*direction;
|
|
|
|
+ Vector2D end = slice.End-(Constants.FingerContourMargin+Constants.FingerSliceOverlapFactor)*direction;
|
|
|
|
+ image.Draw(new Emgu.CV.Structure.LineSegment2D(start, end), new Gray(0), 2);
|
|
|
|
+
|
|
|
|
+ //FingerSlice slice = finger.SliceTrail.Slices[1];
|
|
|
|
+ //image.Draw(new Emgu.CV.Structure.LineSegment2D(slice.Start, slice.End), new Gray(255), 2);
|
|
}
|
|
}
|
|
|
|
|
|
Hands = new List<Hand>();
|
|
Hands = new List<Hand>();
|
|
@@ -62,6 +68,7 @@ namespace bbiwarg.Detectors.HandDetection
|
|
{
|
|
{
|
|
hand.addFinger(finger);
|
|
hand.addFinger(finger);
|
|
newHand = false;
|
|
newHand = false;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -72,7 +79,7 @@ namespace bbiwarg.Detectors.HandDetection
|
|
CvInvoke.cvFloodFill(image, finger.HandPoint, new MCvScalar(255), new MCvScalar(1), new MCvScalar(1), out comp, Emgu.CV.CvEnum.CONNECTIVITY.FOUR_CONNECTED, Emgu.CV.CvEnum.FLOODFILL_FLAG.DEFAULT, mask);
|
|
CvInvoke.cvFloodFill(image, finger.HandPoint, new MCvScalar(255), new MCvScalar(1), new MCvScalar(1), out comp, Emgu.CV.CvEnum.CONNECTIVITY.FOUR_CONNECTED, Emgu.CV.CvEnum.FLOODFILL_FLAG.DEFAULT, mask);
|
|
if (comp.area < maxArea * Constants.HandMaxSize)
|
|
if (comp.area < maxArea * Constants.HandMaxSize)
|
|
{
|
|
{
|
|
- Hand hand = new Hand(mask.Copy(new Rectangle(1, 1, width, height)));
|
|
|
|
|
|
+ Hand hand = new Hand(mask.Copy(new Rectangle(1, 1, width, height)).Mul(255));
|
|
hand.addFinger(finger);
|
|
hand.addFinger(finger);
|
|
Hands.Add(hand);
|
|
Hands.Add(hand);
|
|
}
|
|
}
|
|
@@ -80,11 +87,12 @@ namespace bbiwarg.Detectors.HandDetection
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void drawHands() {
|
|
|
|
|
|
+ private void drawHands()
|
|
|
|
+ {
|
|
int maxIndex = Math.Min(3, Hands.Count);
|
|
int maxIndex = Math.Min(3, Hands.Count);
|
|
- for (int i = 0; i < maxIndex ; i++)
|
|
|
|
|
|
+ for (int i = 0; i < maxIndex; i++)
|
|
{
|
|
{
|
|
- outputImage.Image[i] = Hands[i].Mask.Mul(255);
|
|
|
|
|
|
+ outputImage.Image[i] = Hands[i].Mask;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|