|
@@ -19,6 +19,7 @@ namespace bbiwarg.Detectors.HandDetection
|
|
|
private EdgeImage edgeImage;
|
|
|
private List<Finger> fingers;
|
|
|
public List<Hand> Hands { get; private set; }
|
|
|
+ public Image<Gray, byte> HandMask { get; private set; }
|
|
|
public OutputImage outputImage;
|
|
|
|
|
|
public HandDetector(DepthImage depthImage, EdgeImage edgeImage, List<Finger> fingers, OutputImage outputImage)
|
|
@@ -38,6 +39,7 @@ namespace bbiwarg.Detectors.HandDetection
|
|
|
int height = depthImage.Height;
|
|
|
int maxArea = width * height;
|
|
|
Image<Gray, byte> image = edgeImage.Image.Copy().Dilate(2).Erode(2).Mul(255);
|
|
|
+ HandMask = image.CopyBlank();
|
|
|
|
|
|
//draw top finger slice
|
|
|
foreach (Finger finger in fingers)
|
|
@@ -79,9 +81,10 @@ 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);
|
|
|
if (comp.area < maxArea * Constants.HandMaxSize)
|
|
|
{
|
|
|
- Hand hand = new Hand(mask.Copy(new Rectangle(1, 1, width, height)).Mul(255));
|
|
|
- hand.addFinger(finger);
|
|
|
+ Image<Gray, byte> cropedMask = mask.Copy(new Rectangle(1, 1, width, height)).Mul(255);
|
|
|
+ Hand hand = new Hand(cropedMask, finger);
|
|
|
Hands.Add(hand);
|
|
|
+ HandMask = HandMask.Or(cropedMask);
|
|
|
}
|
|
|
}
|
|
|
}
|