/// <summary> /// Checks if list contains a certain blob.It does it by checking if the /// rectangle surounding the blob intersects with other blobs in list. /// The algorithm returns the position of the one with the biggest intersection. /// </summary> /// <param name="blob">The blob to search for,.</param> /// <param name="blobsList">The blobs list.</param> /// <returns>Blob id that was found in the collection that intersects with the given argument.null if none was found.</returns> private static String containBlob(ExtendedBlob blob, ICollection <KeyValuePair <String, RPair <ExtendedBlob, int> > > blobsList) { Rectangle blobRetangle = blob.Rectangle; int maxIntersectSize = 0; String returnValue = null; // Man...this is ugly foreach (KeyValuePair <String, RPair <ExtendedBlob, int> > value in blobsList) { // Intersect both rectangles. RPair <ExtendedBlob, int> exBlob = value.Value; Rectangle intersect = Rectangle.Intersect(exBlob.First.Rectangle, blobRetangle); // Check size of intersected rectangle if it's bigger then max. int size = intersect.Width * intersect.Height; if (size > maxIntersectSize) { returnValue = value.Key; // Update location. maxIntersectSize = size; } } return(returnValue); }
/// <summary> /// Checks if list contains a certain blob.It does it by checking if the /// rectangle surounding the blob intersects with other blobs in list. /// The algorithm returns the position of the one with the biggest intersection. /// </summary> /// <param name="blob">The blob to search for,.</param> /// <param name="blobsList">The blobs list.</param> /// <returns>Blob id that was found in the collection that intersects with the given argument.null if none was found.</returns> private static String containBlob(ExtendedBlob blob, ICollection<KeyValuePair<String, RPair<ExtendedBlob, int>>> blobsList) { Rectangle blobRetangle = blob.Rectangle; int maxIntersectSize = 0; String returnValue = null; // Man...this is ugly foreach (KeyValuePair<String, RPair<ExtendedBlob, int>> value in blobsList) { // Intersect both rectangles. RPair<ExtendedBlob, int> exBlob = value.Value; Rectangle intersect = Rectangle.Intersect(exBlob.First.Rectangle, blobRetangle); // Check size of intersected rectangle if it's bigger then max. int size = intersect.Width * intersect.Height; if (size > maxIntersectSize) { returnValue = value.Key; // Update location. maxIntersectSize = size; } } return returnValue ; }