public void FindContourTest2()
{
Bitmap bmp = Accord.Imaging.Image.Clone(Properties.Resources.hand2);
BlobCounter bc = new BlobCounter(bmp);
bc.ObjectsOrder = ObjectsOrder.Size;
Blob[] blobs = bc.GetObjectsInformation();
bc.ExtractBlobsImage(bmp, blobs[0], true);
List<IntPoint> expected = bc.GetBlobsEdgePoints(blobs[0]);
Bitmap blob = blobs[0].Image.ToManagedImage();
BorderFollowing bf = new BorderFollowing();
List<IntPoint> actual = bf.FindContour(blob);
foreach (IntPoint point in expected)
Assert.IsTrue(actual.Contains(point));
IntPoint prev = actual[0];
for (int i = 1; i < actual.Count; i++)
{
IntPoint curr = actual[i];
Assert.IsTrue(System.Math.Abs(prev.X - curr.X) <= 1 &&
System.Math.Abs(prev.Y - curr.Y) <= 1);
prev = curr;
}
IntPoint first = actual[0];
IntPoint last = actual[actual.Count - 1];
Assert.IsTrue(System.Math.Abs(first.X - last.X) <= 1 &&
System.Math.Abs(first.Y - last.Y) <= 1);
}