public void FindDefectsTest()
{
Bitmap bmp = Accord.Imaging.Image.Clone(Properties.Resources.hand);
Bitmap gray = Accord.Imaging.Filters.Grayscale.CommonAlgorithms.BT709.Apply(bmp);
BlobCounter bc = new BlobCounter(gray);
bc.ObjectsOrder = ObjectsOrder.Size;
Blob[] blobs = bc.GetObjectsInformation();
bc.ExtractBlobsImage(bmp, blobs[0], true);
Bitmap blob = blobs[0].Image.ToManagedImage();
BorderFollowing bf = new BorderFollowing();
List<IntPoint> contour = bf.FindContour(blob);
GrahamConvexHull graham = new GrahamConvexHull();
List<IntPoint> hull = graham.FindHull(contour);
ConvexHullDefects hullDefects = new ConvexHullDefects(10);
List<ConvexityDefect> defects = hullDefects.FindDefects(contour, hull);
/* PointsMarker marker = new PointsMarker(hull, Color.Green, 10);
marker.ApplyInPlace(blob);
ImageBox.Show(blob);
*/
Assert.AreEqual(2, defects.Count);
Assert.AreEqual(new IntPoint(130, 10), contour[defects[0].Start]);
Assert.AreEqual(new IntPoint(93, 109), contour[defects[0].Point]);
Assert.AreEqual(new IntPoint(64, 9), contour[defects[0].End]);
Assert.AreEqual(99.549179077148438, defects[0].Depth, 1e-5);
Assert.IsFalse(double.IsNaN(defects[0].Depth));
// Assert.AreEqual(9912.9531239366424, defects[0].Area);
Assert.AreEqual(new IntPoint(49, 18), contour[defects[1].Start]);
Assert.AreEqual(new IntPoint(61, 106), contour[defects[1].Point]);
Assert.AreEqual(new IntPoint(18, 127), contour[defects[1].End]);
Assert.AreEqual(35.615153852366504, defects[1].Depth, 1e-5);
Assert.IsFalse(double.IsNaN(defects[1].Depth));
// Assert.AreEqual(2293.7535682510002, defects[1].Area);
}