public static List <Rectangle> EnlargetRectangles(List <Rectangle> rectangles, int handle) { List <Rectangle> result = new List <Rectangle>(); Size dim = ImageOperations.GetImageDimensions(handle); for (int i = 0; i < rectangles.Count; ++i) { int x = rectangles[i].X; int y = rectangles[i].Y; int width = rectangles[i].Width; int height = rectangles[i].Height; if (x >= 1) { x = x - 1; } if (y >= 1) { y = y - 1; } if (x + width - 1 < dim.Width - 2) { width += 2; } if (y + height - 1 < dim.Height - 2) { height += 2; } result.Add(new Rectangle(x, y, width, height)); } return(result); }
public static void Method_A(int handle) { Size s = ImageOperations.GetImageDimensions(handle); ImageOperations.Crop(handle, 140, 0, s.Width - 140, s.Height); //ImageOperations.CardScan_RectifyRawImageHighGradientError(handle); int handle2 = ImageOperations.Copy(handle); ImageOperations.SizeHalve(handle2, HalveSizeType.Average); ImageOperations.Invert(handle2); float a = 90.0f - ImageOperations.HoughGradient(handle2, 84, 96, 46); ImageOperations.DeleteImage(handle2); ImageOperations.Rotate(handle, a); int minx = 0; int miny = 0; int maxx = 0; int maxy = 0; ImageOperations.CardScan_DetermineCardBounds(handle, 20, ref minx, ref maxx, ref miny, ref maxy); ImageOperations.Crop(handle, minx, miny, maxx - minx + 1, maxy - miny + 1); }