|
@@ -14,6 +14,8 @@ namespace bbiwarg.Images
|
|
{
|
|
{
|
|
private Image<Gray, Byte> image;
|
|
private Image<Gray, Byte> image;
|
|
private int width, height;
|
|
private int width, height;
|
|
|
|
+ private Contour<Point> contour;
|
|
|
|
+ bool[,] inContour;
|
|
|
|
|
|
public PalmImage(EdgeImage edgeImage)
|
|
public PalmImage(EdgeImage edgeImage)
|
|
{
|
|
{
|
|
@@ -22,16 +24,40 @@ namespace bbiwarg.Images
|
|
height = image.Height;
|
|
height = image.Height;
|
|
|
|
|
|
findContours();
|
|
findContours();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
private void findContours()
|
|
private void findContours()
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ image = image.Dilate(3);
|
|
|
|
+ contour = image.FindContours(Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_NONE, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_EXTERNAL);
|
|
|
|
+
|
|
|
|
+ Contour<Point> maxContour = contour;
|
|
|
|
+ double maxPerimeter = 0;
|
|
|
|
+ int count = 0;
|
|
|
|
+ while (contour != null)
|
|
|
|
+ {
|
|
|
|
+ ++count;
|
|
|
|
+ if (contour.Perimeter > maxPerimeter)
|
|
|
|
+ {
|
|
|
|
+ maxPerimeter = contour.Perimeter;
|
|
|
|
+ maxContour = contour;
|
|
|
|
+ }
|
|
|
|
+ contour = contour.HNext;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Console.WriteLine("numContours: " + count + "\nmaxPerimeter = " + maxPerimeter);
|
|
|
|
+
|
|
|
|
+ inContour = new bool[width, height];
|
|
|
|
+ foreach (Point p in maxContour)
|
|
|
|
+ inContour[p.X, p.Y] = true;
|
|
}
|
|
}
|
|
|
|
|
|
public bool belongsToPalm(int x, int y)
|
|
public bool belongsToPalm(int x, int y)
|
|
{
|
|
{
|
|
- return false;
|
|
|
|
|
|
+ return inContour[x, y];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|